timmah1 Posted June 4, 2008 Share Posted June 4, 2008 This form worked fine, but added some fields, now it shows that it processed, but when I check the database, nothing is getting inserted. Can anybody tell me why? <?php session_start(); require("config.php"); //check if the form has been submitted if($_POST['register']) { //check to see if the passwords match if($_POST['password1'] == $_POST['password2']) { //check to see if email has been registered $checksql = "SELECT * FROM users WHERE email = '" . $_POST['email'] . "';"; $checkresult = mysql_query($checksql); $checknumrows = mysql_num_rows($checkresult); //if email is used, show the erro if($checknumrows == 1){ header("Location: " . $config_basedir . "/register.php?error=taken"); } //if it hasn't been used, process the form else { //create a random string for the verification for($i = 0; $i < 16; $i++) { $randomstring .=chr(mt_rand(32,126)); } $verifyurl = "$config_basedir/verify.php"; $verifystring = urlencode($randomstring); $verifyemail = urlencode($_POST['email']); $verifyusername = $_POST['username']; //now, insert everything that the user entered into the database, including the verify string $sql = "INSERT INTO users(email, password, sal, l_name, f_name, dob, profession, addresse1, addresse2, postal, town, country, special, subscribe, reader, verifystring, active) VALUES( '" . $_POST['email'] . "', '" . $_POST['password1'] . "', '" . $_POST['sal'] . "', '" . $_POST['l_name'] . "', '" . $_POST['f_name'] . "', '" . $_POST['dob'] . "', '" . $_POST['profession'] . "', '" . $_POST['addresse1'] . "', '" . $_POST['postal'] . "', '" . $_POST['town'] . "', '" . $_POST['country'] . "', '" . $_POST['special'] . "', '" . $_POST['subscribe'] . "', '" . $_POST['reader'] . "', '" . addslashes($randomstring) . "', 0);"; mysql_query($sql); //now mail the user the informatin to verify their account. $subject = "Contest Verification"; $message = " Hi $validusername, Please click on the following link to verify your new account: $verifyurl?email=$verifyemail&verify=$verifystring =================================== NOTE: If you believe you received this notification in error, please send an email to [email protected] ------------------------- ©2007 YourWebsite.com. All Rights Reserved. This is an automated email and unchecked account, please do not reply this email!"; mail($_POST['email'], $subject, $message, "From: Email Verification<[email protected]\n"); //show that their information was received and that an email was sent to them require("header.php"); echo "A link has been emailed to the address you entered below.<br> Please follow that link in the email to validate your account."; } } //show error if the passwords don't match else { header("Location: " . $config_basedir . "/register.php?error=pass"); } } else { require("header.php"); //this switches and shows the errors if there were any switch($_GET['error']) { case "pass": echo "Passwords do not match"; break; case "taken": echo "Email address already in use"; break; case "no": echo "Incorrect login details"; break; } ?> <h2>Register</h2> To register, please fill in the form below <form action="<? echo $SCRIPT_NAME ?>" method="POST"> <table width="100%" border="0" cellspacing="0" cellpadding="3"> <tr> <td colspan="2" bgcolor="#CCCCCC">Login Details</td> </tr> <tr> <td width="10%">Email Address</td> <td width="90%"><input name="email" type="text" id="email"></td> </tr> <tr> <td>Password</td> <td><input type="password" name="password1" id="password1"></td> </tr> <tr> <td>Password (again)</td> <td><input type="password" name="password2" id="password2"></td> </tr> <tr> <td colspan="2" bgcolor="#CCCCCC">Personal Details</td> </tr> <tr> <td>Salutation</td> <td><select name="sal" id="sal"> <option value="Mr">Mr</option> <option value="Mrs">Mrs</option> <option value="Ms">Ms</option> </select> </td> </tr> <tr> <td>Last Name</td> <td><input type="text" name="l_name" id="l_name"></td> </tr> <tr> <td>First Name</td> <td><input type="text" name="f_name" id="f_name"></td> </tr> <tr> <td>Birthday</td> <td><input type="text" name="dob" id="dob">(ex. 1950/20/01)</td> </tr> <tr> <td>Profession</td> <td><select name="profession" id="profession"> <option value="PDG, DG, chef d'entreprise (+10 sal.)">PDG, DG, chef d'entreprise (+10 sal.)</option> <option value="Artisan, commerçant">Artisan, commerçant</option> <option value="Cadre gestion, finance">Cadre gestion, finance</option> <option value="Cadre commercial, marketing">Cadre commercial, marketing</option> <option value="Cadre RH, administratif">Cadre RH, administratif</option> <option value="Ingénieur, cadre technique">Ingénieur, cadre technique</option> <option value="Agent de maîtrise, contremaître">Agent de maîtrise, contremaître</option> <option value="Technicien, employé">Technicien, employé</option> <option value="Profession libérale">Profession libérale</option> <option value="Professeur, prof. scientifique">Professeur, prof. scientifique</option> <option value="Prof. de l'information, des arts et spectacles">Prof. de l'information, des arts et spectacles</option> <option value="Prof. de la santé, du travail social">Prof. de la santé, du travail social</option> <option value="Agriculteur, pêcheur">Agriculteur, pêcheur</option> <option value="Etudiant">Etudiant</option> <option value="Au foyer, sans emploi">Au foyer, sans emploi</option> <option value="Sans réponse">Sans réponse</option> </select></td> </tr> <tr> <td>Address 1</td> <td><input type="text" name="addresse1" id="addresse1"></td> </tr> <tr> <td>Address 2</td> <td><input type="text" name="addresse2" id="addresse2"></td> </tr> <tr> <td>Postal Code</td> <td><input type="text" name="postal" id="postal"></td> </tr> <tr> <td>Town</td> <td><input type="text" name="town" id="town"></td> </tr> <tr> <td>Country</td> <td><input type="text" name="country" id="country"></td> </tr> <tr> <td>Special Offers</td> <td><input name="special" type="radio" id="special" value="Yes" checked="checked" /> Yes <input type="radio" name="special" id="special" value="No" /> No</td> </tr> <tr> <td>Are you a subscriber?</td> <td><input name="subscriber" type="radio" id="subscriber" value="Yes" checked="checked" /> Yes <input type="radio" name="subscriber" id="subscriber" value="No" /> No</td> </tr> <tr> <td>Are you a reader?</td> <td><input name="reader" type="radio" id="reader" value="Yes" checked="checked" /> Yes <input type="radio" name="reader" id="reader" value="No" /> No</td> </tr> <tr> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> <input type="submit" name="register" id="register" value="Register" /> <input type="reset" name="button" id="button" value="Reset" /></td> </tr> </table> </form> <?php } require("footer.php"); ?> Thanks in advance Link to comment https://forums.phpfreaks.com/topic/108623-solved-insert/ Share on other sites More sharing options...
DarkWater Posted June 4, 2008 Share Posted June 4, 2008 Holy. Crap. I beg of you people to put OR die(mysql_error()) after your queries so you can see what's going on. =/ Link to comment https://forums.phpfreaks.com/topic/108623-solved-insert/#findComment-557096 Share on other sites More sharing options...
timmah1 Posted June 4, 2008 Author Share Posted June 4, 2008 WOW Batman! Guess I'm going to the Dark Side and heed his advice. Thanks, I'll remember it now, because if I'm not mistaken, this is about the 5th time that you have told me that. Works now :-) Link to comment https://forums.phpfreaks.com/topic/108623-solved-insert/#findComment-557100 Share on other sites More sharing options...
DarkWater Posted June 4, 2008 Share Posted June 4, 2008 Yeah. I think it's the 5th time too. =P It makes life about.... [ ] <--that much easier. Link to comment https://forums.phpfreaks.com/topic/108623-solved-insert/#findComment-557102 Share on other sites More sharing options...
timmah1 Posted June 4, 2008 Author Share Posted June 4, 2008 I'll never forget now, put it in my signature. :-) Link to comment https://forums.phpfreaks.com/topic/108623-solved-insert/#findComment-557105 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.