t-buck
11-29-2007, 06:08 AM
I just created a form that when submitted, it submits to register.php. This file connects to a sql database and then drops the data in and sends an email of the data. Everything works, and we're all good.
What I want to do, is from this file, it directs to a form submitted successfully page. On this page, I want to display some of the data that was submitted in the form. How do I go about doing this?
Here is what is in register.php
<?php
require 'functions.php';
dbconnect();
if ($_POST["Submit"]=="Submit")
{
//REGISTRATION INFO REQUIREMENTS
if (!$name) { echo "Please <a href=javascript:history.go(-1)>go back</a> and fill in your <b>NAME.</B>"; exit(); }
if (!$nadults) { echo "Please <a href=javascript:history.go(-1)>go back</a> and fill in your <b>LAST NAME.</B>"; exit(); }
if (!$nchildren) { echo "Please <a href=javascript:history.go(-1)>go back</a> and fill in your <b>ORGANIZATION.</B>"; exit(); }
if (!$adultages) { echo "Please <a href=javascript:history.go(-1)>go back</a> and fill in your <b>BUSINESS ADDRESS.</B>"; exit(); }
if (!$childages) { echo "Please <a href=javascript:history.go(-1)>go back</a> and fill in your <b>BUSINESS CITY.</B>"; exit(); }
if (!$contact) { echo "Please <a href=javascript:history.go(-1)>go back</a> and fill in your <b>BUSINESS STATE.</B>"; exit(); }
if (!$address) { echo "Please <a href=javascript:history.go(-1)>go back</a> and fill in your <b>BUSINESS ZIP.</B>"; exit(); }
if (!$city) { echo "Please <a href=javascript:history.go(-1)>go back</a> and fill in your <b>PHONE.</B>"; exit(); }
if (!$state) { echo "Please <a href=javascript:history.go(-1)>go back</a> and fill in your <b>EMAIL.</B>"; exit(); }
if (!$zip) { echo "Please <a href=javascript:history.go(-1)>go back</a> and fill in the <b>ZIP.</B>"; exit(); }
if (!$phone) { echo "Please <a href=javascript:history.go(-1)>go back</a> and fill in the <b>TELEPHONE.</B>"; exit(); }
if (!$email) { echo "Please <a href=javascript:history.go(-1)>go back</a> and fill in the <b>EMAIL.</B>"; exit(); }
if (!$transportation) { echo "Please <a href=javascript:history.go(-1)>go back</a> and fill in the <b>TRANSPORTATION.</B>"; exit(); }
if (!$timeoutdoors) { echo "Please <a href=javascript:history.go(-1)>go back</a> and fill in the <b>TIMEOUTDOORS.</B>"; exit(); }
if (!$visit) { echo "Please <a href=javascript:history.go(-1)>go back</a> and fill in the <b>VISIT.</B>"; exit(); }
if (!$important) { echo "Please <a href=javascript:history.go(-1)>go back</a> and fill in the <b>IMPORTANT.</B>"; exit(); }
// ENTER THE INFORMATION IN THE DATABASE
$date=date("m-d-Y");
$appid=time();
$sql="INSERT INTO registration (appid, date, name, nadults, nchildren, adultages, childages, contact, address, city, state, zip, phone, email, transportation, ethnicity, ethnicityother, timeoutdoors, visit, important) VALUES ('$appid', '$date', '$name', '$nadults', '$nchildren',
'$adultages', '$childages', '$contact', '$address', '$city', '$state', '$zip', '$phone', '$email','$transportation','$ethnicity','$ethnicityother','$timeoutdoors','$visit','$important')";
$result=mysql_query($sql);
// SEND AN EMAIL NOTIFICATION
$from="$email";
$fromname="$name";
$to="";
$subject="Lincoln Safari Registration";
$html="
<strong>Application ID:</strong> $appid<p>
<strong>Date:</strong> $date<p>
<strong>Applicants Name:</strong> $fname $lname<p>
<strong>Organization:</strong> $organization<p>
<strong>Nickname:</strong> $nickname<p>
<strong>Address:</strong> $baddress<p>
<strong>City, State Zip:</strong> $bcity, $bstate $bzip<p>
<strong>Telephone:</strong> $phone<p>
<strong>Email:</strong> $email<p>
<hr>
<strong>First Time Attendee:</strong> $attended<p>
<hr>
<strong>Total Amount Charged:</strong> $answer<p>
<strong>Credit Card Type:</strong> $cctype<p>
<strong>Credit Card Number:</strong> $ccnumber<p>
<strong>Credit Card Expiration:</strong> $ccexpm/$ccexpy<p>
<strong>Billing Address:</strong> $ccaddress<p>
<strong>Billing City, State Zip:</strong> $cccity, $ccstate $cczip<p>
<strong>Name on Card:</strong> $ccname<p>";
$text=ereg_replace("<br>","\r\n",$html);
$attm=array();
SendMail($from,$fromname,$to,$subject, $html,$text,$attm,"\r\n\r\n");
// SEND APPLICANT TO SUCCESSFUL PAGE
header ("Location:successful.php");
exit();
}
?>
And here is what is in function.php
function SendMail($From,$FromName,$To,$Subject,$Text,$Html,$AttmFiles)
{
//sends email with attachments
$OB="----=_OuterBoundary_000";
$IB="----=_InnerBoundery_001";
$Html=$Html?$Html:preg_replace("/\n/","{br}",$Text) or die("neither text nor h
tml part present.");
$Text=$Text?$Text:"Sorry, but you need an html mailer to read this mail.";
$From or die("sender address missing");
$To or die("recipient address missing");
$headers ="MIME-Version: 1.0\r\n";
$headers.="From: ".$FromName." <".$From.">\n";
$headers.="To: ".$ToName." <".$To.">\n";
$headers.="Cc: " ."\n";
$headers.="Reply-To: ".$FromName." <".$From.">\n";
$headers.="X-Priority: 1\n";
$headers.="X-MSMail-Priority: High\n";
$headers.="X-Mailer: My PHP Mailer\n";
$headers.="Content-Type: multipart/text;\n\tboundary=\"".$OB."\"\n";
//Messages start with text/html alternatives in OB
$Msg ="This is a multi-part message in MIME format.\n";
$Msg.="\n--".$OB."\n";
$Msg.="Content-Type: multipart/alternative;\n\tboundary=\"".$IB."\"\n\n";
//plaintext section
$Msg.="\n--".$IB."\n";
$Msg.="Content-Type: text/plain;\n\tcharset=\"iso-8859-1\"\n";
$Msg.="Content-Transfer-Encoding: quoted-printable\n\n";
// plaintext goes here
$Msg.=$Text."\n\n";
// html section
$Msg.="\n--".$IB."\n";
$Msg.="Content-Type: text/html;\n\tcharset=\"iso-8859-1\"\n";
$Msg.="Content-Transfer-Encoding: base64\n\n";
// html goes here
$Msg.=chunk_split(base64_encode($Html))."\n\n";
// end of IB
$Msg.="\n--".$IB."--\n";
// attachments
if($AttmFiles)
{
foreach($AttmFiles as $AttmFile)
{
$patharray = explode ("/", $AttmFile);
$FileName=$patharray[count($patharray)-1];
$Msg.= "\n--".$OB."\n";
$Msg.="Content-Type: application/octetstream;\n\tname=\"".$FileName."\"\n"
;
$Msg.="Content-Transfer-Encoding: base64\n";
$Msg.="Content-Disposition: attachment;\n\tfilename=\"".$FileName."\"\n\n"
;
//file goes here
$fd=fopen ($AttmFile, "r");
$FileContent=fread($fd,filesize($AttmFile));
fclose ($fd);
$FileContent=chunk_split(base64_encode($FileContent));
$Msg.=$FileContent;
$Msg.="\n\n";
}
}
//message ends
$Msg.="\n--".$OB."--\n";
mail($To,$Subject,$Msg,$headers);
//syslog(LOG_INFO,"Mail: Message sent to $ToName <$To>");
}
?>
What I want to do, is from this file, it directs to a form submitted successfully page. On this page, I want to display some of the data that was submitted in the form. How do I go about doing this?
Here is what is in register.php
<?php
require 'functions.php';
dbconnect();
if ($_POST["Submit"]=="Submit")
{
//REGISTRATION INFO REQUIREMENTS
if (!$name) { echo "Please <a href=javascript:history.go(-1)>go back</a> and fill in your <b>NAME.</B>"; exit(); }
if (!$nadults) { echo "Please <a href=javascript:history.go(-1)>go back</a> and fill in your <b>LAST NAME.</B>"; exit(); }
if (!$nchildren) { echo "Please <a href=javascript:history.go(-1)>go back</a> and fill in your <b>ORGANIZATION.</B>"; exit(); }
if (!$adultages) { echo "Please <a href=javascript:history.go(-1)>go back</a> and fill in your <b>BUSINESS ADDRESS.</B>"; exit(); }
if (!$childages) { echo "Please <a href=javascript:history.go(-1)>go back</a> and fill in your <b>BUSINESS CITY.</B>"; exit(); }
if (!$contact) { echo "Please <a href=javascript:history.go(-1)>go back</a> and fill in your <b>BUSINESS STATE.</B>"; exit(); }
if (!$address) { echo "Please <a href=javascript:history.go(-1)>go back</a> and fill in your <b>BUSINESS ZIP.</B>"; exit(); }
if (!$city) { echo "Please <a href=javascript:history.go(-1)>go back</a> and fill in your <b>PHONE.</B>"; exit(); }
if (!$state) { echo "Please <a href=javascript:history.go(-1)>go back</a> and fill in your <b>EMAIL.</B>"; exit(); }
if (!$zip) { echo "Please <a href=javascript:history.go(-1)>go back</a> and fill in the <b>ZIP.</B>"; exit(); }
if (!$phone) { echo "Please <a href=javascript:history.go(-1)>go back</a> and fill in the <b>TELEPHONE.</B>"; exit(); }
if (!$email) { echo "Please <a href=javascript:history.go(-1)>go back</a> and fill in the <b>EMAIL.</B>"; exit(); }
if (!$transportation) { echo "Please <a href=javascript:history.go(-1)>go back</a> and fill in the <b>TRANSPORTATION.</B>"; exit(); }
if (!$timeoutdoors) { echo "Please <a href=javascript:history.go(-1)>go back</a> and fill in the <b>TIMEOUTDOORS.</B>"; exit(); }
if (!$visit) { echo "Please <a href=javascript:history.go(-1)>go back</a> and fill in the <b>VISIT.</B>"; exit(); }
if (!$important) { echo "Please <a href=javascript:history.go(-1)>go back</a> and fill in the <b>IMPORTANT.</B>"; exit(); }
// ENTER THE INFORMATION IN THE DATABASE
$date=date("m-d-Y");
$appid=time();
$sql="INSERT INTO registration (appid, date, name, nadults, nchildren, adultages, childages, contact, address, city, state, zip, phone, email, transportation, ethnicity, ethnicityother, timeoutdoors, visit, important) VALUES ('$appid', '$date', '$name', '$nadults', '$nchildren',
'$adultages', '$childages', '$contact', '$address', '$city', '$state', '$zip', '$phone', '$email','$transportation','$ethnicity','$ethnicityother','$timeoutdoors','$visit','$important')";
$result=mysql_query($sql);
// SEND AN EMAIL NOTIFICATION
$from="$email";
$fromname="$name";
$to="";
$subject="Lincoln Safari Registration";
$html="
<strong>Application ID:</strong> $appid<p>
<strong>Date:</strong> $date<p>
<strong>Applicants Name:</strong> $fname $lname<p>
<strong>Organization:</strong> $organization<p>
<strong>Nickname:</strong> $nickname<p>
<strong>Address:</strong> $baddress<p>
<strong>City, State Zip:</strong> $bcity, $bstate $bzip<p>
<strong>Telephone:</strong> $phone<p>
<strong>Email:</strong> $email<p>
<hr>
<strong>First Time Attendee:</strong> $attended<p>
<hr>
<strong>Total Amount Charged:</strong> $answer<p>
<strong>Credit Card Type:</strong> $cctype<p>
<strong>Credit Card Number:</strong> $ccnumber<p>
<strong>Credit Card Expiration:</strong> $ccexpm/$ccexpy<p>
<strong>Billing Address:</strong> $ccaddress<p>
<strong>Billing City, State Zip:</strong> $cccity, $ccstate $cczip<p>
<strong>Name on Card:</strong> $ccname<p>";
$text=ereg_replace("<br>","\r\n",$html);
$attm=array();
SendMail($from,$fromname,$to,$subject, $html,$text,$attm,"\r\n\r\n");
// SEND APPLICANT TO SUCCESSFUL PAGE
header ("Location:successful.php");
exit();
}
?>
And here is what is in function.php
function SendMail($From,$FromName,$To,$Subject,$Text,$Html,$AttmFiles)
{
//sends email with attachments
$OB="----=_OuterBoundary_000";
$IB="----=_InnerBoundery_001";
$Html=$Html?$Html:preg_replace("/\n/","{br}",$Text) or die("neither text nor h
tml part present.");
$Text=$Text?$Text:"Sorry, but you need an html mailer to read this mail.";
$From or die("sender address missing");
$To or die("recipient address missing");
$headers ="MIME-Version: 1.0\r\n";
$headers.="From: ".$FromName." <".$From.">\n";
$headers.="To: ".$ToName." <".$To.">\n";
$headers.="Cc: " ."\n";
$headers.="Reply-To: ".$FromName." <".$From.">\n";
$headers.="X-Priority: 1\n";
$headers.="X-MSMail-Priority: High\n";
$headers.="X-Mailer: My PHP Mailer\n";
$headers.="Content-Type: multipart/text;\n\tboundary=\"".$OB."\"\n";
//Messages start with text/html alternatives in OB
$Msg ="This is a multi-part message in MIME format.\n";
$Msg.="\n--".$OB."\n";
$Msg.="Content-Type: multipart/alternative;\n\tboundary=\"".$IB."\"\n\n";
//plaintext section
$Msg.="\n--".$IB."\n";
$Msg.="Content-Type: text/plain;\n\tcharset=\"iso-8859-1\"\n";
$Msg.="Content-Transfer-Encoding: quoted-printable\n\n";
// plaintext goes here
$Msg.=$Text."\n\n";
// html section
$Msg.="\n--".$IB."\n";
$Msg.="Content-Type: text/html;\n\tcharset=\"iso-8859-1\"\n";
$Msg.="Content-Transfer-Encoding: base64\n\n";
// html goes here
$Msg.=chunk_split(base64_encode($Html))."\n\n";
// end of IB
$Msg.="\n--".$IB."--\n";
// attachments
if($AttmFiles)
{
foreach($AttmFiles as $AttmFile)
{
$patharray = explode ("/", $AttmFile);
$FileName=$patharray[count($patharray)-1];
$Msg.= "\n--".$OB."\n";
$Msg.="Content-Type: application/octetstream;\n\tname=\"".$FileName."\"\n"
;
$Msg.="Content-Transfer-Encoding: base64\n";
$Msg.="Content-Disposition: attachment;\n\tfilename=\"".$FileName."\"\n\n"
;
//file goes here
$fd=fopen ($AttmFile, "r");
$FileContent=fread($fd,filesize($AttmFile));
fclose ($fd);
$FileContent=chunk_split(base64_encode($FileContent));
$Msg.=$FileContent;
$Msg.="\n\n";
}
}
//message ends
$Msg.="\n--".$OB."--\n";
mail($To,$Subject,$Msg,$headers);
//syslog(LOG_INFO,"Mail: Message sent to $ToName <$To>");
}
?>