berry05 Posted November 22, 2008 Share Posted November 22, 2008 how do i do that? i looked everywhere on google for a script or a tut and couldn't find any.. like i want to add it to the registration form..and if its a invalid email or already used the registration wont go through...and if its valid it sticks to my database so that nobody else can sign up with that email again.. any help plz? Quote Link to comment Share on other sites More sharing options...
webmaster1 Posted November 22, 2008 Share Posted November 22, 2008 Post your existing code (your registration form) so we have something to work with. Quote Link to comment Share on other sites More sharing options...
gevans Posted November 22, 2008 Share Posted November 22, 2008 function emailCheck($e){ if(!ereg("^[^@]{1,64}@[^@]{1,255}$", $e)) return false; $e_array = explode("@", $e); $local_array = explode(".", $e_array[0]); for($i=0;$i<count($local_array);$i++) if(!ereg("^(([A-Za-z0-9!#$%&'*+/=?^_`{|}~-][A-Za-z0-9!#$%&'*+/=?^_`{|}~.-]{0,63})|("[^(\|")]{0,62}"))$", $local_array[$i])) return false; if(!ereg("^[?[0-9.]+]?$", $email_array[1])){ $domain_array = explode(".", $e_array[1]); if(count($domain_array)<2) return false; for($i=0;$i<count($domain_array);$i++) if (!ereg("^(([A-Za-z0-9][A-Za-z0-9-]{0,61}[A-Za-z0-9])|([A-Za-z0-9]+))$", $domain_array[$i])) return false; } return true; } that is a function to check an email address, it will return false if the email address isn't of proper layout Quote Link to comment Share on other sites More sharing options...
webmaster1 Posted November 22, 2008 Share Posted November 22, 2008 I've come across this online: <?php $fetch_exist=mysql_query("SELECT email, username FROM register WHERE email = '".varCheck($_POST['email'])."'" OR username = '".varCheck($_POST['username'])."'"); //then check if dupplicate if(mysql_num_rows($fetch_exist)>0) { while ($rst = mysql_fetch_array($fetch_exist, MYSQL)) { //Is it the username or the email? if ( $rst["username"] == $_POST['username'] ) { //its the username $error_message .="Your Username is already taken. "; } elseif ( $rst["email"] == $_POST['email'] ) { //its the email $error_message .="Your EMail is already taken. "; } } } else { //OK, everything is fine //Otherwise we would have gotten any rows (thus $error is not needed) //mysql_query 'INSERT....' here } //Now display $error_message and give the user another chance ?> Search google under the following: php check if email exists already Quote Link to comment Share on other sites More sharing options...
berry05 Posted November 22, 2008 Author Share Posted November 22, 2008 ok ill check the codes you guys sent...but this is my registration code.. <?php require_once('Connections/login.php'); ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } $editFormAction = $_SERVER['PHP_SELF']; if (isset($_SERVER['QUERY_STRING'])) { $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']); } if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "register")) { if($_POST['textfield2'] == $_POST['textfield3']) { $insertSQL = sprintf("INSERT INTO users (username, password) VALUES (%s, %s)", GetSQLValueString($_POST['textfield'], "text"), GetSQLValueString($_POST['textfield2'], "text")); mysql_select_db($database_login, $login); $Result1 = mysql_query($insertSQL, $login) or die(mysql_error()); if (isset($_SERVER['QUERY_STRING'])) { $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?"; $insertGoTo .= $_SERVER['QUERY_STRING']; } $insertGoTo = "good.html"; header(sprintf("Location: %s", $insertGoTo)); } else { echo 'Your passwords did not match'; } } ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <form id="register" name="register" method="POST" action="<?php echo $editFormAction; ?>"> <label>Desired Username:<br /> <input type="text" name="textfield" id="textfield" /> </label> <label><br /> <br /> </label> <table width="200" border="0" bordercolor="#000000"> <tr> <td><label> Password: <input type="password" name="textfield2" id="textfield2" /> </label></td> </tr> </table> <p> <label>Confim Password:<br /> <input type="password" name="textfield3" id="textfield3" /> </label> </p> <p> <label>E-Mail Verification<br /> <input type="text" name="textfield4" id="textfield4" /> </label> </p> <p> <label> <input type="submit" name="Register" id="Register" value="Register" /> </label> </p> <p> </p> <input type="hidden" name="MM_insert" value="register" /> </form> </body> </html> Quote Link to comment Share on other sites More sharing options...
berry05 Posted November 22, 2008 Author Share Posted November 22, 2008 i tried both codes and i keep getting errors..im using dremaweaver and i have a textfield box called "textfield4" to use it as where the people put in there e-mail address to check if its already taken... idk what to do...i googled php check if email exists already like webmaster told me to and still nothing.... please help! Quote Link to comment Share on other sites More sharing options...
gevans Posted November 22, 2008 Share Posted November 22, 2008 You should try learning some basic php and see if you can write it yourself. dreamweaver is just going to hinder you progress. It tries to do everything for you but as you can see it just makes your life hard Quote Link to comment Share on other sites More sharing options...
berry05 Posted November 22, 2008 Author Share Posted November 22, 2008 k...do you know any good sources? Quote Link to comment Share on other sites More sharing options...
gevans Posted November 22, 2008 Share Posted November 22, 2008 http://www.w3schools.com/php/default.asp that's not a bad starting place, you should also try and use http://www.php.net there you will be able to see more indepth view of what functions and code do.. Quote Link to comment Share on other sites More sharing options...
berry05 Posted November 23, 2008 Author Share Posted November 23, 2008 erhm...i looked at both sites...mostly w3....i guess i have to study harder.... thxs man 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.