Jump to content

Contact form help with php - 05.13.11


mrjap1

Recommended Posts

Hello All,

 

I've successfully figure out how to make a form that connects to My Database, INSERTS the END USERS INFO into my database, and THEN sends a email notification back to the ME that contains the the END USERS INFO.

 

Is there a line of CODE in PHP to use that I can ALSO send the END USERS INFO from the form THEY FILLED OUT with all their details that was sent back to ME in the initial e-mail?

 

 

Also how do I get the date and time to post in the in my e-mail received with from the END USERS containing the date and time of the form filled out. It shows up in my Database HOWEVER, not in my RECEIVED e-mail.

 

Here is my code below:

 

<pre>

 

<?php 
if (isset($_POST['submitted'])) {
   include('connect2myDB.php');
   
   $salutation = $_POST['salutation'];
   $first_name = $_POST['first_name'];
   $last_name = $_POST['last_name'];
   $email = $_POST['email'];
   $zip_code = $_POST['zip_code'];
   $newsletter = $_POST['newsletter'];
   $registation_date = $_POST['registation_date'];
   $sqlinsert = "INSERT INTO travelers (salutation, first_name, last_name, email, zip_code, newsletter, registation_date) VALUES ('$salutation', '$first_name','$last_name','$email','$zip_code','$newsletter', NOW()))";
   
}


?>



<?php 

// ALL THE SUBJECT and EMAIL VARIABLES

   $emailSubject = 'MY TEST EMAIL SCRIPTING!!! ';
   $webMaster = 'mrjap1jobs@gmail.com';
   
   
   
// GATHERING the FORM DATA VARIABLES

   $salutation = $_POST['salutation'];
   $first_name = $_POST['first_name'];
   $last_name = $_POST['last_name'];
   $email = $_POST['email'];
   $zip_code = $_POST['zip_code'];
   $newsletter = $_POST['newsletter'];
   $registation_date = $_POST['registation_date'];  // THIS DATA DOES NOT SHOW UP IN MY RECEIVED E-MAIL HOWEVER, IT DOES SHOW UP IN MY DATABASE.... HOW DO I FIX THIS?
   
   $body = <<<EOD
<br /><hr><br />
<strong>Salutation:</strong> $salutation <br />
<strong>First Name:</strong> $first_name <br />
<strong>Last Name: </strong>$last_name <br />
<strong>Email:</strong> $email <br />
<strong>Zip Code:</strong> $zip_code <br />
<strong>Newsletter:</strong> $newsletter <br />
<strong>Registration Date:</strong> $registation_date <br />
EOD;


// THIS SHOW ALL E-MAILED DATA, ONCE IN THE E-MAILBOX AS READABLE HTML

   $headers = "From: $email\r\n";
   $headers .= "Content-type: text/html\r\n";
   $success = mail($webMaster, $emailSubject, $body, $headers);
   
   
// THE RESULTS OF THE FORM RENDERED AS PURE HTML 

   $theResults = <<<EOD
<!DOCTYPE HTML>
<html lang="en">
<head>
<style type="text/css">
body {
   font-family:Arial, Helvetica, sans-serif;
   font-size:11px;
   font-weight:bold;
   }

#thankyou_block {
   width: 400px;
   height: 250px;
   text-align:center;
   border: 1px solid #666;
   padding: 5px;
   background-color: #0CF;
   border-radius:8px;
   -webkit-border-radius:8px;
   -moz-border-radius:8px;
   -opera-border-radius:8px;
   -khtml-border-radius:8px;
   box-shadow:0px 0px 10px #000;
   -webkit-box-shadow: 0px 0px 10px #000;
   -moz-box-shadow: 0px 0px 10px #000;
   -o-box-shadow: 0px 0px 10px #000;
   margin: 25px auto;
}

p {
   font-family: Arial, Helvetica, sans-serif;
   font-size: 14px;
   line-height: 18px;
   letter-spacing:1px;
   color: #333;
}
   
</style>
<meta charset="UTF-8">
<title>THANK YOU!!!</title>
</head>

<body>

<div id="thankyou_block">
<br><br><br>
<h1>CONGRATULATIONS!!</h1>
<h2>YOUR FORM HAS BEEN PROCESSED!!!</h2>
<p>You are now registered in our Database...<br>
we will get back to you very shortly.<br>
Please have a very wondeful day.</p>

</div>
</body>
</html>

EOD;
echo "$theResults"; 



?>

 

</pre>

 

 

thanks

mrjap1

 

MOD EDIT: code tags added.

Link to comment
Share on other sites

You might need to set the date and time variables.. something like this for example

 

$date = date ("l, F jS, Y");
$time = date ("h:i A");

 

You could then add them to your email message like this:

 

$body = <<<EOD
<br /><hr><br />
<strong>Salutation:</strong> $salutation <br />
<strong>First Name:</strong> $first_name <br />
<strong>Last Name: </strong>$last_name <br />
<strong>Email:</strong> $email <br />
<strong>Zip Code:</strong> $zip_code <br />
<strong>Newsletter:</strong> $newsletter <br />
<strong>Registration Date:</strong> $date at $time <br />
EOD;

 

This should send the date and time the form was processed. Which should match the date from $registration_date which gets entered into the database

 

Hope that helps in some way.

Link to comment
Share on other sites

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.