...

View Full Version : Unable to get field value of included form



raymanw
10-27-2006, 10:26 AM
Sequence of events:
1. transaction.php calls include("signup.php");
2. signup form call a standard php function to receive user entries
3. php function calls js function to validate the values (returns true)
4. php function returns processing to signup.php using:
<input type=button value="<?php echo $button_caption; ?>" onclick="if (verifyChange() == true) {location.href='<?php echo $_SERVER['PHP_SELF']; ?>?homeinclude=signup&pageaction=signup'}">

After controll has returned to signup.php, the values received by the php function (step 2) are lost.

What am I missing?
Or It just does work that way?

Thanks.

mlseim
10-27-2006, 01:34 PM
I'm just guessing on this without trying it out ....

In this step:

4. php function returns processing to signup.php using:
<input type=button value="<?php echo $button_caption; ?>" onclick="if (verifyChange() == true) {location.href='<?php echo $_SERVER['PHP_SELF']; ?>?homeinclude=signup&pageaction=signup'}">

The part in blue... I don't think you can send the variables with location.href.

But you don't have to ...
If you define the variables within your .php file and you go to another
.php file, the variables are global, so they will be seen by the other script.

Example:
<?php
$homeinclude="signup";
$pageaction="signup";
?>
<input type=button value="<?php echo $button_caption; ?>" onclick="if (verifyChange() == true) {location.href='<?php echo $_SERVER['PHP_SELF']; ?>'}

raymanw
10-27-2006, 02:50 PM
One of the values accepted from the user, in 2., is username (without 1st declaring the variable) using the format:
<input type=text name=username value="<?php echo $username ?>">

When the control returns back to signup.php, $username doesn't have any value.

Even when I declare "global $username" in signup.php, the value would not be carried down.

Do I need to explicitly declare any variable to contain the value like so:
$value=$username in the php function in 2.?

mlseim
10-27-2006, 03:17 PM
<input type=text name=username value="<?php echo $username ?>">

This can also be this syntax (a little shorter):

<input type=text name=username value="<?=$username ?>">

In the script that is looking for "username", you would have:

$username=$_REQUEST['username'];

To retrieve that from a POST,GET, or URL variable.

Not sure if you're already doing that or not.

raymanw
11-02-2006, 11:56 AM
I got it working but I am curious how it works.

I got it working by removing this line from 1.:
<input type=hidden name=pageaction value="$pageaction">

Then the pageaction's value can be read in 2.

raymanw
11-02-2006, 03:29 PM
I forgot the actual change which allowed all the variables to propogate properly.
After I corrected my typo on the form action, all variables worked ok except for the pageaction variable.
It was only okay after I remove the type=hidden line.

Can someone please explain it to me why it is so.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum