ffxpwns Posted April 3, 2012 Share Posted April 3, 2012 Sorry for the caps, but this is relatively time sensitive. I am trying to make a register form, but when I click the submit button, nothing happens. It doesn't add to the table, it doesn't bring me home, doesn't even display the errors if the PWD's don't match or the fields are blank. Here's my code, thanks guys ! PS: The DB name is phptest, and the table is called users. <?php error_reporting(0); require_once('connector.php'); $errors = array(); if ($_POST["submit"]) { if (empty($_POST['username'])) { array_push($errors, 'You did not submit a username.');} if (empty($_POST['email'])) { array_push($errors, 'You did not submit a email.');} if (empty($_POST['password1'])) { array_push($errors, 'You did not submit a password.');} $old_usn = mysql_query("SELECT id FROM users WHERE name = '".$_POST['username']."' LIMIT 1") or die (mysql_error()); if (mysql_num_rows($old_usn) > 0) { array_push($errors, 'This username is already registered.');} $old_email = mysql_query("SELECT id FROM users WHERE email = '".$_POST['email']."' LIMIT 1") or die (mysql_error()); if (mysql_num_rows($old_email) > 0) { array_push($errors, 'This email is already registered.');} if ($_POST['password1'] != $_POST['password2']) { array_push($errors,'You entered two different passwords');} if(sizeof($errors) == 0) { $username = $_POST['username']; $email = $_POST['email']; $password = sha1 ($_POST['password1']); mysql_query("INSERT INTO users (name, hashed_psw, email, joined) VALUES ('{$username}', '{$password1}', '{$email}', NOW());") or die (mysql_error()); header ('Location: index.php?msg=1'); } } ?> <html> <head> <title>register</title> </head> <body> <?php foreach($errors as $e) { echo $e; echo "<br/>\n"; } ?> <form action="register.php" method="post"> <h4> Username: <br /> <input name="username" type="text" value="" size="10" maxlength="16" /> <br /> <br /> Email: <br /> <input name="email" type="text" value="" size="10" maxlength="100" /> <br /> <br /> Password: <br /> <input name="password1" type="password" value="" size="10" maxlength="16" /> <br /> <br /> Confirm Password: <br /> <input name="password2" type="password" value="" size="10" maxlength="16" /> <br /> <br /> <input name="submit" type="button" value="Register" /> </h4> </form> </body> </html> And heres the connector.php script: <?php mysql_connect("localhost", "***", "***") or die (mysql_error()); mysql_select_db("phptest") or die (mysql_error()); ?> (yes, the asterisks have the name and pw, just put them just in caseys! Quote Link to comment Share on other sites More sharing options...
dragon_sa Posted April 3, 2012 Share Posted April 3, 2012 try changing this <input name="submit" type="button" value="Register" /> to this <input name="submit" type="submit" value="Register" /> It needs to be a submit type to submit your form, I am not sure how this issue relates to phpMyAdmin though? Quote Link to comment Share on other sites More sharing options...
ffxpwns Posted April 3, 2012 Author Share Posted April 3, 2012 try changing this <input name="submit" type="button" value="Register" /> to this <input name="submit" type="submit" value="Register" /> It needs to be a submit type to submit your form, I am not sure how this issue relates to phpMyAdmin though? BY SCOTT WE'VE DONE IT! Thanks a bunch! And, it doesn't relate to PHPmyadmin. It was on my mind at the time, so I typed it and never proof read to check it. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.