473,395 Members | 1,608 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,395 software developers and data experts.

New user confirmation scrip not sending mail

I need help in new user email confirmation script for my site.

My script is populating my table but the email is not sending.

Please help.


Expand|Select|Wrap|Line Numbers
  1.  
  2. <?php
  3.  
  4. if (isset($_POST['Submit'])) {
  5. //$Bday  = date("dd-mm-yyyy");
  6. include "dbCon.php";
  7.  
  8. $EmailAd = $_POST['EmailAd'];
  9. $Password = $_POST['Password'];
  10. $Name = $_POST['Name'];
  11. $Gender = $_POST['Gender'];
  12. $Bday = $_POST['Bday'];
  13. $Phone = $_POST['Phone'];
  14. $College = $_POST['College'];
  15. $Course = $_POST['Course'];
  16. $Yr = $_POST['Yr'];
  17. $UserType = $_POST['UserType'];
  18.  
  19.  
  20. /* Let's strip some slashes in case the user entered
  21. any escaped characters. */
  22. $EmailAd = stripslashes($EmailAd);
  23. $Password = stripslashes($Password);
  24. $Name = stripslashes($Name);
  25. $Gender = stripslashes($Gender);
  26. $Bday = stripslashes($Bday);
  27. $Phone = stripslashes($Phone);
  28. $College = stripslashes($College);
  29. $Course = stripslashes($Course);
  30. $Yr = stripslashes($Yr);
  31. $UserType = stripslashes($UserType);
  32.  
  33.  
  34.  
  35. /* Let's do some checking and ensure that the user's email address or username
  36.  does not exist in the database */
  37.  
  38. $sql_email_check = mysql_query("SELECT emailad FROM user WHERE EmailAd='$EmailAd'");
  39. // $sql_username_check = mysql_query("SELECT username FROM users WHERE username='$username'");
  40.  
  41. $email_check = mysql_num_rows($sql_email_check);
  42. // $username_check = mysql_num_rows($sql_username_check);
  43.  
  44.  if(($email_check > 0)){
  45.      echo "Please fix the following errors: <br />";
  46.      if($email_check > 0){
  47.          echo "<strong>Your email address has already been used. Please use a different Email address!<br />";
  48.          unset($email_address);
  49.  
  50.      include 'index.php'; // Show the form again!
  51.      exit();  // exit the script so that we do not create this account!
  52.     }}
  53.  
  54.  
  55. //$expiry = date ("Y-m-d", mktime (0,0,0,date("m")+12,(date("d")-1),date("Y")));
  56. // table name 
  57.  
  58. // Random confirmation code 
  59. $confirm_code=md5(uniqid(rand())); 
  60.  
  61.  
  62. $query = mysql_query("INSERT into temp_user (confirm_code, EmailAd, Password, Name, Gender, Bday, Phone, College, Course, Yr, UserType)
  63.                     VALUES('$confirm_code', '$EmailAd', '$Password', '$Name', '$Gender', '$Bday', '$Phone', '$College', '$Course', '$Yr', '$UserType')");
  64.  
  65. // $sql= "INSERT INTO user SET Regdate='$now',  expire='$exp'";
  66.  
  67. $jude="SELECT emailad FROM temp_user WHERE emailad='$emailad'";
  68. $result=mysql_query($jude);
  69.  
  70. // if found this e-mail address, row must be 1 row
  71. // keep value in variable name "$count"
  72. $count=mysql_num_rows($result);
  73. }
  74. // compare if $count =1 row
  75. if($count==1){
  76.  
  77. $rows=mysql_fetch_array($result);
  78. // send e-mail to ...
  79. $to=$emailad;
  80.  
  81. // Your subject
  82. $subject="Your confirmation link here";
  83.  
  84. // From
  85. $header="from: mysite <alart@mysite.org>";
  86.  
  87. // Your message
  88. $message="Your Comfirmation link \r\n";
  89. $message.="Click on this link to activate your account \r\n";
  90. $message.="http://www.mysite.org/confirm.php?passkey=$confirm_code";
  91.  
  92. // send email
  93. $sentmail = mail($to,$subject,$header,$message);
  94.  
  95. }
  96.  
  97. // if not found 
  98. else {
  99. echo "Please enter a valid email address.";
  100. }
  101.  
  102. // if your email succesfully sent
  103. if($sentmail){
  104. echo "Your Confirmation link Has Been Sent To Your Email Address.";
  105. }
  106. else {
  107. echo "Cannot send Confirmation link to your e-mail address";
  108. }
  109.  
  110.  
  111.  
  112. ?>
  113.  
  114.  
Feb 21 '11 #1
1 1427
I haven't used MAIL() in forever but i remember offhand that $message was always the third item sent to that procedure.
Feb 22 '11 #2

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

Similar topics

3
by: Matthew | last post by:
I am have written a medium sized program and everything works fine except for one piece. At a certain point in the program I want to do a simple user confirmation, eg Are you sure ? y/n. The...
9
by: Leo Breebaart | last post by:
I am writing a utility in Python and I'd like to add a command-line option "--mailto <address>" that will cause an e-mail summary to be sent to <address> when the utility finishes running. My...
11
by: ColinWard | last post by:
Hi. I have the following code in a module which sends email via Outlook. Option Compare Database Option Explicit ' Declare module level variables Dim mOutlookApp As Outlook.Application Dim...
7
by: mostafa atalla | last post by:
how to send email by MS outlook express using C# code
3
by: HoustonComputerGuy | last post by:
I am working on getting my web applications moved to .Net 2.0 and am having some problems with System.Net.Mail. I get the following error when sending the mail: System.Net.Mail.SmtpException was...
2
by: Danny | last post by:
Hi all, Trying to send mail with System.Net.SmtpClient, using very simple code just for testing: SmtpClient smtp = new SmtpClient("mail.server.com", 25); smtp.Credentials = new...
9
by: JoeP | last post by:
Hi All, How can I find the reason for such an error: Failure sending mail. Some Code... oMailMessage.IsBodyHtml = False oMailMessage.Body = cEmailBody Dim oSMTP As New SmtpClient...
3
by: raj200809 | last post by:
when i m sending mail i received error from symantec Antivirus" Your email message was unable to be sent because your mail server rejected the message 550-5.7.1 the ip you’re using to send mail is...
7
by: undbund | last post by:
Hi I am creating a newsletter system. The software should run from desktop computer (localhost) but be able to send email to anyone on the internet. Can you guys give me some ideas on how to...
1
by: jagdeep gupta | last post by:
10.2 How to send emails by using System.Net.Mail CODE-BEHIND: MailMessage message = new MailMessage(); message.From = new MailAddress("fromusername@DomainName"); message.To.Add(new...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.