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

send users activation Email for the new accounts

I have this code (it's a form which will sign up new users and send them an email to active they account).

Expand|Select|Wrap|Line Numbers
  1. <?php
  2.         if(isset($_POST['submited'])) {
  3.             $msg="";
  4.  
  5.             $RFname = clean_text($_POST['RFname']);
  6.             $RLname = clean_text($_POST['RLname']);
  7.             $USERname = clean_text($_POST['UserName']);
  8.             $USERpassword = $_POST['UserPass'];
  9.             $USERpassword2 = $_POST['UserPassConfirm'];
  10.             $USERemail = $_POST['UserEmail'];
  11.             $USERwebsite = $_POST['WebSite'];
  12.             $hash = clean_text(md5(rand(0,1000)));
  13.  
  14.             if($USERpassword !== $USERpassword2) {
  15.             $msg = "<span class='errorMessges'>Confirm passwords did not match</span>";
  16.             }
  17.  
  18.             elseif($check=$db->query("select 1 from loginaccess where Email ='".$USERemail."'")){
  19.             if(mysqli_num_rows($check) > 0 ) {
  20.                 $msg = "<span class='errorMessges'>This email already taken</span>";
  21.             }
  22.  
  23.             elseif(empty($_SESSION['6_letters_code'] ) || strcasecmp($_SESSION['6_letters_code'], $_POST['6_letters_code']) != 0){
  24.             $msg = "<span class='errorMessges'>Human code verification invalid</span>";
  25.           }
  26.  
  27.             else{
  28.                 $putData = " insert into loginaccess (id, FUname, LUname, Uname, Pword, Email, Website, hash) value ('', '$RFname', '$RLname', '$USERname', '$USERpassword', '$USERemail', '$USERwebsite', '$hash')";
  29.  
  30.                 $inputResult = $db -> query ($putData) or die ('$db->error');
  31.  
  32.                 if ($inputResult){
  33.                 $msg = "<span class='successMessgaes'>You have been successfully registered</span>";
  34.  
  35.                 // Send email to our user 
  36. $to='$USERemail'; 
  37. $subject ='Signup | Verification'; 
  38. $message =' 
  39.  
  40. Thanks for signing up! 
  41. Your account has been created, you can login with the following credentials after you have activated your account by pressing the url below. 
  42.  
  43. ------------------------ 
  44. Username: '.$USERname.' 
  45. Password: '.$USERpassword.' 
  46. ------------------------ 
  47.  
  48. Please click this link to activate your account: 
  49.  
  50. http://www.yourwebsite.com/verify.php?email='.$USERemail.'&hash='.$hash.' 
  51.  
  52. ';
  53.  
  54. $headers = 'From:noreply@learning.com' . "\r\n"; 
  55. mail($to, $subject, $message, $headers);
  56.  
  57.                     }else{
  58.                         $msg = "<span class='errorMessges'>There was an error please try again later</span>";
  59.                     }
  60.                 }
  61.             }
  62.         }
  63.     ?>
  64.  
  65. <form action="<?php $_SERVER['PHP_SELF']; ?>" method="post">
  66.  
  67. <table width="762" border="0" cellspacing="5" cellpadding="5">
  68.   <tr>
  69.     <td colspan="2" class="socialAndPeopleByName">Personal information</td>
  70.     <td colspan="2"><span class="socialAndPeopleByName">Account information</span></td>
  71.     </tr>
  72.   <tr>
  73.     <td width="91" class="registrationInfo"><span class="red">*</span> First name</td>
  74.     <td width="203"><label for="textfield"></label>
  75.       <span id="sprytextfield1">
  76.       <input name="RFname" type="text" class="registrationFeild" id="textfield" />
  77.       <span class="textfieldRequiredMsg"><br>
  78.       First name  is required.</span></span></td>
  79.     <td width="148"><span class="red">*</span><span class="registrationInfo"> User name</span></td>
  80.     <td width="255"><span id="sprytextfield5">
  81.       <input name="UserName" type="text" class="registrationFeild" id="textfield5" />
  82.       <span class="textfieldRequiredMsg"><br>
  83.       User name is required.</span></span></td>
  84.   </tr>
  85.   <tr>
  86.     <td class="registrationInfo"><span class="red">*</span> Last name</td>
  87.     <td><span id="sprytextfield2">
  88.       <input name="RLname" type="text" class="registrationFeild" id="textfield2" />
  89.       <span class="textfieldRequiredMsg"><br>
  90.       Last name is required.</span></span></td>
  91.     <td><span class="red">*</span><span class="registrationInfo"> Password</span></td>
  92.     <td><span id="sprypassword1">
  93.     <input name="UserPass" type="password" class="registrationFeild" id="textfield7" />
  94.     <span class="passwordRequiredMsg"><br>
  95.     Password is required.</span><span class="passwordMaxCharsMsg"><br>
  96.     Password can't be more then 20 letter</span><span class="passwordMinCharsMsg"><br>
  97.     Password can't be less then 6 letter</span></span></td>
  98.   </tr>
  99.   <tr>
  100.     <td class="registrationInfo"><span class="red">*</span> Valid email</td>
  101.     <td><span id="sprytextfield3">
  102.     <input name="UserEmail" type="text" class="registrationFeild" id="textfield3" />
  103.     <br>
  104.     <span class="textfieldRequiredMsg">Valid email is required.</span><span class="textfieldInvalidFormatMsg">Invalid email format.</span></span></td>
  105.     <td><span class="red">*</span><span class="registrationInfo"> Confirm Password</span></td>
  106.     <td><span id="sprypassword2">
  107.       <input name="UserPassConfirm" type="password" class="registrationFeild" id="textfield8" />
  108.       <span class="passwordRequiredMsg"><br>
  109.       Please confirm your password</span></span></td>
  110.   </tr>
  111.   <tr>
  112.     <td class="registrationInfo">Web site</td>
  113.     <td><span id="sprytextfield4">
  114.       <input name="WebSite" type="text" class="registrationFeild" id="textfield4" />
  115.       <br>
  116.       <span class="textfieldInvalidFormatMsg">Invalid format</span></span></td>
  117.     <td><span class="registrationInfo"><span class="red">*</span> Prove you are human</span></td>
  118.     <td><img src="includes/captcha.php?rand=<?php echo rand(); ?>" align="absmiddle" id='captchaimg' /> <a href="javascript: refreshCaptcha();"><img src="http://bytes.com/images/refreshIcon.jpg" alt="Refresh" width="18" height="25" border="0" align="absmiddle" /></a>      <input name="6_letters_code" type="text" class="registrationFeildSmall" id="6_letters_code" /></td>
  119.   </tr>
  120.   <tr>
  121.     <td colspan="3"><?php if(!empty($msg)) {echo $msg;} ?></td>
  122.     <td><input name="submited" type="submit" class="signUpItem" id="submited" value="" /></td>
  123.   </tr>
  124. </table>
  125. </form>

I just don't send any Emails when the user submit.
I think it should do,
any Idea will help here.
Apr 17 '12 #1
1 2431
Luuk
1,047 Expert 1GB
First you should check for the return value of the function mail()
(see: http://www.php.net/manual/en/function.mail.php)

If this returns FALSE, no mail is send.
If this returns TRUE, is something in the config of your mailserver.
Apr 21 '12 #2

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

Similar topics

0
by: Akira | last post by:
Could someone tell me how to send outlook appointment email from asp page? I would like appointment email just like one outlook can send out. I tried to look for an answer for this, but it seems...
2
by: Kent | last post by:
Hi all, I have a .aspx page that I would like to Outlook. I can do that from the browser by: File/Send/Page by Email ...but it would be better if I cold send directly to Outlook. How can I...
1
by: Mike | last post by:
I'm creating a web app were i want to send users a link so they can go to a web page and view information on feeback for thier group. now in the url i want to add the date the feedback was...
6
by: toufik | last post by:
Hi, I've a crystal reports Report, Is it possible to send it by email? how? Thanks
5
by: sam | last post by:
Do anyone know how to apply send datagrid via email? Any website for reference? Please advise.
0
by: Dave S | last post by:
I have a lot of forms on our web site that require the user to fill out information and submit it back to us. currently the information comes back as name value pair. The our employee's then has to...
2
by: deepaks85 | last post by:
Dear Sir, How can I attach and send files through email in PHP? I am sending normal email through php script. It's working fine for me. Now I want to send some attached files with that mail. ...
1
by: steinwaygirl | last post by:
Hi all, I have been searching so hard for the answer to this, hopefully some of you all can help. I have created an HTML file with various forms - also included CSS and some javascript for...
0
by: sam song | last post by:
Hi everybody, i develop a email sender that uses outlook application in vs 2003. before a mail is sent, i hope the user can choose one email account as the sender address from all email accounts...
16
by: Ed Bitzer | last post by:
Trying to send groups of email with program using System.Net.Mail. I do not clear MailMessage but repeatedly loop changing only the Bcc entries. Works fine if all addresses are valid. As a simple...
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.