Jump to content

[SOLVED] how to add e-mail verification to register


berry05

Recommended Posts

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?

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

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

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>

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!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.