-2

I have recently starting using php so i need your help. I have created a contact form that sends an email to me after someone submits,but how can i send a copy of the email or a new email to the submitter also ?

Thank you in advance.

This is my html code where user enters his email:

<div class="row">
    <div class="col-md-6">
        <div class="form-group">
            <label for="form_email">Email </label>
            <input id="form_email" type="email" name="email" class="form-control" placeholder="">
            <div class="help-block with-errors"></div>
        </div>
    </div>

And this is the php code that sends an email to me :

<?php
$from = 'Someone <registration@registration.gr>';

// an email address that will receive the email with the output of the form
$sendTo = 'me <me@wxample.com>';

// subject of the email
$subject = 'Subject';

// form field names and their translations.
// array variable name => Text to appear in the email
$fields = array('name' => 'Ονομα', 'surname' => 'Επίθετο', 'need' => 'Need', 'title' => 'Τίτλος','specialty' => 'Ειδικότητα','foreas' => 'Φορέας','country' => 'Χώρα','city' => 'Πόλη','area' => 'Περιοχή','address' => 'Διευθυνση','tk' => 'T.K','tergasias' => 'Tηλ.Εργασίας','toikias' => 'Tηλ.Οικίας','mobile' => 'Κινητό','fax' => 'Φαξ','email' => 'Email'); 

// message that will be displayed when everything is OK :)
$okMessage = 'Successfull';

// If something goes wrong, we will display this message.
$errorMessage = 'There was an error while submitting the form. Please try again later';
RiggsFolly
  • 93,638
  • 21
  • 103
  • 149

1 Answers1

0

first of all request needs to be sent to php file , for example you send with parameter email=xyz@xyz.in through GET method,

generate a random number on php file save into a table with email

you can generate a random number by-

$randomcode=rand(100000,999999);

here i saved it to a variable named random code

now we can shoot that generating a url to email

$randomcode=rand(100000,999999);
$email=$_GET['email'];// storing email into a variable
$tempMail="verification@domain.com"; // --display on user email account
$to =$email;
$email_subject = "Verification of Email"; // you can enter anything else
$email_body = "http://www.somedomain.com/verifyemail.php?email=$email&code=$randomcode ,click above link to verify email";
$headers = "From: $tempMail\n"; 
$headers .= "Reply-To: $tempMail";
$check=false;
// now we will send mail
$check = mail($to,$email_subject,$email_body,$headers);
if($check){ //if success 
          }else{}

now you need to create a php document for verification of that email for example used above as verifyemail.php where php script will check if that random number is stored in table or not...

now user will get a email containing url, when he will click on that verifyemail.php will verify if these are present inn database or not, if yes then verification successful

Fraz Abbas
  • 158
  • 9