Jump to content

Recommended Posts

I have a registration form on my website which the user has to enter there email address into. My php script needs to send a email to the enter email address registered on the from in order to send the user an account activation link. Below is the code I am attempting to do this with but its not working. Any ideas?

 

 


$mail = strtolower(strip_tags ($_POST["Email"]));

$to = '$mail';

$email_message .= " Content \n"; 

if (mail ($to, 'Registration', $email_message , 'From: ' . $name . ' <' . $email . '>')){
   echo "<meta http-equiv='refresh' content='5;url=/pages/register.php?error=18'>"; 
  } else {
  echo("<p>An error has occurred please try again!</p>");
  }

 

 

Thanks for any help! :D

you can use this kind of code to validate your email address.

 

if (filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) {
$e = mysqli_real_escape_string ($dbc, $_POST['email']);
} else {
$errors[] =  'Please enter a valid email address!';
}

 

 

use something like this to send email

 

if validation ok... handle your register form.. 


if (isset ( $_POST['submitted']) ) { // if your form submit true

      // u can validate your input data here... like email, password.....


    // if validation ok.. try something like this 

   if ( empy( $errors )) {

      //here u can send your email....

   }

} 

 

Here I used errors array to store error messages from validation process.. then I checked that errors array empty or not to send email.. It is empty mean, your validation process ok... if it is not empty there is a problem in validation process..

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.