SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Addict Normal75's Avatar
    Join Date
    Oct 2001
    Location
    Vancouver, Canada
    Posts
    245
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    form and variables question

    hello, this might be stupid/easy question but I don't know how...

    I have a form code that looks like this

    member.php
    PHP Code:
    $result mysql_query("SELECT * FROM member WHERE id='$userid';",$link);
        while (
    $a_row =mysql_fetch_array ($result) )
        {
            
    $a_row['name'] = stripslashes($a_row['name']);
            
    $a_row['email'] = stripslashes($a_row['email']);
            
            include 
    "./forms/form.php";
         } 
    form.php
    PHP Code:
    Name : <input type="text"name="name" value="<?=$a_row['name']?>
    Email : <input type="text"name="email" value="<?=$a_row['email']?>
    Now when I go to member.php and for some reason, the variables are not being passed to form.php, so the form is not populated with results.

    Any clue how i can fix this?

    thanks
    ~It will come to me one day~

  2. #2
    SitePoint Wizard silver trophy
    Join Date
    Mar 2006
    Posts
    6,132
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    the output of member.php should be the contents of form.php, with the values filled in properly.

    are you saying your problem is when you goto form.php via its direct url, your not seeing the variables? your not supposed to. you would need to use sessions to carry those values over to another page request.

  3. #3
    SitePoint Addict Normal75's Avatar
    Join Date
    Oct 2001
    Location
    Vancouver, Canada
    Posts
    245
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    My problem is when i go to member.php with form.php printed on member.php, there is no values in the fields.
    ~It will come to me one day~

  4. #4
    SitePoint Addict Normal75's Avatar
    Join Date
    Oct 2001
    Location
    Vancouver, Canada
    Posts
    245
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    so you are saying, on form.php, i should have something like this...?

    PHP Code:
    $_SESSION['name'] = $a_row['name']
    Name : <input type="text"name="name" value="<?=$a_row['name']?>
    ~It will come to me one day~

  5. #5
    SitePoint Wizard silver trophy
    Join Date
    Mar 2006
    Posts
    6,132
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you dont need to use sessions if form.php is always being included.

    is this code, inside of a function in form.php?
    PHP Code:
     Name : <input type="text"name="name" value="<?=$a_row['name']?>
    Email : <input type="text"name="email" value="<?=$a_row['email']?>

    if not, it should work fine. (btw, your html is invalid, view the page source)


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
  •