How to use Session in PHP like ASP
Hello,
I am trying to make a form that will, when submitted, will call "send.php" to process the form fields and then redirect to a "thanks.php" page.
Issue is, I want the "thanks.php" page to show the values of that form field submitted like Name, Product chosen, order No., Amount etc.
I have done similar kind of thing in ASP using sessions but unable to do it in PHP.
I am not using any database here. Just a simple "form mail" which sends the form contents to email & shows a "thanks.php" page for the confirmation or you may say customized Thanks to the user.
The PHP Code i.e. "send.php" I am using is as under:
Code:
<?php
$nameofproduct = $_REQUEST['nameofproduct'] ;
$priceusd = $_REQUEST['priceusd'] ;
$nametitle = $_REQUEST['nametitle'] ;
$name = $_REQUEST['name'] ;
$address = $_REQUEST['address'] ;
$city = $_REQUEST['city'] ;
$district = $_REQUEST['district'] ;
$state = $_REQUEST['state'] ;
$country = $_REQUEST['country'] ;
$pincode = $_REQUEST['pincode'] ;
$telephone = $_REQUEST['telephone'] ;
$email = $_REQUEST['email'] ;
$query = $_REQUEST['query'] ;
$uorder = date("dmY-His") ;
$userdetails = $_SERVER['REMOTE_ADDR'];
$ourid = "Company Name <info@company.com>";
$message = "<h4><font color=blue>$nametitle $name has placed an order. Details are as under</font></h4>
<br><br><b><u>CONTACT/SHIPPING DETAILS:</u></b>
<br><b>Name: </b> $title $name
<br><br><b>Address: </b> $address
<br><br><b>Telephone: </b> $telephone
<br><br><b>E-mail ID: </b> $email
<br><br><b>Any other Information/Question: </b> $query
<br><br><b>IP Address of Customer is: </b> $userdetails
<br><br><br><b><u>ORDER DETAILS</u></b>
<br><b>Order No.: </b> $uorder
<br><b>Name of Product: </b> PRODUCT NAME
<br><br><b>Total Amount (in US Dollars): </b> $priceusd ";
$repmessage = "<table border=0 width=600>
<tr><td><br>
<b>Dear $title $name</b>
<br><br>Thanks for your order. Your order details:
<br><br>Order No.: $uorder
<br><br>Name of Product: PRODUCT NAME
<br><br>Rate Per Unit in US Dollars: $priceusd
<br><br>Amount in USD: $priceusd
<br><br><br>
<br><br>Admin Team
<br><br>Company Name
<br>http://www.company.com</tr></td></table>";
$headers = "MIME-Version: 1.0\r\n";
$headers.= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers.= "From: $email\r\n";
$repheaders = "MIME-Version: 1.0\r\n";
$repheaders.= "Content-type: text/html; charset=iso-8859-1\r\n";
$repheaders.= "From: $ourid\r\n";
mail( "info@company.com", "Order No. $uorder received from website",
$message, $headers );
mail( "To: $email", "Thanks for your shopping at company.com",
$repmessage, $repheaders );
header( "Location: http://www.company.com/thanks.php" );
?>
The above code works just fine to send the form contents to the email. But I am not able to display the form contents in thanks.php page.
Actually I am neither an ASP programmar nor a PHP programmar as well. But knows how to do this in ASP. PHP is very new for me, thats why unable to do this.
Any help will be highly appreciated.