lukeawade Posted September 9, 2008 Share Posted September 9, 2008 Im just checking to see if the email exists in a table I have in my database and that actually works. I just cant get it to display on the same page under my email textfield. Currently if they dont put in an email and click submit then it shows an error. The code below is what I use to check if their email has already been put in the database. It works but the only problem is if their email already exists it takes me to a blank page and just says my error message. "'ERROR! The email '.$_POST['email'].' has already registered." I want it to display this message below my email text field(code below my email check code). <?php //my email check above the body & head //checks if the email is registered if (!get_magic_quotes_gpc()) {$_POST['email'] = addslashes($_POST['email']);} $usercheck = $_POST['email']; $check = mysql_query("SELECT email FROM dashboard_registration WHERE email = '$usercheck'") or die(mysql_error()); $check2 = mysql_num_rows($check); //if the name exists it gives an error if ($check2 != 0) {die ('ERROR! The email '.$_POST['email'].' has already registered.');} //my text field in a table in the body <input name="email" type="text" id="email" value="<?php echo $row_rsdashboard_registration['email']; ?>" size="32" /> <?php echo $tNGs->displayFieldError("dashboard_registration", "email"); ?> Quote Link to comment https://forums.phpfreaks.com/topic/123508-check-if-email-exists/ Share on other sites More sharing options...
BlueSkyIS Posted September 9, 2008 Share Posted September 9, 2008 remove the line where it die()'s because nothing will happen after that. move that check to after your email field and echo the error instead of die()'ing. Quote Link to comment https://forums.phpfreaks.com/topic/123508-check-if-email-exists/#findComment-637853 Share on other sites More sharing options...
lisa71283 Posted September 9, 2008 Share Posted September 9, 2008 How can it output the form again when you are having it die() if the email already exists? Also, addslashes() is depreciated, and you really shouldn't use it. You should be using mysql(i)_real_escape_string() instead. Quote Link to comment https://forums.phpfreaks.com/topic/123508-check-if-email-exists/#findComment-637856 Share on other sites More sharing options...
BlueSkyIS Posted September 9, 2008 Share Posted September 9, 2008 deprecated Quote Link to comment https://forums.phpfreaks.com/topic/123508-check-if-email-exists/#findComment-637861 Share on other sites More sharing options...
lukeawade Posted September 9, 2008 Author Share Posted September 9, 2008 I've tried moving it to after the email field and echoing but that doesnt work. So just replace the addslashes with mysql(i)_real_escape_string() and that should do it? Quote Link to comment https://forums.phpfreaks.com/topic/123508-check-if-email-exists/#findComment-637873 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.