Thread: Help with form

    #1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Posts
    3
    Rep Power
    0

    Help with form


    How come my php function wont respond when i press submit button in form??


    <?php
    include 'connect.php';
    ?>
    <title>Registration</title>

    <form method='post'>
    <?php
    if(isset($_POST['register_button'])){
    $username = $_POST['username'];
    $first_name = $_POST['first_name'];
    $last_name = $_POST['last_name'];
    $email = $_POST['email'];
    $password = $_POST['password'];
    $confirm_password = $_POST['confirm_password'];

    if(empty($username) or empty($first_name)){
    echo'fields missing!';
    } else if ($password != $confirm_password) {
    echo"confirm password didnt match";
    } else {
    mysql_query("INSERT INTO members VALUES('', '$first_name', '$last_name', '$username', '$email', '$password')");
    echo "Successfully Registered";
    }

    }
    ?>
    Name: <br/>
    <input type='text' name='first_name' />
    <input type='text' name='last_name' />
    <br /><br />
    User Name : <br />
    <input type='text' name='username' />
    <br /><br/>
    email ID : <br/>
    <input type='email' name='email' />
    <br/><br/>
    Password :
    </form><br>
    <input type='password' name='password' />
    <br/><br/>
    Confirm Password:
    <br/>
    <input type='password' name='confirm_password' />
    <br/><br/>
    <input type='submit' value='submit' id='button' name='register_button' />

    </form>

    Reply With Quote Reply With Quote
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2003
    Posts
    3,572
    Rep Power
    595
    1) Please enclose your code in [ PHP ] tags. See the sticky at the top of this forum.
    2) You need to better describe what is (not) happening. Are you getting a blank screen or is the submit button appearing to not do anything? You will need to check the logs to clarify either way.
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Posts
    3
    Rep Power
    0
    Originally Posted by gw1500se
    1) Please enclose your code in [ PHP ] tags. See the sticky at the top of this forum.
    2) You need to better describe what is (not) happening. Are you getting a blank screen or is the submit button appearing to not do anything? You will need to check the logs to clarify either way.

    thanks for the tips i wil next time, but what is not happening is anything when i press the button. i cant connect the submit button to the function at all.
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2003
    Posts
    3,572
    Rep Power
    595
    Do you see anything in the log when you click the submit button? You first need to determine if the page is being executed and just outputting the identical info making it look like it is not executing or if is really is a no-op. I'd suggest you put something like this before the isset check:
    PHP Code:
    echo "<pre>";
    print_r($_POST);
    echo 
    "</pre>"
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Posts
    3
    Rep Power
    0
    Originally Posted by gw1500se
    Do you see anything in the log when you click the submit button? You first need to determine if the page is being executed and just outputting the identical info making it look like it is not executing or if is really is a no-op. I'd suggest you put something like this before the isset check:
    PHP Code:
    echo "<pre>";
    print_r($_POST);
    echo 
    "</pre>"

    Im not sure how to read the log, and when i put
    PHP Code:
    echo "<pre>";
    print_r($_POST);
    echo 
    "</pre>"
    [/QUOTE]
    in it just reads as
    Array
    (
    )

    i guess my question is how do i get that form submit button to trigger my php code, sorry im a noob and thanks for your quick reply i appreciate it
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2003
    Posts
    3,572
    Rep Power
    595
    What that output implies is it is the first time on that page (i.e. $_POST is empty). The PHP code is executed/triggered every time you request that page. The only difference is when you click the submit button the page is executed with all the $_POST values filled in. That is what the debug I gave you was to show.
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  12. #7
  13. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2014
    Posts
    15
    Rep Power
    0
    Please enclose your code in [ PHP ] tags. at start <?php ]and ?>
  14. #8
  15. No Profile Picture
    Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2003
    Posts
    3,572
    Rep Power
    595
    This thread is a bit old, don't you think?
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  16. #9
  17. Sarcky
    Devshed Supreme Being (6500+ posts)

    Join Date
    Oct 2006
    Location
    Pennsylvania, USA
    Posts
    10,908
    Rep Power
    6352
    Oh geeze, I was just about to actually reply to this, I thought it was a read thread. Closing.
    HEY! YOU! Read the New User Guide and Forum Rules

    "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin

    "The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002

    Think we're being rude? Maybe you asked a bad question or you're a Help Vampire. Trying to argue intelligently? Please read this.

IMN logo majestic logo threadwatch logo seochat tools logo