Jump to content

return button to form again???


wblati

Recommended Posts

when the form is completed there is no way for the user to return to the form again except for the back button on the browser. how do i put a button at the bottom of the thank you message.

 

also if its not too much of a hassle a simple add/subtract/multiple calculations(quantity/price/discount/total) to add to the form. thanks.

 

<html>
   <head>
   
   <style type=text/css>
input.blue {background-color: #0066FF; font-weight: bold; font-size: 12px; color: white;}
input.violet {background-color: #ccccff; font-size: 14px;}
textarea.violet {background-color: #ccccff; font-size: 14px;}
option.red {background-color: #cc0000; font-weight: bold; font-size: 14px; color: white;}
option.pink {background-color: #ffcccc;}
.style2 {	color: #990000;
font-weight: bold;
font-size: 36px;
font-family: Verdana, Arial, Helvetica, sans-serif;
}
.style5 {font-family: Arial, Helvetica, sans-serif; font-weight: bold; }
.style6 {font-family: Arial, Helvetica, sans-serif}
body {
background-color: #FFFFCC;
}
</style>
   
      <meta http-equiv='Content-Type' content='text/html; charset=utf-8'>
      <title>
  ONLINE MOVIE BOOKING
      </title>
      <Style>
        BODY, P,TD{ font-family: Arial,Verdana,Helvetica, sans-serif; font-size: 10pt }
        A{font-family: Arial,Verdana,Helvetica, sans-serif;}
        B {	font-family : Arial, Helvetica, sans-serif;	font-size : 12px;	font-weight : bold;}
        .style2 {color: #990000;
font-weight: bold;
font-size: 36px;
font-family: Verdana, Arial, Helvetica, sans-serif;
}
      </Style>
      </script>
   </head>
<body>
<h2 align="center"><span class="style2">ONLINE MOVIE BOOKING</span></h2>


<div align="center">
  <table width="444" border="1">
    <tr>
      <td colspan='2' align='center'><div align="left">
  
<?PHP // VALIDATIONS TAKEN php file formValidator.php (http://www.phpbuilder.com/columns/weiner20050831.php3?page=2)
require_once "formvalidator.php";
$show_form=true;

class MyValidator extends CustomValidator
{
function DoValidate(&$formars,&$error_hash)
{
        if(stristr($formars['Comments'],'http://'))
        {
            $error_hash['Comments']="No URLs allowed in comments";
            return false;
        }
	return true;
}
}

if(isset($_POST['Submit']))
{
    $validator = new FormValidator();

// TAKEN FROM http://www.html-form-guide.com/php-form/php-form-validation.html

// VALIDATION FOR NAME -------------------------------------------------------------------- 
    $validator->addValidation("NAME","req","Please enter a name");
$validator->addValidation("NAME","alpha_s","Please enter only letters");

// VALIDATION FOR EMAIL -------------------------------------------------------------------
$validator->addValidation("EMAIL","req","Please enter an email address");
    $validator->addValidation("EMAIL","email","Please enter a valid email address");

// VALIDATION FOR CARD NUMBER -------------------------------------------------------------
$validator->addValidation("CARD_NUMBER","req","Please enter a card number");
$validator->addValidation("CARD_NUMBER","numeric","Please enter only numbers");

// VALIDATION FOR CARD TYPE ---------------------------------------------------------------
$validator->addValidation("CARD_TYPE","dontselect=Please Choose","Please select a card type");

// VALIDATION FOR MOVIE -------------------------------------------------------------------
$validator->addValidation("MOVIE","dontselect=Please Choose","Please select a movie type");

// VALIDATION FOR DATE --------------------------------------------------------------------
$validator->addValidation("DATE","dontselect=Please Choose","Please select a date type");

// VALIDATION FOR TIME --------------------------------------------------------------------
$validator->addValidation("TIME","selectradio=TIME","Please select a time");

    $custom_validator = new MyValidator();
    $validator->AddCustomValidator($custom_validator);

    if($validator->ValidateForm())
    {
        echo "<h2>THANK YOU </h2>" ; 
	echo $_POST['NAME'];

	echo "<h2><br>HERES A RECEIPT FOR THE RECENT TRANSACTION<br></h2>";

	echo "<br>NAME: " ;
	echo $_POST['NAME'];

	echo "<br>EMAIL: " ;
	echo $_POST['EMAIL'];

	echo "<br>CARD NUMBER: " ;
	echo $_POST['CARD_NUMBER'];

	echo "<br>CARD TYPE: " ;
	echo $_POST['CARD_TYPE'];

	echo "<br>MOVIE: " ;
	echo $_POST['MOVIE'];

	echo "<br>DATE: " ;
	echo $_POST['DATE'];



        $show_form=false;
    }
    else
    {
        echo "<B>PLEASE CORRECT THE FOLLOWING ERRORS TO COMPLETE THE BOOKING</B>";

        $error_hash = $validator->GetErrors();
        foreach($error_hash as $inpname => $inp_err)
        {
            echo "<p>$inpname : $inp_err</p>\n";
        }        
    }
}

if(true == $show_form)
{
?>
      </div></td>
    </tr>
  </table>
</div>
  <form name='test' method='POST' action='' accept-charset='UTF-8'>
  <div align="center">
<table width="444" border="1">
            <tr>
              <td><span class="style5">NAME ON CARD: </span></td>
               <td class='element_label'>
                  <input class="violet" type="text" name="NAME" size="30" value="<?php echo $_POST['NAME'] ?>" />                
		   </td>
      </tr>
            <tr>
              <td><span class="style5">EMAIL: </span></td>
               <td class='element_label'>
                  <input class="violet" type='text' name='EMAIL' size='30' value="<?php echo $_POST['EMAIL'] ?>"/>               
		   </td>
      </tr>

		    <tr>
      <td><span class="style5">CARD_NUMBER: </span></td>
      <td><input class="violet" name="CARD_NUMBER" type='number' size='9' value="<?php echo $_POST['CARD_NUMBER'] ?>" /></td>
    </tr>
    <tr>
      <td><span class="style5">CARD_TYPE: </span></td>
      <td><span class="style6">
        <select name="CARD_TYPE" value="<?php echo $_POST['CARD_TYPE'] ?>" />
          <option class="red" >Please Choose</option>
          <option class="pink" >VISA</option>
          <option class="pink" >Mastercard</option>
          <option class="pink" >American Express</option>
          </select>
      </span></td>
    </tr>
    <tr>
      <td><span class="style5">MOVIES: </span></td>
      <td><span class="style6">
        <select name="MOVIE" value="<?php echo $_POST['MOVIE'] ?>" />
          <option class="red" >Please Choose</option>
          <option class="pink" >Burn After Reading</option>
          <option class="pink" >Planet Terror</option>
          <option class="pink" >Tropic Thunder</option>
          <option class="pink" >Quantum of solace</option>
          </select>
      </span></td>
    </tr>
    <tr>
      <td><span class="style5">DATE: </span></td>
      <td><span class="style6">
        <select name="DATE" value="<?php echo $_POST['DATE'] ?>"/>
          <option class="red" selected="selected">Please Choose</option>
          <option value="October 20" class="pink" >October 20</option>
          <option value="October 21" class="pink" >October 21</option>
          <option value="October 22" class="pink" >October 22</option>
          <option value="October 23" class="pink" >October 23</option>
          <option class="pink" >October 24</option>
          <option class="pink" >October 25</option>
          <option class="pink" >October 26</option>
          <option class="pink" >October 27</option>
          </select>
      </span></td>
    </tr>	
    <tr>
      <td><span class="style5"><br />
      TIME: </span></td>
      <td><span class="style6">
        <input type="radio" value="TIME" name="TIME" />
        10:40am<br />
        <input type="radio" value="TIME" name="TIME" />
        1:00pm<br />
        <input type="radio" value="TIME" name="TIME" />
        3:50pm<br />
        <input type="radio" value="TIME" name="TIME" />
        6:10pm<br />
        <input type="radio" value="TIME" name="TIME" />
        8:40pm<br />
        <input type="radio" value="TIME" name="TIME" />
      9:10pm</span></td>
   	  </tr>
            <tr>
              <td colspan='2' align='center'>
                <div align="right">
                  <input class="blue" type='submit' name='Submit' value='SUBMIT'>  
                </div>
                <p align="right">
      			 <input class="blue" name="Submit2" type="reset" value="CLEAR ALL FIELDS" />
   			</p>             
		  </td>
      		</tr>

</table>        
	</td>
</tr>
</table>
  </div>
</form>
<?PHP
}//true == $show_form
?>
</body>
<html>

Link to comment
Share on other sites

If you want to have a back button/link, and not lose all the data in the form, you will have to save it in a cookie/session. Set the cookie after the form has been sent. On the form page itself, check to see if the cookie exists, and if it does, populate the form with the values from it.

Link to comment
Share on other sites

M'all experience is that I actually rarely use cookies, and almost always use sessions, purely to cut down on page-bandwidth. The cookie is sent with every single http request, and if you have a lot of information in a cookie, it is sending that each time, whereas a session-cookie will only have the name of the session variable on the server in it, thereby cutting down on the amount of data being transferred.

 

Actually, if you have static images etc, it's better to access them from a separate domain name or subdomain altogether, as the cookie is only attached when sending from the domain it belongs to, and cookies don't actually need to be send with images etc, so if they are on a separate domain, the cookie isn't sent. For example, you ever notice on Yahoo, there are http requests to yming.com and yting.com? Those are the yahoo static image sites, used in order to prevent cookie transfers.

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.