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 4 of 4
  1. #1
    Senior Coder rafiki's Avatar
    Join Date
    Aug 2006
    Location
    Floating around somewhere...
    Posts
    2,042
    Thanks
    19
    Thanked 42 Times in 42 Posts

    $_post not working



    heres my form.php code
    Code:
    <BR><BR><BR><BR><form action="welcome.php" method="post" />
    First Name: <input type="text" name="firstname" /><br />
    Surname: <input type="text" name="surname" /><br />
    DOB: <input type="text" name="DOB" /><br />
    Year In School:
    <select name="school_year" />
    <option value="7" />7
    <option value="8" />8
    <option value="9" />9
    <option value="10" />10
    <option value="11" />11
    </select />,<br />
    Number of Siblings: <input type="text" name="siblings" /><br />
    Bedtime: <select name="bedtime" /><br />
    <option value="7" />7
    <option value="8" />8
    <option value="9" />9
    <option value="10" />10
    <option value="11" />11
    <option value="other" />other
    </select /><br />
    Time Doing Home Work: <input type="text" name="homework" /><br />
    Time watching T.V: <input type="text" name="tv" /><br />
    Time Playing Computer/console: <input type="text" name="computer" /><br />
    Time Spent With Family: <input type="text" name="family" /><br />
    Time Spent With Friends: <input type="text" name="friends" /><br />
    <input type="submit" />
    </form />
    and here is my welcome.php

    PHP Code:
    <?php 
    echo "Welcome $_POST['firstname'] thanks for filling in out form";
    ?>

  • #2
    Regular Coder googleit's Avatar
    Join Date
    Jul 2006
    Location
    birmingham, uk
    Posts
    189
    Thanks
    0
    Thanked 0 Times in 0 Posts
    use
    PHP Code:
    $_Get['firstname'

  • #3
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    You're closing your form before it has a chance to live.
    PHP Code:
    <form action="welcome.php" method="post" /> 
    See anything funky about that?

    I'll give you a hint.. "<form />" is shorthand for "<form></form>".

    You've got similar issues on your <select> tags. And </select /> is... interesting philosophically (how does one close a closer tag?), but wrong

  • #4
    Senior Coder
    Join Date
    Aug 2003
    Location
    One step ahead of you.
    Posts
    2,815
    Thanks
    0
    Thanked 3 Times in 3 Posts
    You can't do it like this:
    PHP Code:
    <?php  
    echo "Welcome $_POST['firstname'] thanks for filling in out form"
    ?>
    You either have to use complex syntax (it's not really complex, it's just a name)
    PHP Code:
    <?php  
    echo "Welcome {$_POST['firstname']} thanks for filling in out form"
    ?>
    or concatenate
    PHP Code:
    <?php  
    echo 'Welcome ' $_POST['firstname'] . ' thanks for filling in out form'
    ?>
    I'm not sure if this was any help, but I hope it didn't make you stupider.

    Experience is something you get just after you really need it.
    PHP Installation Guide Feedback welcome.


  •  

    Posting Permissions

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