Jump to content

Confirmation page with preview and email submission


gamz

Recommended Posts

I've got this confirmation page using sessions and i'm having trouble suppressing the thank you message before the user pushes the submit button. 

Here's what i've got so far -

[code]<?php
session_start();
if( $_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['submit']) )
{
        $to = '[email protected]'; //will use real email address when it goes live.
        $subject = "Bippity Boppity Boo Confirmation";
        $from = stripslashes($_SESSION['rname']);
        $numbr = stripslashes($_SESSION['rnumber']);
        $msg = "Message sent by $from\n";
        $msg.= "Representative Phone Number: $numbr\n"; 
        $msg.= "<p>\nAddress: ".$_SESSION['address'];
        $msg.= "\nCity: ".$_SESSION['city'];
        $msg.= "\nState: ".$_SESSION['state'];
        $msg.= "\nZip: ".$_SESSION['zip'];
        $msg.= "<p>\nEvent Date: ".$_SESSION['date'];
        $msg.= "\nStart Time: ".$_SESSION['start'];
        $msg.= "\nStart Time: ".$_SESSION['end'];
        $msg.= "\nChildren: ".$_SESSION['kids'];
        $msg.= "\nAdults: ".$_SESSION['adults'];
        $msg.= "<p>\nSchool Name: ".$_SESSION['school'];
        if (mail($to,$subject,$msg))
        {
            echo "<p>Your reservation has been sent to the selected Bippity Boppity Boo Representative in that area.  They will be in contact with you to confirm your reservation.  Thank you!</p>";
            echo nl2br($msg);
        } else
            echo "An unknown error occurred.";
        }
