Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New Coder
    Join Date
    Oct 2006
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unable to get field value of included form

    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.

  • #2
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,493
    Thanks
    8
    Thanked 1,089 Times in 1,080 Posts
    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']; ?>'}

  • #3
    New Coder
    Join Date
    Oct 2006
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.?

  • #4
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,493
    Thanks
    8
    Thanked 1,089 Times in 1,080 Posts
    <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.

  • #5
    New Coder
    Join Date
    Oct 2006
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #6
    New Coder
    Join Date
    Oct 2006
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •