Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    PHP




How To Process Some Variables, Then Place Them Into POST And Redirect?


I'd like to do the following in PHP. Is there a way?

Someone submits a form with data. I want to process the data, then once I'm done with it, take two of the variables, make them post variables and basically redirect the browser as if the user pressed the submit button with data filled in.

The variables can't appear in the url.




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Post Variables From Header Redirect
I'm using header to redirect the browser to another page and in the url I've added ?var1=value1&var2=value2 to pass some argument as get to that script, can I pass in some way, arguments as post in this case ? may I do it in both methos at the same time ?

What's A Good Place To Post Code?
I have been working on a nifty PDF library written in PHP that I want
to make available to the public. The package is a bit too large to be
posted at a forum somewhere. I'm also planning to include a good amount
of documentation and example. SourceForge seems a bit of an overkill
for such a small project. What I'm looking for is something like a blog
for programmer types.

Post And Redirect With Post Data
The solution we have though up is the following:

1. The user fills in data in a form and hits submit
- This submits (POST) to another page (redirect.php)
2. redirect.php adds more POST data to POST and then submits all this POST data to another page (offsite [payment portal])

The reason why we have to do this is for someone who knows our to read html source code, could easily find the sucessful page which will then do the processing we need to do on our side. Which means freebeis.

How Does PHP5 Process POST Data In Creating $_POST Array?
I need to save a wav file that is HTTP POSTed to a php page.
What does PHP5 do automatically to a POSTed variable when it puts it in
the $_POST[] superglobal array? I haven't been able to find any info on
this....

I have a script that does what I want in PERL, but I need to do it in
PHP.
I think the PERL does something magic when it does this:

#### PERL CODE ####
read ( STDIN, $buffer, $ENV { 'CONTENT_LENGTH' } );

@pairs = split ( /&/, $buffer );

foreach $pair ( @pairs )
{
($name, $value) = split(/=/, $pair);

$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;

$FORM { $name } = $value;
}
#### END PERL CODE ####

Pass Variables To A Background Process.
I know how to start a process in the background, but how do I pass variables (from the calling script) to the background process?

Post Redirect Get
I'm doing a website for a client - and all my forms (bar one) are using the POST method. I'm getting the typical "Don't Hit Back" message - due the post method recalling - and double submitting data. I want to get rid of this and I've read about the PRG method.

but it doesn't seem to work. Both pages have their code echo'd too - so you can have a look at the code i've put on there. Any ideas what's gone wrong?

Post To One Url And Redirect To Another
Let me start off by saying the script below does work. However once the script is submitted and passes all the setting to my providers' URL to initiate a sms text message. As I stated the script works fine however the output is just a white screen on my providers page (as my script submitted the url). I am looking for a way to redirect users to a different page then the post Code:

Redirect With Post Data Using PHP
Normally I use javascript for doing this form1.submit() it works
properly. it can redirect to another page with post data. But there
is another problem. Some cheater Do Cheat with me. they click Stop
Button on IE when it is submitted and they view the source. by this
way they know my secure information what i need to supply to another
page..

Any One know this solution using PHP? I know there is a solution for doing this Because some websites use php to do it like 2CheckOut and WorldPay. But I don`t know what the solution. Can Anybody Help me?

Fsockopen POST Vars And Redirect
There is plenty of information in these forums on sending post variables using fsockopen and reading the server response but I cant find any solution to sending the POST variables using fsockopen and also redirecting to the page the POST variables are sent to.
test file is attached and but I cant figure out how to redirect to the target file Anyone know how to do this?

Old Question (perhaps): Redirect With POST Of Data?
A question that has certainly been asked before and I've googled etc.
for answers with no certain outcome...

I'd like my PHP script to redirect the client browser to another page,
POSTing some data at the same time. (To take them back to an html page
showing a form that needs correcting because some data is missing.)
I believe this is either tricky or not possible from what I've seen, but
I'd just like to see what others think currently...

It's a little annoying because plain redirecting is easy and plain POST
to a URL (and get the results back) is easy too, but combining them
seems to be another matter...

How Redirect A User To Another Page And Send Some Variable With The Post Method?
I make a user registration. It contains two/more page. First page is for official purpose. User ID, password and some other official information is in first page and user basic information is in second page. If user enter an user id that already exist in database then a message show the same page to change his user id otherwise page is redirect to second page and send user id, and other variable that was in first page.   My Code:

Header Redirect With GET Variables
I have PHP 5.2.2 installed on my WinXP machine. I am using the web server built into Proxy Plus, with PHP enabled using php-cgi.exe. It seem to be working fine, but I have a problem trying to redirect to a new page using the header() function.

When I do:
header('Location: mypage.php?var=fred');

The browser (Firefox 2.0.0.3) get redirected and shows the following in the location bar:
http://localhost/mypage.php?var:%20fred

Notice that the "=" gets changed to ":%20"

Of course this is not working. I have tried everything I can think of, including using %3d instead of =. Nothing seems to work. Any ideas? Could this be a problem with PHP, or a problem with the web server in Proxy Plus, or something else? I have NOT tried this on any other web server.

Passing Along Variables During A Htaccess 301 Redirect
I have a form people fill out on my website, and on submit they are then sent to an appropriate document depending on their input.

Some people link directly to those documents instead of to my form page which the preferred method. Therefore I added to my .htacess a 301 redirect to the form page for visitors requesting documents with a referer other than blank or from my domain.

The 301 redirect is important to me so people's address bars change to the matching page, and for search engines to accredit the form page for the incoming links.

My only concern is, once there, the visitor will see an empty form. For usability, I would strongly like to send which document the user requested to the form page, so once loaded, the form will be pre filled out for their appropriate document.

I would know how to do this using my .htaccess page if I wanted to have that document name in the address bar, but I would strongly like to have the address bar be the normal form page address.

Is it possible that in the redirect I can send that variable in a POST type method, where the information is not visible in the address bar?

I guess if I can't do the first I could redirect the visitor to an intermediary page that just reads the variable in the link and stores that value in a cookie before sending the visitor off the the form page.

Passing Variables In Redirect Script?
Does anyone know how to pass a variable(text input from form) so that the variable will be sent along to the redirect page (as in): header("Location:...page2.php");

Domain Redirect - Loses Session Variables
I just purchased a new domain name and I've set it up as a redirect to a
folder on my main site. What is happening is the index.php page checks a
session variable to see if the user is logged on and if not it displays a
login screen. However, after loggin in it just keeps coming back to the
login screen because the session variables are getting lost.

I inserted "session_write_close()" prior to the header("Location:
Index.PHP) and it now is working on my developement computer but on 2 other
computers it is still just coming back to the login screen.



Retain Variables After Form Submit Redirect
I have a section on my website where only users that are "logged in" can view and I'm using the following syntax at the top of verify that they are logged in and that they can only view their profile:

if((!$session->logged_in) || (($session->num != $_GET[num]) && ($session->num != $_POST[num])))
{
header("Location:websiteaddresshere");
exit;
}
This works great. The get to your account you have to be logged in and use the user: account.php?num=# or else you are redirected.

My problem is as follows. I have a section to edit your account details that uses the same code as above.
However, once you submit the form on accountedit.php, it redirects to the main website address instead of displaying some text saying the edit worked successfully.

How do I submit a form and add "?num=$usernum" to the end of the website url so they aren't redirected?

Can't See My Post Variables
I work on an application which runs on our Intranet network, so security it's not a big issue, and my phpinfo() get me register_globals on (php 4.1.2 on a Debian system).
The problems is that I can't see my post variables (only with $_POST) and I don't get it . Is there another setting wich overrides php.ini and stop my register_globals ->on to behave properly ?

With Variables And POST
On my online order form, I need to send a few variables to my
credit-card processor. These variables are for non-secure customer
comments, and will be sent through the usual metod, i.e.,
<form action="https://orderpage.ic3.com/hop/orderform.jsp"
method="post">

However, one variable is a text-area box for a detailed customer
comment, and this variable can get pretty long. But my credit-card
processor has a 256 byte maximum length limit for all POSTed
variables. However, I can add as many of these 256-byte variables as I
like.

So how can I accomplish this in the most simple, efficient, and
elegant manner? How can I break up the text-area vaiable into 256-byte
pieces and then send these variables via POST along with all of the
other form variables which will be POSTed through the usual HTML
means?

POST/GET Into Variables
how does this look? should this by me calling ... myforms = new
forms(); work by turning all key/value pairs for both get and post
into variable names of the same name as the get/post key, and the
variable values as the values from the post/get?

class forms {
// Some stuff
var $MyPosts;
var $MyGets;...

Post Cookie Variables
I have a page that include on the top the result of a cookie (i come form a previous page with some inputs) in the second part of the page a form with name surname email etc etc
On submit all the information (cookie + form) are sent by email...
my problem is this: in the email doesn't appear the cookie values
i try to create in the form tab a hidden fiel d with this value

<input name="NewEoc" type="hidden" value="<?php echo $COOKIE['NewEoc'] ?>">

Variables Past By Get And Post
I'd like a generic include that goes at the top of all pages that mysql escapes the variables past to the script. Is there a way to refer to the each of the variables past, for example (in pseudo code):

for(each $XX in (list of get/post variables)) {
$$XX = mysql_escape_string($$XX);
}

Empty Variables And 4.21 (POST/GET)
With global variables set to on, I always had the following in my script to make sure variables had a default value:

if (empty($var)) {
$var = 1;}

Now with 4.21, I changed it to:

if (empty($_GET['var'])) {
$var = 1;}

The problem is sometimes I use GET and sometimes I use POST. With global variables on it didn't matter. Now it does. Is there a way to do this? When I try if (empty($_GET['var']) || empty($_POST['var'])), it doesn't work because one or the other will always be empty at any one time.

Processing GET And POST Variables
Below is a function adapted from one found in phpMyEdit.class.php
http://platon.sk/projects/release_l...hp?project_id=5
phpMyEdit is a form generator for PHP/MySQL.

I think this function works great, especially for forms where data is
redisplayed due to failed validation of user input. I wonder what the
opinion of other PHP users would be.

function get_cgi_var($name, $default_value = null)
{
// From the phpMyEdit project
// Usage: $name = get_cgi_var('name');
static $magic_quotes_gpc = null;
if ($magic_quotes_gpc === null) {
$magic_quotes_gpc = get_magic_quotes_gpc();
}
global $HTTP_GET_VARS;
$var = @$HTTP_GET_VARS[$name];
if (! isset($var)) {
global $HTTP_POST_VARS;
$var = @$HTTP_POST_VARS[$name];
}
if (isset($var)) {
if ($magic_quotes_gpc) {
if (is_array($var)) {
foreach (array_keys($var) as $key) {
$var[$key] = stripslashes(trim(strip_tags($var[$key])));
}
return $var;
} else {
$var = stripslashes(trim(strip_tags($var)));
}
}
} else {
$var = @$default_value;
}
return $var;
// If data is displayed/posted using htmlspecialchars($var)
// return @$HTTP_POST_VARS ? html_entity_decode($var, ENT_QUOTES) :
$var;
};

$name = get_cgi_var('name');

POST Variables And Sockets...
I have a server that uses Cpanel, and my mail server is Cpanel's cppop. I am trying to create an email address. With an older version of Cpanel, you could use this command line through sockets.

GET /frontend/x2/mail/doaddpop.html?email=emailaddress&domain=mysite.ca&password=emailpassword&quota=10 HTTP/1.0
Authorization: Basic $pass

That worked just fine because email addresses were created through GET variables. Now, they have changed it to POST variables. Now, I need to create an email address, while faking the following post variables:

email
domain
password
quota

I know I need to use sockets, and pass the POST variables, but I have no idea how to.

Passing Variables With POST
I have a file named login.php that basically just checks if a username and password are in a MySQL database. If they aren't then it shows access denied. If they are then I want to pass the $name and $pass to project.php in a different directory. Code:

Looping Thru POST Variables
I need to know how to loop thru the variables my script receives from a form with action=post. I need to build a list of only those variables that comes from my checkboxes.

POST Variables Not Coming Through
For some reason, at random posts, the post variables don't get thru to
the server. For example, if there is are two text fields: name and
email... (I have register_globals on)... When I try to update the
database with a query and use $name, $email, the $name is missing or
the $email is missing. I am building an intranet application and all
the 20 or so clients run IE. This happens very rarely. Something like
once in 100 updates.

But I can see this in the log files as update contact set name="",
email="asda@pol.com" where contact_id=918. Notice the name field is
blank. I have JS checks in the client side which does not allow blank
name field..

Is this an IE random error? How do I get over this?

POST Variables From Programs
we are trying to make a program in C++ that will comminicate with a PHP script. But we dont know how to get the variables from the program. We got it figured out with perl/CGI, but PHP seems to be a better way to connect to SQL server. On PHP the GET works, its easy, but it's not secure enough. I need informtion on what headers does the PHP require to get the POSTed data from a program.

Sending Variables As POST?
I am currently trying to send information to another page using the POST method. Unfortuantley I can not find any information on how to do this. Currently I am trying

Header ("Location: newpage.html?var=test&var2=test2");

Obviously this re-directs with the variables, but they are send using GET. Not what it need. Any ideas on how to post these variables to the new page?

Apache/PHP Post Variables
I'm working with someone on a PHP project. The other person is doing
testing of scripts on their personal machine using Apache as a web server.
The production server and the one I'm using are both using IIS.

This other person reports that in their PHP scripts when tested with Apache,
form variable sent via the POST method are not "coming through." (This is
even using the "long method" of specifying them as $HTTP_POST_VARS['x'].)
These same scripts work fine on the the IIS machine (the POST variable come
through).

I've looked online to see if I can find out if anything special must be
specified in the Apache configuration to enable the POST method, and
although I found other people posting similar problems, I saw no reference
to a solution.

Not Catching The Post Variables
For some reason my PHP script is not catching the post variables that should be being sent by this form. Code:

Forward POST-variables
I have a form which should be submitted with either of two actions. Tried with javascript but this seems unreliable. Now looking at php and a processor page as the action of the form (process.php) which then sends the user to the different actionpages...can't figure out how to forward the post-variables to the different pages. Code:

Passing Post Variables Using Fopen()
I'm trying to pull data from a website and read it into a file the I
can parse. I've done the before to site without post variables but I
can seem to get my statments to work with the post. Can someone help
me out?below is the code I have so far.

$url="www.somesitethatneedspostvariables.com";

$postdata = http_build_query(
array( 'postvarname1' ='value1',
'postvarname2' ='value2'
)
);
$opts = array('http' =>
array(
'method' ='POST',
'header' ='Content-type: application/x-www-form-
urlencoded',
'content' =$postdata
)
);

$context = stream_context_create($opts);
$file = @fopen($url, "r", $content) or die("Connection Error, Please
contact Webmaster ERROR CODE=0xDEADBEEF");

Get Unknown Number Of Variables From POST Or GET.
I am trying to create a page that redirects users to an advertiser's page. The reason for the redirect is statistics about who clicks where.

The situation is simple when I only need to redirect them to a page, but some of the ads on my site include forms which put data in either POST or GET and I need to know how to allow my redirect page to take that data from POST or GET, whatever that data is, and pass it on to the page that the data were intended for.

I think that once I get the data I can simply create a hidden form, on the redirect page, with the data from POST or GET already in it. However, I don't know how to get an arbitrary number of variables from POST or GET.

Search - Pass Variables Or Self Post
I've created a database of documents that is searchable by a variety of fields. Currently I have a PHP page called search.php with a form to get the keywords from the user and it then passes this back to itself, runs a query and displays the results. Doing it this way the address for the search page and the results of the search is the same.

This all works fine and I'm happy with it but I was wondering if it should be implemented differently where the keywords are used as a part of the address like with search engines with Google. I don't know what the advantages or disadvantages is for either method so I'm keen to hear what others think is the best method.

How Can I Pass Variables Via POST In A Script?
Let's assume we have a script that only accepts POST variable input.. How is it possible to pass variables to it (using a php-script)?

How To Loop Through POST Variables And Contents
I am looking for a standard way/function to loop through all POST variables
and their respective contents to update a database record.

Here's my ideal to pass a function and it update:
session variable - "ID" - that holds the record ID to update
$_POST or $HTTP_POST_VARS

The function would update the $_POST vaiables of the ID record with the
$_POST variable's contents.

Get/Post Variables Not Showing Under Windows
I'm quite rusty with PHP and have a little issue. A script transmit parameters to itself through a simple form. It works fine when I run it on aproduction server (Linux+Apache+PHP4). When I run the same script on my development machine (Win2K+Apache2+PHP5) the submited variables
don't show.

Here's some simplified code:

<HTML>
<BODY>

<?php
print_r ($_SERVER);
print_r ($submit);
switch ($submit) {
// ...
}
?>

<FORM METHOD=Get>Display content of:<BR>
<INPUT TYPE=submit NAME=submit VALUE=APACD1>
<INPUT TYPE=submit NAME=submit VALUE=APACD2>
// ...
</FORM>

</BODY>
</HTML>

PHP Not Populating Form Variables Passed Through POST Or GET
I"m running:

Windows Xp SP2
Apache2
PHP5
MySQL4

Everything seems fine and dandy, and I can do scripting on server side, but for some reason I cannot get data from a form to be put into a variable.

I have a simple form in an html page which submits, and in the php script that handles the input, none of the data in the form is going into the variables.

My php.ini file does have all the GPC's in place(ie variable_order, the way they get processed).

How Do You Parse Post Variables To A Popup Window?
I know this isnt really a php question but can anyone tell me how
you parse post variables to a popup window, here's my code so far, im
trying to pass the value entered into a radio button:

<head>
<script language="JavaScript" type="text/JavaScript">
var win= null;
function NewWindow(mypage,myname,w,h,scroll)
{
var winl = (screen.width-w)/2;
var wint = (screen.height-h)/2;
var settings ='height='+h+','
settings +='width='+w+','
settings +='top='+wint+','
settings +='left='+winl+','
settings +='scrollbars='+scroll+','
settings +='resizable=yes'
win=window.open(mypage,myname,settings);
if(parseInt(navigator.appVersion) >= 4){win.window.focus();}
}
<!--
function MM_reloadPage(init) { //reloads the window if Nav4 resized
if (init==true) with (navigator) {if
((appName=="Netscape")&&(parseInt(appVersion)==4)) {
document.MM_pgW=innerWidth; document.MM_pgH=innerHeight;
onresize=MM_reloadPage; }}
else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH)
location.reload();
}
MM_reloadPage(true);
//-->
</script>
</head>

<body>
<form name="answer" action="result.php" method="post">
<input type="radio" name="group1" value="Milk"> Milk<br>
<input type="radio" name="group1" value="Butter"> Butter<br>
<input type="radio" name="group1" value="Cheese"> Cheese<br>
<input type="submit" name="submit" value="submit" src="result.php"
onClick="NewWindow(this.src,'name',âÆ',âÆ','yes');retur n false" >
</form>
</body>

Post Variables After Java Sort Are Lost
I have an HTML table that is being constructed from a MySQL table and
displays a form that includes a check box on 1 of the fields on the form for
each record. I have included in this PHP program a javascript routine called
sorttable.js which is something I found on the internet for sorting tables
and works quite well. The HTML table includes a check box on each record so
the user can select certain records for passing to the next process. This
works fine unless I sort the table on some column and then the POST
variables are lost. When I run the following code there are no POST
variables that will echo except the submit button.

foreach ($_POST as $varName =$value){
echo ($varName . " = " . $value);
}

However, if I don't sort the table the POST variables will be echoed for
every record in the table. I'm not sure why this is happening or how to go
about solving it. When I check certain records on the form and then sort the
table the checks themself don't disappear only the POST variables do. This
prevents me from looping thru the ARRAY to determine the value of the POST
check box for each record to see if it was checked. If I run the above code
but don't sort it I will have several hundred POST variables (several for
each record).

Could someone give me an idea on how to solve this or offer some sort of
work-around?

Forward To Page Alongwith Variables In POST
How to forward a page to another page alongwith the parameters passed into it

I mean I have page a.php
which is called with some parameters in $_POST and I require to pass these to another page with same variables in $_POST

Passing Variables In Frame Page By Post Method
Is it possible to send  variables by post method through a submit button to a frames page, and have all 3 pages in the frame pick up the variable using the $_request[var] ?In other words, I click on a submit button. in form action method call index.php the index page has a top, main, and a left frame.how do i get each one of those to receive the variable, when i can only sendit to one page? or is it possible to send it to more than one page, but only action to one page?

Problems With Error Checking / Control Of POST Variables
I have a small form that on button press submits to a PHP file for further
processing into a database. I have to change the script as it allows
blank / nothing to be submitted to the database. The intention is that if
any of the two form fields are blank (empty) then the page is resent
stating that they have to fill in all the fields to post (to a database).

If I deliberately leave the fields blank and submit the form, querying the
database shows that both fields are zero / null - so nothing was entered in
to the database.

However, if I use an echo command to see what is going on (before the data
is entered into a database) I get the $TheName field with a "1" and the
$TheComment field with an unknown entry (it doesn't echo anything to the
screen - but it's not empty).

The code I've used to test this is:

$TheName = $_POST[gbName];
$TheComment = $_POST[gbComment];

if (($TheName = NULL) or ($TheComment = NULL))
{
echo 'Quick error check running:<BR>'
echo "Name: $TheName<BR>";
echo "Comment: $TheComment";
exit;
}

This does NOT execute as these fields are not empty. It only runs if I
change to:

if (($TheName = !NULL) or ($TheComment = !NULL))

Which is pointless as it will always execute with genuine entries.

Using the amended code below:

if (($TheName = !NULL) or ($TheComment = !NULL))
{
echo 'Quick error check running:<BR>'
}

echo "Name: $TheName<BR>";
echo "Comment: $TheComment";

I get the result that both the echoed lines are displayed as blank (no
"1").

PHP:Unable To Post Variables From Html Form To Mysql Database
Plz dont treat this as another newbie query , i did my homework but
still getting nowhere :( :( :(

Trying to learn PHP on Fedora core 1 (PHP 4.3,MySQL,HTTPD).Unable to
post data from html form to php file(connecting to mysql database and
inserting into a table) .
This seemingly simple problem is making me go mad !!! I googled
extensively and already tried the following

I enabled " register_globals = On " .... in /etc/php.ini and
also took used _$POST syntax.

wot could be the problem .... is it the case that /etc/php.ini file is
not being read .... how do i know whether this is the default location
for php.ini?
Where can i find the PHPRC environment variable (the variable
responsible for the php.ini default location)

Is the problem something else .....?

Following is the code ...

form.html
---------
<HTML>
<HEAD>
<TITLE> email entry form </TITLE>
</HEAD>
<BODY>

<P>plz fil the form </P>

<FORM METHOD="POST" ACTON="form-handler.php">

NAME: <BR>
<INPUT TYPE=TEXT NAME="givename" SIZE=25> <BR>
AGE: <br>
<INPUT TYPE=TEXT NAME="givenaddress" SIZE=25> <BR>

<INPUT TYPE=SUBMIT>
</FORM>
</BODY>
</HTML>

form-handler.php
-----------------
<HTML>
<HEAD>
<TITLE> EMAIL FORM HANDLER </TITLE>
</HEAD>

<BODY>

<?
mysql_connect("localhost","root") or die("Failure on db connection");

mysql_select_db("mydb");

Where Do I Place This?
i have a script which allows users to edit their information. I can make the form edit and update the data, but when the user returns to the form to update the information, it retunrs to the first value. I am not sure where to place this tag <?=$a13?> PHP code:

Where Does Php Place Cookies?
This is baffling me. I am starting a session and I know it is setting a
cookie on my computer - I called getallheaders() and see that it is
setting the cookie, and it is also accessible in $_COOKIE. I cleared
all cookies in my Cookies folder before starting the session, and
everytime I run the script it does not create a cookie in the folder.
For testing I even set the browser to accept all cookies to make sure.

session.use_cookies is on in php.ini, session.use_only_cookies is off,
and session.use_trans_sid is off. The session data file is definitely
being created, but I cannot find the corresponding cookie no matter what
I try.

Best Place To Transform XSL
Hi, I have a question that a friend was asking me a few minutes ago.

Is it better to transform XSL on the client side, or let the server
handle it? Or both, ensuring that everyone can view the site correctly.

Backslashes All Other The Place
this is the text i type into the database:

this is some 'example text' and is a "test"

and this is what is displayed when its in the database:

this is some 'example text' and is a "test"

is there anyway to stop that? or hide the backslahes?


Copyright © 2005-08 www.BigResource.com, All rights reserved