SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    Oct 2000
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Variables not getting set

    Ok . . . so I have a form that has some default values (from a database) put in the fields. I submit the form and I can see in the url that the new values are being passed to the script, however, when I print out the variable names, they have the old values in them.

    For example, the name field has the value "Robert" in it, i change that value to "Help" and submit the form. I can see in the url that the new value is being sent (ie. location=http://blah.com/script.php?name=Help) however when I print out $name in script.php it has the value "Robert" still. I am using sessions, but I have printed out all the session variables, and $name is not one of them.

    Has anyone seen something like this before? If you need more specifics, I can post the URL.

    Thanks.

  2. #2
    SitePoint Enthusiast
    Join Date
    Oct 2000
    Posts
    30
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It would be easier to help if you showed us the code

  3. #3
    SitePoint Member
    Join Date
    Oct 2000
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here is the php code to handle the form's output:

    PHP Code:
    <?include("/web/virtual/referrals.atlantech.net/httpdocs/includes/agent_header.php");?>
    <html>
    <!-- Header Table -->
    <table border=0 width='100%' cellspacing=0 cellpadding=0>
        <tr>
            <td align='left' bgcolor='#D9D9D9'><a href='index.php'>Main Menu</a></td>
            <td align='right' bgcolor='#D9D9D9'>Welcome <?=$name?>. Click <a href='logout.php'>here</a> to logout</td>
        </tr>
    </table>
    <?

        $dbcnx 
    dbConnect("referral");
        
    $sql "update agent_emp set " .
            
    "fname = '$fname', " .
            
    "lname = '$lname', " .
            
    "title = '$title', " .
            
    "email = '$email', " .
            
    "phone = '$phone', " .
            
    "fax   = '$fax'  , " .
            
    "mobile= '$mobile', " .
            
    "login = '$login' " .
            
    "where ID = '$eid'";

        
    alert("Here is the sql statement\\n" $sql);

        
    $result mysql_query($sql);
        if (!
    $result) {
            
    error("A database error occurred in processing your ".
            
    "submission.\\nIf this error persists, please ".
            
    "contact [email]jonese@atlantech.net[/email].\\n\\nThe error given was: \\n" mysql_error() . " ");
        }

        if( 
    $login != $oldlogin ){
            
    // login has changed so we need to update the session variable
            
    $uid $login;
        }
        if( 
    $fname != $name ){
            
    // name has changed so we need to update the session variable
            
    $name $fname;
        }

    ?>
        Data successfully updated.<br>
        <a href='editcontact.php?changeindiv=1'>Review contact information</a><br><br>

  4. #4
    SitePoint Member
    Join Date
    Oct 2000
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I've done some more debugging and printed out all the variables that I am expecting to get passed by the form, all session variables, all POST variables and all GET variables. The odd thing is that when I print out the post variables, the value is set properly, however when I print out the variable by its name that it was given in the form, it is not set properly. I'm not sure if that made any sense at all, so here is an example. There is a field in the form like this:
    <input type='text' name='fname' value='Robert'>

    I change the value to Robert1 and submit the form. When I print out $fname, the value Robert is printed, but when I loop through all the post variables, the variable called fname has the value Robert1. So, my question now is, does anyone know why the variable $fname is not getting the value from the form. BTW, $fname is not a session variable, so its not like that value is getting passed from the session.

    Thanks.

  5. #5
    SitePoint Enthusiast
    Join Date
    Oct 2000
    Posts
    30
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm having a hard time making sense of exactly how you have things set up. But for right now just try leaving the value attribute empty. From what I've been able to make out of your problem that seems like its where you went wrong.


Bookmarks

Posting Permissions

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