Jump to content

RE: ADDING A CLIENT CONFIRMATION E-MAIL to CODE / THANK YOU.PHP - 05.21.11


mrjap1

Recommended Posts

Hello,

 

Below is my existing code for my web site visitor to fill out the form... they see a thank you html page.... and  I get the info inserted into my database.... and I get an e-mail with all their details, even their date of registration. From what I have seen so far, EVERYTHING WORKS SUCCESSFULLY. :D :D :D :D :D

 

HOWEVER, I would like to have the web site visitors details that they filled out ALSO SENT BACK to the web site visitor as a confirmation... say that this is a confirmation of the form they previously filled out.

 

How do I accomplish this based off of my existing code here?

I also would like my thank you.html code at the bottom of my current php code to be called in from a SEPARATE REDIRECT thankyou.php page after a successful form entry. I know that ALL headers must be IMMEDIATELY taken cared of upon entering any php page. This is what i used ***** header("Location: thankyou.php");******* Now I know that this is the correct code to make this happen but i do not know how to get this to work with my present code here.

 

How do put the header location: thank you.php code in my EXISTING PHP page to make this all work right?

 

 

 

thx

mrjap1

 

 


====================== HTML ==========================

<?php require_once("db_connection.php");?>



<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>HTML form for insert users</title>
<style type="text/css">
p {
margin:0;
padding:0;
font-family:Arial, Helvetica, sans-serif;
font-size:12px;
color:#633;
font-weight:bold;
}

legend {
font-family:Arial, Helvetica, sans-serif;
font-size:15px;
color:#3F6;
font-weight:bold;
}

#form_container {
background:#F7F;
margin: 50px auto 50px auto;
border: 1px solid #F00;
padding:10px;
width:285px;
height:150px;
}

input {
margin-bottom:5px;
}


body {
background-color: #033;
}
</style>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>

<body>



<?php 
if (isset($_POST['submit'])) { // Handle the form.


$message = NULL; // Create an empty new variable.

// Check for a first name.
if (empty($_POST['first_name'])) {
$first_name = FALSE;
$message .= '<p>You forgot to enter your first name... its Required!</p>';
} else {
$first_name = ($_POST['first_name']);
}

// Check for a last name.
if (empty($_POST['last_name'])) {
$last_name = FALSE;
$message .= '<p>You forgot to enter your last name... its Required!</p>';
} else {
$last_name = ($_POST['last_name']);
}

// Check for an email address.
if (empty($_POST['email'])) {
$email = FALSE;
$message .= '<p>You forgot to enter your email address... its Required!</p>';
} else {
$email = ($_POST['email']);
}
}
?>


<div id="form_container">

<form action="form_proceessed201XXX.php" method="post">
<input type="hidden" name="submit" value="true" />
<fieldset>
<legend>My Data Feilds</legend> 

  <!--  ### FIRST NAME ### -->
    <p>
    <label>First Name:</label><input name="first_name" type="text" value="<?php if(isset($_POST['first_name'])) echo $_POST['first_name']; ?>" 
id="first_name" size="15" maxlength="30">
   </p>
   
  <!--  ### LAST NAME ### -->
    <p>
    <label>Last Name:</label><input name="last_name" type="text" value="<?php if(isset($_POST['last_name'])) echo $_POST['last_name']; ?>" 
id="last_name" size="15" maxlength="30">
   </p>
   
  <!--  ### EMAIL ### -->
    <p>
    <label>E-mail:</label><input name="email" type="text" value="<?php if(isset($_POST['email'])) echo $_POST['email']; ?>"
id="email" size="15" maxlength="30">
    </p>
    
   <!--  ### SUBMIT BUTTON ### -->
    <p style="text-align:center">
    <input type="submit" name="submit" value="SEND MY INFO PLEASE" />
    </p>
</fieldset>
  </form>

</div>

</body>
</html>

====================== PHP ==========================

<?php
// ALL THE SUBJECT and EMAIL VARIABLES

$emailSubject = 'MY TEST EMAIL SCRIPTING!!! ';
$webMaster = 'myemail@gmail.com';

// GATHERING the FORM DATA VARIABLES

    $first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$email = $_POST['email'];
$registration_date = $_POST['registration_date'];
$date = date ("l, F jS, Y");
        $time = date ("h:i A");


$body = <<<EOD
<br /><hr><br />
<strong>First Name:</strong> $first_name <br />
<strong>Last Name: </strong>$last_name <br />
<strong>Email:</strong> $email <br />
<strong>Registration Date:</strong> $date at $time <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"; 



?>



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.