?>
<html>
<head>
<style type="text/css">
<!--
.style4 {font-family: Arial; font-size: 10px; font-weight: bold; }
.style6 {font-family: Arial; font-size: 10px; color: #000066; }
-->
</style>
</head>
<title>Bippity Boppity Boo Confirmation</title>
<style type="text/css">
<!--
body {
margin-top: 0px;
background-color: #384E70;
}
-->
</style>

<body>
<div align="center">
  <table width="691" height="176" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
    <!--DWLayoutTable-->
    <tr>
      <td width="243" height="71" valign="top"><img src="images/Form_header_01.jpg" width="243" height="142" /></td>
    <td width="231" valign="top"><img src="images/Form_header_02.jpg" width="231" height="142" /></td>
    <td width="217" height="142" valign="top"><img src="images/Form_header_03.jpg" width="217" height="142" /></td>
    </tr>
    <tr>
      <td height="71" colspan="3" valign="top"><table width="80%" border="0" align="center" cellpadding="0" cellspacing="0">
        <tr>
          <td>
<h1 align="center">Bippity Boppity Boo Party Reservation<br>
  Confirmation Page
  <body>
</h1>
<form name="bc" method="POST" action="<?php echo $_SERVER['PHP_SELF'] ?>">
<table width="100%" border="0" cellspacing="1" cellpadding="1">
  <tr>
    <td width="30%" class="style4"><label>
      <div align="right">Representative Name:</div>
    </label></td>
    <td width="70%" class="style6"><?php $rname=$_SESSION['rname']; echo "$rname";?>    </td>
  </tr>
  <tr>
    <td class="style4"><label>
      <div align="right">Representative Phone Number:</div>
    </label></td>
    <td class="style6"><?php $rnumber=$_SESSION['rnumber']; echo "$rnumber";?>    </td>
  </tr>
</table>
<br>
<table width="100%" border="0" cellspacing="1" cellpadding="1">
  <tr>
    <td width="30%" class="style4"><label>
      <div align="right">Address:</div>
    </label></td>
    <td width="70%" class="style6"><?php $address=$_SESSION['address']; echo "$address";?>    </td>
  </tr>
  <tr>
    <td class="style4"><label>
      <div align="right">City:</div>
    </label></td>
    <td class="style6"><?php $city=$_SESSION['city']; echo "$city";?>    </td>
  </tr>
  <tr>
    <td class="style4"><label>
      <div align="right">State:</div>
    </label></td>
    <td class="style6"><?php $state=$_SESSION['state']; echo "$state";?>    </td>
  </tr>
  <tr>
    <td class="style4"><label>
      <div align="right">Zip:</div>
    </label></td>
    <td class="style6"><?php $zip=$_SESSION['zip']; echo "$zip";?>    </td>
  </tr>
  <tr>
    <td class="style4"><label>
      <div align="right">Location:</div>
    </label></td>
    <td class="style6"><?php $location=$_SESSION['location']; echo "$location";?>    </td>
  </tr>
  <tr>
    <td class="style4"><label>
      <div align="right">Date:</div>
    </label></td>
    <td class="style6"><?php $date=$_SESSION['date']; echo "$date";?>    </td>
  </tr>
  <tr>
    <td class="style4"><label>
      <div align="right">Start:</div>
    </label></td>
    <td class="style6"><?php $start=$_SESSION['start']; echo "$start";?>    </td>
  </tr>
  <tr>
    <td class="style4"><label>
      <div align="right">End:</div>
    </label></td>
    <td class="style6"><?php $end=$_SESSION['end']; echo "$end";?>    </td>
  </tr>
  <tr>
    <td class="style4"><label>
      <div align="right">Children:</div>
    </label></td>
    <td class="style6"><?php $kids=$_SESSION['kids']; echo "$kids";?>    </td>
  </tr>
  <tr>
    <td class="style4"><label>
    <div align="right">Adults:</div>
    </label></td>
    <td class="style6"><?php $adults=$_SESSION['adults']; echo "$adults";?>    </td>
  </tr>
  <tr>
    <td class="style4"><label>
      <div align="right">School:</div>
    </label></td>
    <td class="style6"><?php $school=$_SESSION['school']; echo "$school";?>    </td>
  </tr>
</table>
<br>

<p>
  <input name="back" id="back" type="button" class="style1"  value="Back" onClick="history.go(-1);return true;">
  <input name="submit" type="submit" class="style1" id="submit" value="Submit">
  <input type="button" value=" Print this page "
onclick="window.print();return false;" /></p>

</form>
</td>
        </tr>
      </table></td>
    </tr>
  </table>
</div>
</body>
</html>
[/code]

Any ideas?  Thanks in advance.
Here is how I would do it on your form have a hidden field like this
[code]
<form>
// Form Fields

<input type="hidden" name="req" value="process" />
</form>
[/code]

then where ever it goes set up a case thats like this:
[code]
$req = (!isset($_REQUEST['req'])) ? 'default' : $_REQUEST['req'];
switch($req){
case "process":
$to = '[email protected]'; //will use real email address when it goes live.
        $subject = "Bippity Boppity Boo Confirmation";
        $from = stripslashes($_SESSION['rname']);
        $numbr = stripslashes($_SESSION['rnumber']);
        $msg = "Message sent by $from\n";
        $msg.= "Representative Phone Number: $numbr\n"; 
        $msg.= "<p>\nAddress: ".$_SESSION['address'];
        $msg.= "\nCity: ".$_SESSION['city'];
        $msg.= "\nState: ".$_SESSION['state'];
        $msg.= "\nZip: ".$_SESSION['zip'];
        $msg.= "<p>\nEvent Date: ".$_SESSION['date'];
        $msg.= "\nStart Time: ".$_SESSION['start'];
        $msg.= "\nStart Time: ".$_SESSION['end'];
        $msg.= "\nChildren: ".$_SESSION['kids'];
        $msg.= "\nAdults: ".$_SESSION['adults'];
        $msg.= "<p>\nSchool Name: ".$_SESSION['school'];

        header("Location: thispage.php?req=thankyou");
break;
case "thankyou":
// thank you messeage here
break;
defualt:
// your form
break

[/code]


Something like should work just remember to use .php?req="casename" to access what ever part of the case you want to access next
Could you noobify this for me?

I'm changing my end form statements to :
<input type="hidden" name="req" value="process" />

and adding [code]$req = (!isset($_REQUEST['req'])) ? 'default' : $_REQUEST['req'];
switch($req){
case "process":
$to = '[email protected]'; //will use real email address when it goes live.
        $subject = "Bippity Boppity Boo Confirmation";
        $from = stripslashes($_SESSION['rname']);
        $numbr = stripslashes($_SESSION['rnumber']);
        $msg = "Message sent by $from\n";
        $msg.= "Representative Phone Number: $numbr\n"; 
        $msg.= "<p>\nAddress: ".$_SESSION['address'];
        $msg.= "\nCity: ".$_SESSION['city'];
        $msg.= "\nState: ".$_SESSION['state'];
        $msg.= "\nZip: ".$_SESSION['zip'];
        $msg.= "<p>\nEvent Date: ".$_SESSION['date'];
        $msg.= "\nStart Time: ".$_SESSION['start'];
        $msg.= "\nStart Time: ".$_SESSION['end'];
        $msg.= "\nChildren: ".$_SESSION['kids'];
        $msg.= "\nAdults: ".$_SESSION['adults'];
        $msg.= "<p>\nSchool Name: ".$_SESSION['school'];

        header("Location: thispage.php?req=thankyou");
break;
case "thankyou":
// thank you messeage here
break;
defualt:
// your form
break
[/code] ... to my already existing code?

If the field is hidden, how is the user going to deperess their confirm or submit button on the first page?
well all the hidden field is a field that will not display basicly your setting the value of req to process.

Then it will go to the next page and the top its going to check to see if that $req is set. in this case it will have the value of "process" and execute only the code in the "process" case. Then when it gets to end of this case the last line before the break in the process stament you can call the page several ways doing it the way i showed before or doing something like header("Location: $PHP_SELF?req="thankyou");

What that will do is call the same page but this time setting the value of req to thankyou and execute only the code in the thankyou case.

and all the default case does if the $req doesnt have a value of thankyou or process it will show the form they will fill out.

[code]
<?php
session_start();
$req = (!isset($_REQUEST['req'])) ? 'default' : $_REQUEST['req'];
switch($req){
case "process":
  $to = '[email protected]'; //will use real email address when it goes live.
        $subject = "Bippity Boppity Boo Confirmation";
        $from = stripslashes($_SESSION['rname']);
        $numbr = stripslashes($_SESSION['rnumber']);
        $msg = "Message sent by $from\n";
        $msg.= "Representative Phone Number: $numbr\n"; 
        $msg.= "<p>\nAddress: ".$_SESSION['address'];
        $msg.= "\nCity: ".$_SESSION['city'];
        $msg.= "\nState: ".$_SESSION['state'];
        $msg.= "\nZip: ".$_SESSION['zip'];
        $msg.= "<p>\nEvent Date: ".$_SESSION['date'];
        $msg.= "\nStart Time: ".$_SESSION['start'];
        $msg.= "\nStart Time: ".$_SESSION['end'];
        $msg.= "\nChildren: ".$_SESSION['kids'];
        $msg.= "\nAdults: ".$_SESSION['adults'];
        $msg.= "<p>\nSchool Name: ".$_SESSION['school'];
     
        header("Location: $_SERVER['PHP_SELF']?req=thankyou); // calling this page again to display your message. The $req now has a value of thankyou and will access only the thankyou part of this cases to show your message.
break;

case "thankyou":
      echo "<p>Your reservation has been sent to the selected Bippity Boppity Boo Representative in that    area.  They will be in contact with you to confirm your reservation.  Thank you!</p>";
break;
default:
?>
<form name="bc" method="POST" action="<?php echo $_SERVER['PHP_SELF'] ?>">
<table width="100%" border="0" cellspacing="1" cellpadding="1">
  <tr>
    <td width="30%" class="style4"><label>
      <div align="right">Representative Name:</div>
    </label></td>
    <td width="70%" class="style6"><?php $rname=$_SESSION['rname']; echo "$rname";?>    </td>
  </tr>
  <tr>
    <td class="style4"><label>
      <div align="right">Representative Phone Number:</div>
    </label></td>
    <td class="style6"><?php $rnumber=$_SESSION['rnumber']; echo "$rnumber";?>    </td>
  </tr>
</table>
<br>
<table width="100%" border="0" cellspacing="1" cellpadding="1">
  <tr>
    <td width="30%" class="style4"><label>
      <div align="right">Address:</div>
    </label></td>
    <td width="70%" class="style6"><?php $address=$_SESSION['address']; echo "$address";?>    </td>
  </tr>
  <tr>
    <td class="style4"><label>
      <div align="right">City:</div>
    </label></td>
    <td class="style6"><?php $city=$_SESSION['city']; echo "$city";?>    </td>
  </tr>
  <tr>
    <td class="style4"><label>
      <div align="right">State:</div>
    </label></td>
    <td class="style6"><?php $state=$_SESSION['state']; echo "$state";?>    </td>
  </tr>
  <tr>
    <td class="style4"><label>
      <div align="right">Zip:</div>
    </label></td>
    <td class="style6"><?php $zip=$_SESSION['zip']; echo "$zip";?>    </td>
  </tr>
  <tr>
    <td class="style4"><label>
      <div align="right">Location:</div>
    </label></td>
    <td class="style6"><?php $location=$_SESSION['location']; echo "$location";?>    </td>
  </tr>
  <tr>
    <td class="style4"><label>
      <div align="right">Date:</div>
    </label></td>
    <td class="style6"><?php $date=$_SESSION['date']; echo "$date";?>    </td>
  </tr>
  <tr>
    <td class="style4"><label>
      <div align="right">Start:</div>
    </label></td>
    <td class="style6"><?php $start=$_SESSION['start']; echo "$start";?>    </td>
  </tr>
  <tr>
    <td class="style4"><label>
      <div align="right">End:</div>
    </label></td>
    <td class="style6"><?php $end=$_SESSION['end']; echo "$end";?>    </td>
  </tr>
  <tr>
    <td class="style4"><label>
      <div align="right">Children:</div>
    </label></td>
    <td class="style6"><?php $kids=$_SESSION['kids']; echo "$kids";?>    </td>
  </tr>
  <tr>
    <td class="style4"><label>
    <div align="right">Adults:</div>
    </label></td>
    <td class="style6"><?php $adults=$_SESSION['adults']; echo "$adults";?>    </td>
  </tr>
  <tr>
    <td class="style4"><label>
      <div align="right">School:</div>
    </label></td>
    <td class="style6"><?php $school=$_SESSION['school']; echo "$school";?>    </td>
  </tr>
</table>
<br>

<p>
  <input name="back" id="back" type="button" class="style1"  value="Back" onClick="history.go(-1);return true;">
  <input name="submit" type="submit" class="style1" id="submit" value="Submit">
[color=red]  <input name="req" type="hidden" id="req" value="process" ><!-- ADDED THIS CODE -->[/color]
  <input type="button" value=" Print this page "
onclick="window.print();return false;" /></p>

</form>
<?php
break;
} // End Switch
?>
[/code]


Again adding the hidden field is just that its a field that sets the req variable for the switch statement. The user has nothing to do with this and does not need to fill it out at all infact there wont even be a form field hence the name hidden field.

A note on using the header("Location: $_SERVER['PHP_SELF']?req=thankyou")

im not sure thats the exact syntax you might need to wrap thank you in something like req='{'thankyou'}. Hopefully someone else can correct me if that is incorrect.

if you didnt want to put all this one the same code and not have to use $_SERVER['PHP_SELF'] you could have your form on one page say form.php and just change the action of the form action to another page, for example, <form action="thispage.php" method="post">

Then basicly use the same code I showed above except in the default case have it send them to the form page or display the form again. Then in the process case instead of header("Location: $_SERVER['PHP_SELF']?req=thankyou) you would do ("Location: thispage.php?req=thankyou"); which will again send them back to thispage.php but will only access the thankyou cases.

I hope explained it or showed you a little better im not the best explainer on things im just a doer until i have question of my own. Anyways I hope it clearified what i meant.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.