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 Loyal (3000 - 3499 posts)

    Join Date
    Jul 2003
    Posts
    3,399
    Rep Power
    594
    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 Loyal (3000 - 3499 posts)

    Join Date
    Jul 2003
    Posts
    3,399
    Rep Power
    594
    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 Loyal (3000 - 3499 posts)

    Join Date
    Jul 2003
    Posts
    3,399
    Rep Power
    594
    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.

IMN logo majestic logo threadwatch logo seochat tools logo