473,320 Members | 1,829 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Why is registration Email Confirmation code not being sent?

My registration confirmation code is not sending out emails.

Please help.

Expand|Select|Wrap|Line Numbers
  1. <?php
  2.  
  3. if (isset($_POST['Submit'])) {
  4. //$Bday  = date("dd-mm-yyyy");
  5. include "dbCon.php";
  6.  
  7. $EmailAd = $_POST['EmailAd'];
  8. $Password = $_POST['Password'];
  9. $Name = $_POST['Name'];
  10. $Gender = $_POST['Gender'];
  11. $Bday = $_POST['Bday'];
  12. $Phone = $_POST['Phone'];
  13. $College = $_POST['College'];
  14. $Course = $_POST['Course'];
  15. $Yr = $_POST['Yr'];
  16. $UserType = $_POST['UserType'];
  17.  
  18.  
  19. /* Let's strip some slashes in case the user entered
  20. any escaped characters. */
  21. $EmailAd = stripslashes($EmailAd);
  22. $Password = stripslashes($Password);
  23. $Name = stripslashes($Name);
  24. $Gender = stripslashes($Gender);
  25. $Bday = stripslashes($Bday);
  26. $Phone = stripslashes($Phone);
  27. $College = stripslashes($College);
  28. $Course = stripslashes($Course);
  29. $Yr = stripslashes($Yr);
  30. $UserType = stripslashes($UserType);
  31.  
  32.  
  33.  
  34. /* Let's do some checking and ensure that the user's email address or username
  35.  does not exist in the database */
  36.  
  37. $sql_email_check = mysql_query("SELECT emailad FROM user WHERE EmailAd='$EmailAd'");
  38. // $sql_username_check = mysql_query("SELECT username FROM users WHERE username='$username'");
  39.  
  40. $email_check = mysql_num_rows($sql_email_check);
  41. // $username_check = mysql_num_rows($sql_username_check);
  42.  
  43.  if(($email_check > 0)){
  44.      echo "Please fix the following errors: <br />";
  45.      if($email_check > 0){
  46.          echo "<strong>Your email address has already been used. Please use a different Email address!<br />";
  47.          unset($email_address);
  48.  
  49.      include 'index.php'; // Show the form again!
  50.      exit();  // exit the script so that we do not create this account!
  51.     }}
  52.  
  53.  
  54.  
  55. // table name 
  56.  
  57. // Random confirmation code 
  58. $confirm_code=md5(uniqid(rand())); 
  59.  
  60.  
  61. $query = mysql_query("INSERT into temp_user (confirm_code, EmailAd, Password, Name, Gender, Bday, Phone, College, Course, Yr, UserType)
  62.                     VALUES('$confirm_code', '$EmailAd', '$Password', '$Name', '$Gender', '$Bday', '$Phone', '$College', '$Course', '$Yr', '$UserType')");
  63.  
  64. // $sql= "INSERT INTO user SET Regdate='$now',  expire='$exp'";
  65.  
  66. if($result){
  67.     // ---------------- SEND MAIL FORM ----------------
  68.  
  69. // send e-mail to ...
  70. $to=$emailad;
  71.  
  72. // Your subject
  73. $subject="Your confirmation link here";
  74.  
  75. // From
  76. //$header="from: mysite <alart@mysite.org>";
  77.  
  78. // Your message
  79. mysql_query($query);
  80. $to = $emailad;
  81. $subject = 'Imostars e-mail address confirmation';
  82. $message = "
  83. <p>Hey! Thanks for being part of our alumni portal. Click below to confirm your e-mail address.</p>
  84. <p><a href='http://mysite.org/confirm.php?emailad=$emailad'>below</a></p>";
  85.                 $headers = "ImoStars Alumni <alart@mysite.org>" . "\r\n" .
  86.                             'Content-type: text/html; charset=iso-8859-1' . "\r\n";
  87.                 mail($to,$subject,$message,$headers);
  88.             ?>
  89. <span style='color:green'>Congratulations, you've registered successfully! A confirmation e-mail has been sent to the address you entered.</span>
  90.  
  91.  
  92. }
  93. ?>
  94.  
Feb 3 '11 #1
5 3509
JKing
1,206 Expert 1GB
Have you done any debugging on this whatsoever?

Are there any errors?
Feb 3 '11 #2
There are no errors.
Feb 3 '11 #3
JKing
1,206 Expert 1GB
Okay, have you tried debugging this at all?
Feb 3 '11 #4
Niheel
2,460 Expert Mod 2GB
Your error is where you insert the code into the database and then check to see if the insert has been successful. This is causing the code to send an email to not execute.

You assign the query to variable to ($query)
Expand|Select|Wrap|Line Numbers
  1. $query = mysql_query("INSERT into temp_user (confirm_code, EmailAd, Password, Name, Gender, Bday, Phone, College, Course, Yr, UserType)
  2.                     VALUES('$confirm_code', '$EmailAd', '$Password', '$Name', '$Gender', '$Bday', '$Phone', '$College', '$Course', '$Yr', '$UserType')");
But when you check to see if the query has been executed, you check for ($result)

if($result){

Change $result to $query or vice a versa

Good Luck.
Feb 3 '11 #5
@tutusaint

Error is at the end of page.


mail($to,$subject,$message,$headers);
}
}
?>


end your program here.
May 26 '12 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Les Juby | last post by:
I've used a simple javascript for some time (no entries required up in the <head> tag) that asks for a confirmation before deleting. ie. <a href="/delete.asp?which=345 %>"...
3
by: Kenneth Farmer | last post by:
Several of my websites are getting hosed by automated scripts that insert all kinds of jiberish into the forms and newsletter sign-up fields. Sometimes I get a hundred an hour. I noticed the...
11
by: Prince of Code | last post by:
Hey There, I have been to this group for a couple of days. I am really impressed by the way people respond. I get answers for all my doubts and that too more info. So I am putting across a doubt...
2
by: Tatyana | last post by:
Hello, I'm having problems to Style Order Confirmation Email Body. I'm sending it out as HTML. Everything looks fine in Outlook, but hotmail accounts (checked it on yahoo and hotmail) seem to...
2
by: .Net Sports | last post by:
I'm using CDO mail in my asp scripts, and I need to find a script that whereas a user signs up for your website and when he hits submit, an email goes to his email box with a confirmation link for...
2
by: pbd22 | last post by:
Hi. I have got the email part working. I have it set up so there is a temp_table of the registration. There is a confirm_code column with an encrypted ID. My question is this - it seems...
1
by: DavidPr | last post by:
I'm using the User Registration from the book by Larry Ullman "PHP and MYSQL for dynamc websites - second edition, and it is suppose to send an email to the person who just registered so thay can...
1
by: newbie55 | last post by:
I’m currently using Async sockets with .BeginReceive called to collect any message from clients. I would like to know if the receiving socket received and processed the data sent and throw an...
4
by: xyrhou | last post by:
When i uploaded my site i got these error at registration. When a user register he/she will receive a confirmation email with the link to activate his/her account. But i got this error when i click...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.