Jump to content

Error with confirmation of email


mikebyrne

Recommended Posts

Eveytime i run a test on my code i get the following error:

 

Not found your email in our databaseCannot send Confirmation link to your e-mail address

 

Here's my code:

 

Start


<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>
<td><form name="form1" method="post" action="signup_ac.php">
  <table align="center">
    <tr valign="baseline">
      <td nowrap align="right">Name:</td>
      <td><input type="text" name="name" value="" size="32"></td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">Address:</td>
      <td><input type="text" name="address" value="" size="32"></td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">Address1:</td>
      <td><input type="text" name="address1" value="" size="32"></td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">Address2:</td>
      <td><input type="text" name="address2" value="" size="32"></td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">Address3:</td>
      <td><input type="text" name="address3" value="" size="32"></td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">Address4:</td>
      <td><input type="text" name="address4" value="" size="32"></td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">County:</td>
      <td><input type="text" name="county" value="" size="32"></td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">Zip:</td>
      <td><input type="text" name="zip" value="" size="32"></td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">Telephone:</td>
      <td><input type="text" name="telephone" value="" size="32"></td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">Email:</td>
      <td><input type="text" name="email" value="" size="32"></td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">Username:</td>
      <td><input type="text" name="username" value="" size="32"></td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">Password:</td>
      <td><input type="password" name="password" value="" size="32"></td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right"> </td>
      <td><input type="submit" value="Insert record"></td>
    </tr>
  </table>
  <input type="hidden" name="MM_insert" value="form1">
</form>
<p> </p>
</body>
</html>

 

 

Signup_ac




<?php
include('config.php');

// table name
$tbl_name=temp_users;

// Random confirmation code
$confirm_code=md5(uniqid(rand()));

// values sent from form
$name=$_POST['name'];
$address=$_POST['address'];
$address1=$_POST['address1'];
$address2=$_POST['address2'];
$address3=$_POST['address3'];
$address4=$_POST['address4'];
$country=$_POST['country'];
$zip=$_POST['zip'];
$telephone=$_POST['telephone'];
$email=$_POST['email'];
$username=$_POST['username'];
$password=$_POST['password'];


// Insert data into database
$sql="INSERT INTO $tbl_name(confirm_code, name, address, address1, address2, address3, address4, country, zip, telephone, email, username, password)VALUES('$confirm_code', '$name', '$address', '$address1', '$address2','$address3', '$address4','$country' ,'$zip', '$telephone', '$email', '$username', '$password',)";
$result=mysql_query($sql);

// if suceesfully inserted data into database, send confirmation link to email
if($result){

// ---------------- SEND MAIL FORM ----------------

// send e-mail to ...
$to=$email;

// Your subject
$subject="Your confirmation link here";

// From
$header="from: postmaster@localhost <postmaster@localhost>";

// Your message
$message="Your Comfirmation link \r\n";
$message.="Click on this link to activate your account \r\n";
$message.="http://localhost/confirm.php?passkey=$confirm_code";

// send email
$sentmail = mail($to,$subject,$message,$header);

}

// if not found
else {
echo "Not found your email in our database";
}

// if your email succesfully sent
if($sentmail){
echo "Your Confirmation link Has Been Sent To Your Email Address.";
}
else {
echo "Cannot send Confirmation link to your e-mail address";
}

?>

 

Confirm

 




<?php
include('config.php');

// Passkey that got from link
$passkey=$_GET['passkey'];

$tbl_name1="temp_users";

// Retrieve data from table where row that match this passkey
$sql1="SELECT * FROM $tbl_name1 WHERE confirm_code ='$passkey'";
$result1=mysql_query($sql1);

// If successfully queried
if($result1){

// Count how many row has this passkey
$count=mysql_num_rows($result1);

// if found this passkey in our database, retrieve data from table "temp_users"
if($count==1){

$rows=mysql_fetch_array($result1);
$name=$_POST['name'];
$address=$_POST['address'];
$address1=$_POST['address1'];
$address2=$_POST['address2'];
$address3=$_POST['address3'];
$address4=$_POST['address4'];
$country=$_POST['country'];
$zip=$_POST['zip'];
$telephone=$_POST['telephone'];
$email=$_POST['email'];
$username=$_POST['username'];
$password=$_POST['password'];

$tbl_name2="users";

// Insert data that retrieves from "temp_users" into table "users"
$sql2="INSERT INTO $tbl_name2(name, address, address1, address2, address3, address4, country, zip, telephone, email, username, password)VALUES('$name', '$address', '$address1', '$address2','$address3', '$address4','$country' ,'$zip', '$telephone', '$email', '$username', '$password',)";
$result2=mysql_query($sql2);
}

// if not found passkey, display message "Wrong Confirmation code"
else {
echo "Wrong Confirmation code";
}

// if successfully moved data from table"temp_users" to table "users" displays message "Your account has been activated" and don't forget to delete confirmation code from table "temp_members_db"
if($result2){

echo "Your account has been activated";

// Delete information of this user from table "temp_users" that has this passkey
$sql3="DELETE FROM $tbl_name1 WHERE confirm_code = '$passkey'";
$result3=mysql_query($sql3);

}

}
?>

 

 

The code on the config.php file is fine

Link to comment
Share on other sites

There is something wrong with your insert query.

 

Change

$sql="INSERT INTO $tbl_name(confirm_code, name, address, address1, address2, address3, address4, country, zip, telephone, email, username, password)VALUES('$confirm_code', '$name', '$address', '$address1', '$address2','$address3', '$address4','$country' ,'$zip', '$telephone', '$email', '$username', '$password',)";
$result=mysql_query($sql);

 

To

$sql="INSERT INTO $tbl_name(confirm_code, name, address, address1, address2, address3, address4, country, zip, telephone, email, username, password)VALUES('$confirm_code', '$name', '$address', '$address1', '$address2','$address3', '$address4','$country' ,'$zip', '$telephone', '$email', '$username', '$password')";
$result=mysql_query($sql)or die(mysql_error());

 

Tell us what it outputs.

Link to comment
Share on other sites

No, I had county instead of country!!! Fixed that, now getting the error:

 

Warning: mail() [function.mail]: SMTP server response: 550 Address '<root@localhost>' not known here. in C:\xampp\htdocs\signup_ac.php on line 49

Cannot send Confirmation link to your e-mail address

 

My mail server is running in the background

 

If i try an hotmail address etc, I get:

 

Warning: mail() [function.mail]: SMTP server response: 553 We do not relay non-local mail, sorry. in C:\xampp\htdocs\signup_ac.php on line 49

Cannot send Confirmation link to your e-mail address

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.