Yes, I'm another one of those guys who has had an error and are as well a complete noob to this to figure it out so... heres my code, I havn't neccesarily finished ... so you will see that i don't have the format so it saves after hitting Register... My appoligies for not inserting a text box as I don't know how but im sure it would be easier anyway to c paste it into Notepad ++ (my using) any help would be appreciated thanks in advance ) <?php include "functions.php"; $submit = ($_POST['submit']); $curnum = 0; $username = ($_POST['username']); $password = ($_POST['password']); $passwordc = ($_POST['passwordconf']); $secretq = ($_POST['secretq']); $secreta = ($_POST['secreta']); $country = ($_POST['country']); $province = ($_POST['province']); $city = ($_POST['city']); $street = ($_POST['streetaddress1']); $postal = ($_POST['postalcode']); $phone = ($_POST['phone11']); $phone = ($_POST['phone12']); $phone = ($_POST['phone13']); $firstname = ($_POST['firstname']); $lastname = ($_POST['lastname']); $email = ($_POST['email']); $birth =($_POST['birthmonth']); $birth =($_POST['birthday']); $birth =($_POST['birthyear']); ?> <html> <head> <title> Hello </title> <link rel="stylesheet" href="style.css" type="text/css" /> </head> <body> <div class="navbar"> <a href="help.htm" class="button"> Help</a> <a href="csupport.htm" class="button"> Customer Support</a> <a href="signin,htm" class="button"> Sign In</a> <a href="home.htm" class="button">Home</a> <a href="signup.htm" class="button">Sign Up!</a> </div> <form method="POST" action="index.php"> <div class="suftitle"> <h2 class="suftop"> <span class="titlefont">Sign Up Form</span> <span class="default">-Be sure to fill in every field with a *</span> </h2> </div> <div class="suftitle1"> <h4 class="suftop"> <span class="titlefont">ID and Password</span> </h4> </div> <div class="suout"> <table class="sutable"> <tr><td> <label class="surow" for="username">User ID:</label> </td><td> <input size="25" maxlength="16" type="text" name="username"> </td></tr> <tr><td class="error" colspan="2" align="center">  <?php if($submit) { if(!$username) { $curnum ++; echo "Please enter your desired username."; } if($username) { if(strlen($username) <5) { $curnum ++; echo "Your username needs to be at least 5 characters."; }}} ?> </td></tr> <tr><td> <label class="surow" for='password'>Password:</label> </td><td> <input type="password" class="pw" size="25" type="text" name='password' maxlength="16"/> </td></tr> <tr><td class="error" colspan="2" align="center">  <?php if($submit) { if(!$password) { $curnum ++; echo "Please enter your password."; } if($password) { if(strlen($password) <8) { $curnum ++; echo "Your password needs to be at least 8 characters."; }}} ?> </td></tr> <tr><td> <label class="surow" for="passwordconf">Re-enter Password:</label> </td><td> <input type="password" class="pw" size="25" type="text" name="passwordconf" maxlength="16"> </td></tr> <tr><td class="error" colspan="2" align="center">  <?php if($submit) { if(!$passwordc) { $curnum ++; echo "Please re-enter your password."; } if($passwordc != $password){ $curnum ++; echo "Passwords do not match."; } } ?> </td></tr> <tr><td> <label class="surow" for="secretq">Choose A Secret Question:</label> </td><td> <select name="secretq"> <option name="value" value="0" selected>(Secret Question)</option> <option name="value" value="1">First car?</option> <option name="value" value="2">First school?</option> <option name="value" value="3">Favorite color?</option> <option name="value" value="4">Favorite book?</option> <option name="value" value="5">First best friend?</option> <option name="value" value="6">Mother's middle name?</option> <option name="value" value="7">First pet's name?</option> <option name="value" value="8">A friends last name?</option> <option name="value" value="9">Favorite show?</option> </td></tr> <tr><td class="error" colspan="2" align="center">  <?php if($submit) { if ($secretq ==0){ $curnum ++; echo "Please choose a secret question."; }} ?> </td></tr> <tr><td><label class="surow" for="secreta">Secret Question Answer:</label></td> <td><input type="text" name="secreta" size="25" maxlength="30"/> <tr><td class="error" colspan="2" align="center">  <?php if($submit) { if(!$secreta) { $curnum ++; echo "Please enter your secret answer."; }} ?> </td></tr> </table> </div> <div class="suftitle2"> <h4 class="suftop"><span class="titlefont">Location Information</span> </h4> </div> <div class="suout1"> <table class="sutable1"> <tr><td> <label class="surow" for="country">Country:</label> </td><td> <select name="country"> <option name="value" value="1" selected>Canada</option> <option name="value" value="2">United States</option> </select> </td></tr> <tr><td class="error" colspan="2" align="center">  <?php if($submit) { if(($country) ==2) { $curnum ++; echo "Go to US site."; }} ?> </td></tr> <tr><td> <label class="surow" for="province">Province:</label> </td><td> <select name="province"> <option name="value" value="1" selected>(Province)</option> <option name="value" value="al">Alberta</option> <option name="value" value="bc">British Columbia</option> <option name="value" value="mb">Manitoba</option> <option name="value" value="nb">New Brunswick</option> <option name="value" value="nl">Newfoundland and Labrador</option> <option name="value" value="nt">North West Territories</option> <option name="value" value="ns">Nova Scotia</option> <option name="value" value="nv">Nunavut</option> <option name="value" value="on">Ontario</option> <option name="value" value="pe">Prince Edward Island</option> <option name="value" value="qb">Québec</option> <option name="value" value="sk">Saskatchewan</option> <option name="value" value="yk">Yukon</option><br/> </select> </td></tr> <tr><td class="error" colspan="2" align="center">  <?php if($submit) { if(($province) ==1) { $curnum ++; echo "Please select the province you live in."; }} ?> </td></tr> <tr><td> <label class="surow" for="city">City:</label> </td><td> <input maxlength="50" size="25" type="text" name="city"> </td></tr> <tr><td class="error" colspan="2" align="center">  <?php if($submit) { if(!$city ) { $curnum ++; echo "Please enter the city you live in."; }} ?> </td></tr> <tr><td> <label maxlength="50" size="25" class="surow" for"streetaddress1">Street Address 1:</label> </td><td> <input maxlength="50" size="25" type="text" name="streetaddress1"> </td></tr> <tr><td class="error" colspan="2" align="center">  <?php if($submit) { if(!$street) { $curnum ++; echo "Please enter the name of the street you live on."; }} ?> </td></tr> <tr><td> <label class="surow" for"streetaddress2">Street Address 2:</label> </td><td> <input maxlength="50" size="25" type="text" name="streetaddress2"> </td></tr> <tr><td class="error" colspan="2" align="center">  </td></tr> <tr><td> <label class="surow" for"postalcode">Postal Code: </td><td> <input maxlength="7" size="25" type="text" name="postalcode"> </td></tr> <tr><td class="error" colspan="2" align="center">  <?php if($submit) { if(!$postal) { $curnum ++; echo "Please enter your postal code."; }} ?> </td></tr> <tr><td> <label class="surow" for"phone1"> Primary Phone Number: </td><td> <input maxlength="4" size="3" type="text" name="phone11">-<input maxlength="3" size="3" type="text" name="phone12">-<input maxlength="4" size="4" type="text" name="phone13">     ext:<input maxlength="5" size="5" type="text" name="phoneext1"> </td></tr> <tr><td class="error" colspan="2" align="center">   <?php if($submit) { if(!$phone ) { $curnum ++; echo "Please enter your phone number"; }} ?> </td></tr> </td></tr> <tr><td> <label class="surow" for"phone2">Secondary Phone Number: </td><td> <input maxlength="4" size="3" type="text" name="phone21">-<input maxlength="3" size="3" type="text" name="phone22">-<input maxlength="4" size="4" type="text" name="phone23">     ext:<input maxlength="5" size="5" type="text" name="phoneext2"> </td></tr> <tr><td class="error" colspan="2" align="center">   </td></tr> </table> </div> <div class="suftitle3"> <h4 class="suftop"> <span class="titlefont">Personal Information</span> </h4> </div> <div class="suout2"> <table class="sutable2"> <tr><td> <label class="surow" for"firstname">First Name:</label> </td><td> <input maxlength="40" size="25" type="text" name="firstname"> </td></tr> <tr><td class="error" colspan="2" align="center">  <?php if($submit) { if(!$firstname) { $curnum ++; echo "Please enter your first name."; }} ?> </td></tr> <tr><td> <label class="surow" for"lastname">Last Name:</label> </td><td> <input maxlength="50" size="25" type="text" name="lastname"> </td></tr> <tr><td class="error" colspan="2" align="center">  <?php if($submit) { if(!$lastname ) { $curnum ++; echo "Please enter your last name"; }} ?> </td></tr> <tr><td> <label class="surow" for"email">E-Mail Address:</label> </td><td> <input maxlength="40" size="25" type="text" name="email"> </td></tr> <tr><td class="error" colspan="2" align="center">  <?php if($submit) { if(!$email) { $curnum ++; echo "Please enter your e-mail address"; }} ?> </td></tr> <tr><td> <label class="surow" for"birthdate">Birth Date:</label> </td><td> <select name="birthmonth"> <option name="value" value="1" selected>(Month)</option> <option name="value" value="jan">January</option> <option name="value" value="feb">February</option> <option name="value" value="mar">March</option> <option name="value" value="apr">April</option> <option name="value" value="may">May</option> <option name="value" value="jun">June</option> <option name="value" value="jul">July</option> <option name="value" value="aug">August</option> <option name="value" value="sep">September</option> <option name="value" value="oct">October</option> <option name="value" value="nov">November</option> <option name="value" value="dec">December</option> </select> <select name="birthday"> <option name="value" value="1" selected>(Day)</option> <?php $num = 0; while($num <=30) { $num ++; echo "<option value=".$num."> ".$num." </option>"; } ?> </select> <select name="birthyear"> <option name="value" value="1" selected>(Year)</option> <?php $num = 2011; while($num >=1901) { $num --; echo "<option value=".$num."> ".$num." </option>"; } ?> </select></td></tr> <tr><td class="error" colspan="2" align="center">  <?php if($submit) { if(($birth) ==1){ $curnum ++; echo "Please select your date of birth."; }} ?> </td></tr> <?php if($curnum == 0) { mysql_query("INSERT INTO user VALUES (`id`,'".$username."'.'".$password."')") or die(mysql_error()); } ?> </table> </div> <center> <input type="submit" name="submit" value="Register"> </center> </form> </body> </html>
I haven't checked all of the code, but there are a few issues with your SQL statement that will hopefully sort out your problem. mysql_query("INSERT INTO user VALUES (`id`,'".$username."'.'".$password."')") or die(mysql_error()); Code (markup): - `id` is a column name, not a value, so you can't insert it. Either configure the table so the column auto incs (so you don't need to give a value in your insert statement) or specify a value. (I'm assuming you're using this as a key.) - You have a full stop between the username and password, not a comma. You should also sanitise the inputs to make sure no-one uses a password like fred"); DROP TABLE user;. Xkcd has more http://xkcd.com/327/ Hope that helps.
In my database i had a field for `id` and it was on auto increment and well i had a whole load of other errors all of which are from the non existance of all the names like $username for the reason that it read the code of the $username = $_POST['username'] before 'username even existed <<<GUESSING>>> guessing alsoooooo.... that the fact that my if statement on the POST which was also getting an error reading unknown index ... submit... and my submit button was way after all fo this code at the end of the text... does it actually read the code in 100% order.. if so then like facebook or ebay, how does it end up giving the errors under the specific field as what im doing.. While after messing with that stuff i gave in and just started again from scratch but now i have a new problem I dont have any more errors what so ever now well all i have is the username password password conf and security question fields but now im getting a blank screen if i set the post submit to.... if(isset($_POST['submit'])) { and if i put if(isset($_POST['submit'])) { then it works only now any of the fields wont remember what was entered after submit ( well at first this was the case but now..) i havnt changed anything and now it just goes to another white screen after pushing submit.... Im clueless at this point and need help Heres the code <?php include "functions.php"; if(!isset($_POST['submit'])) { $curnum = 0; ?> <html> <head> <title> Registration </title> </head> <body> <div class="navbar"> <a href="help.htm" class="button"> Help</a> <a href="csupport.htm" class="button"> Customer Support</a> <a href="signin,htm" class="button"> Sign In</a> <a href="home.htm" class="button">Home</a> <a href="signup.htm" class="button">Sign Up!</a> </div> <div class="suftitle"> <h2 class="suftop"> <span class="titlefont"> Sign Up Form </span> <span class="default"> -Be sure to fill in every field with a * </span> </h2> </div> <div class="suftitle1"> <h4 class="suftop"> <span class="titlefont"> ID and Password </span> </h4> </div> <form method="POST" action="index.php"> <table border="0" style="text-align: left; border: 1px solid black; padding: 2px; font-family: Tahoma; font-size: 12px;"> <tr> <td> Username: </td> <td> <input type="text" name="username" value="<?php echo($_POST['username']);?>"> </td> </tr> <tr> <td>   <?php if(isset($_POST['submit'])) { $username = $_POST['username']; if(!$username) { $curnum ++; echo "Please enter your desired username."; } if($username) { if(strlen($username) <5) { $curnum ++; echo "Your username needs to be 6 or more characters."; } } } ?> </td> </tr> <tr> <td> Password: </td> <td> <input type="password" name="password" value="<?php echo $_POST['password'];?>"> </td> </tr> <tr> <td>   <?php if(isset($_POST['submit'])) { $password = $_POST['password']; if(!$password) { $curnum ++; echo "Please enter your password."; } if($password) { if(strlen($password) <8) { $curnum ++; echo "Your password needs to be 8 or more characters."; } } } ?> </td> </tr> <tr> <td> Re-type Password: </td> <td> <input type="password" name="passwordconf"> </td> </tr> <tr> <td>   <?php if(isset($_POST['submit'])) { $passwordconf = $_POST['passwordconf']; if(!$passwordconf) { $curnum ++; echo "Please re-enter your password."; } if($passwordconf) { if($passwordconf != $password) { $curnum ++; echo "Your passwords do not match."; } } } ?> </td> </tr> <tr> <td> Secret Question: </td> <td> <select name="secretq"> <option name="value" value="1" selected>(Secret Question)</option> <option name="value" value="2">Favorite Color?</option> <option name="value" value="3">Favorite Book?</option> <option name="value" value="4">Favorite Reality Show?</option> <option name="value" value="5"> </option> <option name="value" value="6"> </option> <option name="value" value="7"> </option> <option name="value" value="8"> </option> <option name="value" value="9"> </option> <option name="value" value="10"> </option> <option name="value" value="11"> </option> </select> </td> </tr> <tr> <td colspan="2" align="center"> <input type="submit" name="submit" value="Register"> </td> </tr> </table> </form> </body> </html> <?php } ?>
o and also... the error said it occured on line 1 ( This is the begining Syntax SQL error ) and it said that i was soposed to you ) for . or something... i forget becuase i restarted... hopefully i dont get that error again... thanks for the help though
<?php include "functions.php"; if (isset($_POST['submit'])) { $curnum = 0; ?> <html> <head> <title> Registration </title> </head> <body> <div class="navbar"> <a href="help.htm" class="button"> Help</a> <a href="csupport.htm" class="button"> Customer Support</a> <a href="signin,htm" class="button"> Sign In</a> <a href="home.htm" class="button">Home</a> <a href="signup.htm" class="button">Sign Up!</a> </div> <div class="suftitle"> <h2 class="suftop"> <span class="titlefont"> Sign Up Form </span> <span class="default"> -Be sure to fill in every field with a * </span> </h2> </div> <div class="suftitle1"> <h4 class="suftop"> <span class="titlefont"> ID and Password </span> </h4> </div> <form method="POST" action="index.php"> <table border="0" style="text-align: left; border: 1px solid black; padding: 2px; font-family: Tahoma; font-size: 12px;"> <tr> <td> <label class="surow" for="username">User ID:</label> </td> <td> <input type="text" name="username" value="<?php echo($_POST['username']);?>"> </td> </tr> <tr> <td>   <?php if(isset($_POST['submit'])) { $username = $_POST['username']; if(!$username) { $curnum ++; echo "Please enter your desired username."; } if($username) { if(strlen($username) <5) { $curnum ++; echo "Your username needs to be 6 or more characters."; } } $sql = "SELECT * FROM userlist WHERE username='".$username."'"; $res = mysql_query($sql) or die(mysql_error()); if(mysql_num_rows($res) > 0) { $curnum ++; Echo "Sorry, the username '<b>".$username."</b>' already exist."; } } ?> </td> </tr> <tr> <td> <label class="surow" for="password">Password:</label> </td> <td> <input type="password" name="password" value="<?php echo ($_POST['password']);?>"> </td> </tr> <tr> <td>   <?php if(isset($_POST['submit'])) { $password = $_POST['password']; if(!$password) { $curnum ++; echo "Please enter your password."; } if($password) { if(strlen($password) <8) { $curnum ++; echo "Your password needs to be 8 or more characters."; } } } ?> </td> </tr> <tr> <td> <label class="surow" for="passwordconf">Re-Type Password:</label> </td> <td> <input type="password" name="passwordconf"> </td> </tr> <tr> <td>   <?php if(isset($_POST['submit'])) { $passwordconf = $_POST['passwordconf']; if(!$passwordconf) { $curnum ++; echo "Please re-enter your password."; } if($passwordconf) { if($passwordconf != $password) { $curnum ++; echo "Your passwords do not match."; } } } ?> </td> </tr> <tr> <td> <label class="surow" for="secretq">Secret Question:</label> </td> <td> <select name="secretq"> <option name="value" value="1" selected>(Secret Question)</option> <option name="value" value="2">Favorite Color?</option> <option name="value" value="3">Favorite Book?</option> <option name="value" value="4">Favorite Reality Show?</option> <option name="value" value="5"> </option> <option name="value" value="6"> </option> <option name="value" value="7"> </option> <option name="value" value="8"> </option> <option name="value" value="9"> </option> <option name="value" value="10"> </option> <option name="value" value="11"> </option> </select> </td> </tr> <tr> <td colspan="2" align="center"> <input type="submit" name="submit" value="Register"> </td> </tr> <tr> <td> <label class="surow" for="secreta">Secret Question Answer:</label> </td> <td> <input type="text" name="secreta"> </td> </tr> <tr> <td>   <?php if(isset($_POST['submit'])) { $secreta = $_POST['secreta']; if(!$secreta) { $curnum ++; echo "Please enter your secret answer."; } } ?> </td> </tr> </table> </form> </body> </html> <?php if($curnum == 0) { mysql_query("INSERT INTO userlist VALUES(`id`,'".$username."','".$password."')") or die(mysql_error()); } } ?>