Jump to content

PLEASE HELP! Form returning EVERYTHING BUT..


ShadowIce

Recommended Posts

How can I make $myCoupon, $hasdiscount, $print_pur_po_total, $print_pur_po_total2 show on page2? it's showing everything BUT the coupon code, the discount, the total, OR the discount total....

 

orderform.php:

 

<?php
session_start();
require('sessionvars.php');
?>
      <?php

function spamcheck($field)
  {
  //filter_var() sanitizes the e-mail
  //address using FILTER_SANITIZE_EMAIL
  $field=filter_var($field, FILTER_SANITIZE_EMAIL);

  //filter_var() validates the e-mail
  //address using FILTER_VALIDATE_EMAIL
  if(filter_var($field, FILTER_VALIDATE_EMAIL))
    {
    return TRUE;
    }
  else
    {
    return FALSE;
    }
  }

      function VerifyForm(&$values, &$errors)
      {
      // Do all necessary form verification

      if (strlen($values['f_name0001']) < 3){
      $errors['f_name0001'] = '* First name too short';
      }else if (strlen($values['f_name0001']) > 50){
      $errors['f_name0001'] = '* First name too long';
      }
      if ($values['f_name0001'] == ''){
      $errors['f_name0001'] = '* Please fill in your first name';
      }

      if (strlen($values['l_name0001']) < 3){
      $errors['l_name0001'] = '* Last name too short';
      }else if (strlen($values['l_name0001']) > 50){
      $errors['l_name0001'] = '* Last name too long';
      }
      if (htmlentities($values['l_name0001']) == ''){
      $errors['l_name0001'] = '* Please fill in your last name';
      }

      if (htmlentities($values['ad_0001']) == ''){
      $errors['ad_0001'] = '* Please fill in your address';
      }

      if (htmlentities($values['co_0001']) == ''){
      $errors['co_0001'] = ' * Please fill in your country';
      }

      if(htmlentities($values['c_0001']) == ''){
      $errors['c_0001'] = ' * Please fill in your city';
      }

      if (htmlentities($values['stateSelect']) == ''){
      $errors['stateSelect'] = '* Please fill in your state';
      }

      if (!ctype_digit($values['qtycd_0001'])) {
      $errors['qtycd_0001'] = ' * '.$values['qtycd_0001'].' is an invalid amount';
      }

/*      if (!(spamcheck($values['email']))){
      $errors['email'] = '* Email address invalid';
       }

      if(strlen($values['email']) == 0){
      $errors['email'] = '* Please fill in your email';
       }

      if (strlen($values['text']) == 0)
      $errors['text'] = '* Text required';*/

      if (count($errors) > 0)
      {
      return false;
      }

      return true;

      }

      function DisplayForm($values, $errors)
      {
      ?><html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Image Poseidon</title>
<LINK href="style.css" rel="stylesheet" type="text/css">
</head>
<body>

      <?php
      if (count($errors) > 0){
      $fontstart = "<font color=\"#FF0000\">";
      $fontend = "</font>";
      if(count($errors) > 1){echo "<p>".$fontstart."* There were ".count($errors)." errors in your submitted form, please correct them and try again.".$fontend."</p>"."\n";}
      if(count($errors) == 1){echo "<p>".$fontstart."* There is ".count($errors)." error in your submitted form, please correct it and try again.".$fontend."</p>"."\n";}
      ?>
      <tr>
      <?php if($errors['f_name0001'] != ''){ ?><td class="error"><?= $fontstart.$errors['f_name0001'].$fontend ?></td><br><?php } ?>
      <?php if($errors['l_name0001'] != ''){?><td class="error"><?= $fontstart.$errors['l_name0001'].$fontend ?></td><br><?php } ?>
      <?php if($errors['ad_0001'] != ''){?><td class="error"><?= $fontstart.$errors['ad_0001'].$fontend ?></td><br><?php } ?>
      <?php if($errors['co_0001'] != ''){?><td class="error"><?= $fontstart.$errors['co_0001'].$fontend ?></td><br><?php } ?>
      <?php if($errors['c_0001'] != ''){?><td class="error"><?= $fontstart.$errors['c_0001'].$fontend ?></td><br><?php } ?>
      <?php if($errors['stateSelect'] != ''){?><td class="error"><?= $fontstart.$errors['stateSelect'].$fontend ?></td><br><?php } ?>
      <?php if($errors['qtycd_0001'] != ''){?><td class="error"><?= $fontstart.$errors['qtycd_0001'].$fontend ?></td><br><?php } ?>
      </tr>
      <?php
      }
      ?>

<script type="text/javascript" src="js/highlight-active-input.js"></script>

<?php
require('header.php');
?>

<form action="Orderform.php" method="post">

<center>
<!--<fieldset>
<legend>Image Poseidon Order Form</legend>
-->
<table>
  <tr>
    <td><label for="fname_0001">First Name: </label></td>
    <td><input class="textInput" type="text" name="f_name0001" maxlength="30" id="f_name0001" size="30" /></td>
  </tr>
  <tr>
    <td><label for="lname_0001">Last Name: </label></td>
    <td><input class="textInput" type="text" name="l_name0001" maxlength="30" id="l_name0001" size="30"  /></td>
  </tr>
  <tr>
    <td><label for="a_d0001">Shipping Address: </label></td>
    <td><input class="textInput" type="text" name="ad_0001" maxlength="128" id="ad_0001" size="30"  /></td>
  </tr>
  <tr>
    <td>Country: </td>
    <td><select onfocus="this.style.backgroundColor='#4D6DF3';" onblur="this.style.backgroundColor='';" class="textInput" id='countrySelect' name='co_0001' style="width: 209px;">
<option value="">Choose Country</option>
<option value="Afganistan">Afghanistan</option>
<option value="Albania">Albania</option>
<option value="Algeria">Algeria</option>
<option value="American Samoa">American Samoa</option>
<option value="Andorra">Andorra</option>
<option value="Angola">Angola</option>
<option value="Anguilla">Anguilla</option>
<option value="Antigua & Barbuda">Antigua & Barbuda</option>
<option value="Argentina">Argentina</option>
<option value="Armenia">Armenia</option>
<option value="Aruba">Aruba</option>
<option value="Australia">Australia</option>
<option value="Austria">Austria</option>
<option value="Azerbaijan">Azerbaijan</option>
<option value="Bahamas">Bahamas</option>
<option value="Bahrain">Bahrain</option>
<option value="Bangladesh">Bangladesh</option>
<option value="Barbados">Barbados</option>
<option value="Belarus">Belarus</option>
<option value="Belgium">Belgium</option>
<option value="Belize">Belize</option>
<option value="Benin">Benin</option>
<option value="Bermuda">Bermuda</option>
<option value="Bhutan">Bhutan</option>
<option value="Bolivia">Bolivia</option>
<option value="Bonaire">Bonaire</option>
<option value="Bosnia & Herzegovina">Bosnia & Herzegovina</option>
<option value="Botswana">Botswana</option>
<option value="Brazil">Brazil</option>
<option value="British Indian Ocean Ter">British Indian Ocean Ter</option>
<option value="Brunei">Brunei</option>
<option value="Bulgaria">Bulgaria</option>
<option value="Burkina Faso">Burkina Faso</option>
<option value="Burundi">Burundi</option>
<option value="Cambodia">Cambodia</option>
<option value="Cameroon">Cameroon</option>
<option value="Canada">Canada</option>
<option value="Canary Islands">Canary Islands</option>
<option value="Cape Verde">Cape Verde</option>
<option value="Cayman Islands">Cayman Islands</option>
<option value="Central African Republic">Central African Republic</option>
<option value="Chad">Chad</option>
<option value="Channel Islands">Channel Islands</option>
<option value="Chile">Chile</option>
<option value="China">China</option>
<option value="Christmas Island">Christmas Island</option>
<option value="Cocos Island">Cocos Island</option>
<option value="Colombia">Colombia</option>
<option value="Comoros">Comoros</option>
<option value="Congo">Congo</option>
<option value="Cook Islands">Cook Islands</option>
<option value="Costa Rica">Costa Rica</option>
<option value="Cote DIvoire">Cote D'Ivoire</option>
<option value="Croatia">Croatia</option>
<option value="Cuba">Cuba</option>
<option value="Curaco">Curacao</option>
<option value="Cyprus">Cyprus</option>
<option value="Czech Republic">Czech Republic</option>
<option value="Denmark">Denmark</option>
<option value="Djibouti">Djibouti</option>
<option value="Dominica">Dominica</option>
<option value="Dominican Republic">Dominican Republic</option>
<option value="East Timor">East Timor</option>
<option value="Ecuador">Ecuador</option>
<option value="Egypt">Egypt</option>
<option value="El Salvador">El Salvador</option>
<option value="Equatorial Guinea">Equatorial Guinea</option>
<option value="Eritrea">Eritrea</option>
<option value="Estonia">Estonia</option>
<option value="Ethiopia">Ethiopia</option>
<option value="Falkland Islands">Falkland Islands</option>
<option value="Faroe Islands">Faroe Islands</option>
<option value="Fiji">Fiji</option>
<option value="Finland">Finland</option>
<option value="France">France</option>
<option value="French Guiana">French Guiana</option>
<option value="French Polynesia">French Polynesia</option>
<option value="French Southern Ter">French Southern Ter</option>
<option value="Gabon">Gabon</option>
<option value="Gambia">Gambia</option>
<option value="Georgia">Georgia</option>
<option value="Germany">Germany</option>
<option value="Ghana">Ghana</option>
<option value="Gibraltar">Gibraltar</option>
<option value="Great Britain">Great Britain</option>
<option value="Greece">Greece</option>
<option value="Greenland">Greenland</option>
<option value="Grenada">Grenada</option>
<option value="Guadeloupe">Guadeloupe</option>
<option value="Guam">Guam</option>
<option value="Guatemala">Guatemala</option>
<option value="Guinea">Guinea</option>
<option value="Guyana">Guyana</option>
<option value="Haiti">Haiti</option>
<option value="Hawaii">Hawaii</option>
<option value="Honduras">Honduras</option>
<option value="Hong Kong">Hong Kong</option>
<option value="Hungary">Hungary</option>
<option value="Iceland">Iceland</option>
<option value="India">India</option>
<option value="Indonesia">Indonesia</option>
<option value="Iran">Iran</option>
<option value="Iraq">Iraq</option>
<option value="Ireland">Ireland</option>
<option value="Isle of Man">Isle of Man</option>
<option value="Israel">Israel</option>
<option value="Italy">Italy</option>
<option value="Jamaica">Jamaica</option>
<option value="Japan">Japan</option>
<option value="Jordan">Jordan</option>
<option value="Kazakhstan">Kazakhstan</option>
<option value="Kenya">Kenya</option>
<option value="Kiribati">Kiribati</option>
<option value="Korea North">Korea North</option>
<option value="Korea Sout">Korea South</option>
<option value="Kuwait">Kuwait</option>
<option value="Kyrgyzstan">Kyrgyzstan</option>
<option value="Laos">Laos</option>
<option value="Latvia">Latvia</option>
<option value="Lebanon">Lebanon</option>
<option value="Lesotho">Lesotho</option>
<option value="Liberia">Liberia</option>
<option value="Libya">Libya</option>
<option value="Liechtenstein">Liechtenstein</option>
<option value="Lithuania">Lithuania</option>
<option value="Luxembourg">Luxembourg</option>
<option value="Macau">Macau</option>
<option value="Macedonia">Macedonia</option>
<option value="Madagascar">Madagascar</option>
<option value="Malaysia">Malaysia</option>
<option value="Malawi">Malawi</option>
<option value="Maldives">Maldives</option>
<option value="Mali">Mali</option>
<option value="Malta">Malta</option>
<option value="Marshall Islands">Marshall Islands</option>
<option value="Martinique">Martinique</option>
<option value="Mauritania">Mauritania</option>
<option value="Mauritius">Mauritius</option>
<option value="Mayotte">Mayotte</option>
<option value="Mexico">Mexico</option>
<option value="Midway Islands">Midway Islands</option>
<option value="Moldova">Moldova</option>
<option value="Monaco">Monaco</option>
<option value="Mongolia">Mongolia</option>
<option value="Montserrat">Montserrat</option>
<option value="Morocco">Morocco</option>
<option value="Mozambique">Mozambique</option>
<option value="Myanmar">Myanmar</option>
<option value="Nambia">Nambia</option>
<option value="Nauru">Nauru</option>
<option value="Nepal">Nepal</option>
<option value="Netherland Antilles">Netherland Antilles</option>
<option value="Netherlands">Netherlands (Holland, Europe)</option>
<option value="Nevis">Nevis</option>
<option value="New Caledonia">New Caledonia</option>
<option value="New Zealand">New Zealand</option>
<option value="Nicaragua">Nicaragua</option>
<option value="Niger">Niger</option>
<option value="Nigeria">Nigeria</option>
<option value="Niue">Niue</option>
<option value="Norfolk Island">Norfolk Island</option>
<option value="Norway">Norway</option>
<option value="Oman">Oman</option>
<option value="Pakistan">Pakistan</option>
<option value="Palau Island">Palau Island</option>
<option value="Palestine">Palestine</option>
<option value="Panama">Panama</option>
<option value="Papua New Guinea">Papua New Guinea</option>
<option value="Paraguay">Paraguay</option>
<option value="Peru">Peru</option>
<option value="Phillipines">Philippines</option>
<option value="Pitcairn Island">Pitcairn Island</option>
<option value="Poland">Poland</option>
<option value="Portugal">Portugal</option>
<option value="Puerto Rico">Puerto Rico</option>
<option value="Qatar">Qatar</option>
<option value="Republic of Montenegro">Republic of Montenegro</option>
<option value="Republic of Serbia">Republic of Serbia</option>
<option value="Reunion">Reunion</option>
<option value="Romania">Romania</option>
<option value="Russia">Russia</option>
<option value="Rwanda">Rwanda</option>
<option value="St Barthelemy">St Barthelemy</option>
<option value="St Eustatius">St Eustatius</option>
<option value="St Helena">St Helena</option>
<option value="St Kitts-Nevis">St Kitts-Nevis</option>
<option value="St Lucia">St Lucia</option>
<option value="St Maarten">St Maarten</option>
<option value="St Pierre & Miquelon">St Pierre & Miquelon</option>
<option value="St Vincent & Grenadines">St Vincent & Grenadines</option>
<option value="Saipan">Saipan</option>
<option value="Samoa">Samoa</option>
<option value="Samoa American">Samoa American</option>
<option value="San Marino">San Marino</option>
<option value="Sao Tome & Principe">Sao Tome & Principe</option>
<option value="Saudi Arabia">Saudi Arabia</option>
<option value="Senegal">Senegal</option>
<option value="Seychelles">Seychelles</option>
<option value="Sierra Leone">Sierra Leone</option>
<option value="Singapore">Singapore</option>
<option value="Slovakia">Slovakia</option>
<option value="Slovenia">Slovenia</option>
<option value="Solomon Islands">Solomon Islands</option>
<option value="Somalia">Somalia</option>
<option value="South Africa">South Africa</option>
<option value="Spain">Spain</option>
<option value="Sri Lanka">Sri Lanka</option>
<option value="Sudan">Sudan</option>
<option value="Suriname">Suriname</option>
<option value="Swaziland">Swaziland</option>
<option value="Sweden">Sweden</option>
<option value="Switzerland">Switzerland</option>
<option value="Syria">Syria</option>
<option value="Tahiti">Tahiti</option>
<option value="Taiwan">Taiwan</option>
<option value="Tajikistan">Tajikistan</option>
<option value="Tanzania">Tanzania</option>
<option value="Thailand">Thailand</option>
<option value="Togo">Togo</option>
<option value="Tokelau">Tokelau</option>
<option value="Tonga">Tonga</option>
<option value="Trinidad & Tobago">Trinidad & Tobago</option>
<option value="Tunisia">Tunisia</option>
<option value="Turkey">Turkey</option>
<option value="Turkmenistan">Turkmenistan</option>
<option value="Turks & Caicos Is">Turks & Caicos Is</option>
<option value="Tuvalu">Tuvalu</option>
<option value="Uganda">Uganda</option>
<option value="Ukraine">Ukraine</option>
<option value="United Arab Erimates">United Arab Emirates</option>
<option value="United Kingdom">United Kingdom</option>
<option value="United States of America">United States of America</option>
<option value="Uraguay">Uruguay</option>
<option value="Uzbekistan">Uzbekistan</option>
<option value="Vanuatu">Vanuatu</option>
<option value="Vatican City State">Vatican City State</option>
<option value="Venezuela">Venezuela</option>
<option value="Vietnam">Vietnam</option>
<option value="Virgin Islands (Brit)">Virgin Islands (Brit)</option>
<option value="Virgin Islands (USA)">Virgin Islands (USA)</option>
<option value="Wake Island">Wake Island</option>
<option value="Wallis & Futana Is">Wallis & Futana Is</option>
<option value="Yemen">Yemen</option>
<option value="Zaire">Zaire</option>
<option value="Zambia">Zambia</option>
<option value="Zimbabwe">Zimbabwe</option>
</select>

  </tr>

  <tr>
    <td><label for="c0001">City: </label></td>
    <td><input class="textInput" type="text" name="c_0001" maxlength="30" id="c_0001"  size="30"  /></td>
  </tr>
<br><br>
<tr>
<td>State: </td>
<td>
<select onfocus="this.style.backgroundColor='#4D6DF3';" onblur="this.style.backgroundColor='';" class="textInput" name="stateSelect" id="stateSelect" style="width: 209px;">
<option selected value="">Choose State</option>
<option value="">-- UNITED STATES --</option>
<option value="Alabama">Alabama</option>
<option value="Alaska">Alaska</option>
<option value="Arizona">Arizona</option>
<option value="Arkansas">Arkansas</option>
<option value="California">California</option>
<option value="Colorado">Colorado</option>
<option value="Connecticut">Connecticut</option>
<option value="Delaware">Delaware</option>
<option value="Florida">Florida</option>
<option value="Georgia">Georgia</option>
<option value="Hawaii">Hawaii</option>
<option value="Idaho">Idaho</option>
<option value="Illinois">Illinois</option>
<option value="Indiana">Indiana</option>
<option value="Iowa">Iowa</option>
<option value="Kansas">Kansas</option>
<option value="Kentucky">Kentucky</option>
<option value="Louisiana">Louisiana</option>
<option value="Maine">Maine</option>
<option value="Maryland">Maryland</option>
<option value="Massachusetts">Massachusetts</option>
<option value="Michigan">Michigan</option>
<option value="Minnesota">Minnesota</option>
<option value="Mississippi">Mississippi</option>
<option value="Missouri">Missouri</option>
<option value="Montana">Montana</option>
<option value="Nebraska">Nebraska</option>
<option value="Nevada">Nevada</option>
<option value="New Hampshire">New Hampshire</option>
<option value="New Jersey">New Jersey</option>
<option value="New Mexico">New Mexico</option>
<option value="New York">New York</option>
<option value="North Carolina">North Carolina</option>
<option value="North Dakota">North Dakota</option>
<option value="Ohio">Ohio</option>
<option value="Oklahoma">Oklahoma</option>
<option value="Oregon">Oregon</option>
<option value="Pennsylvania">Pennsylvania</option>
<option value="Rhode Island">Rhode Island</option>
<option value="South Carolina">South Carolina</option>
<option value="South Dakota">South Dakota</option>
<option value="Tennessee">Tennessee</option>
<option value="Texas">Texas</option>
<option value="Utah">Utah</option>
<option value="Vermont">Vermont</option>
<option value="Virginia">Virginia</option>
<option value="Washington">Washington</option>
<option value="West Virginia">West Virginia</option>
<option value="Wisconsin">Wisconsin</option>
<option value="Wyoming">Wyoming</option>
<option value="">-- CANADA --</option>
<option value="Alberta">Alberta</option>
<option value="British Columbia">British Columbia</option>
<option value="Manitoba">Manitoba</option>
<option value="New Brunswick">New Brunswick</option>
<option value="Newfoundland and Labrador">Newfoundland and Labrador</option>
<option value="Northwest Territories">Northwest Territories</option>
<option value="Nova Scotia">Nova Scotia</option>
<option value="Nunavut">Nunavut</option>
<option value="Ontario">Ontario</option>
<option value="Prince Edward Island">Prince Edward Island</option>
<option value="Quebec">Quebec</option>
<option value="Saskatchewan">Saskatchewan</option>
<option value="Yukon Territory">Yukon Territory</option>
<option value="">-- AUSTRALIA --</option>
<option value="Australian Capital Territory">Australian Capital Territory</option>
<option value="New South Wales">New South Wales</option>
<option value="Northern Territory">Northern Territory</option>
<option value="Queensland">Queensland</option>
<option value="South Australia">South Australia</option>
<option value="Tasmania">Tasmania</option>
<option value="Victoria">Victoria</option>
<option value="Western Australia">Western Australia</option>
</select>
</td>
</tr>
  <tr>
  </tr>
  <tr>
  </tr>
  <tr>
  </tr>
  <tr>
  </tr>
  <tr>
  </tr>
  </tr>
  <tr>
  </tr>
  <tr>
  </tr>
  <tr>
  </tr>
  <tr>
  </tr>
  <tr>
  </tr>
  <tr>
    <td width=150>Item: <br>
     </td>
    <td width=15>Quantity: <br>
     </td>
  </tr>
  <tr>
    <td>CD</td>
    <td><input class="textInput" type="text" name="qtycd_0001" id="qtycd_0001" value = "1" size="30" maxlength="7"></td>
  </tr>
  <tr>
  </tr>
  <tr>
  </tr>
  <tr>
  </tr>
  <tr>
  </tr>
  <tr>
  </tr>
  <tr>
  </tr>
  <tr>
  </tr>
  <tr>
  </tr>
  <tr>
  </tr>
  <tr>
  </tr>
  <tr>
  <td>Please enter a discount code if you have one: </td>
  <td><input class="textInput" type="text" name="sd_0001" value="000-000-00000" size="30" maxlength="64"></td>
  </tr>
  <tr style="text-align: center;">
  <td style="text-align: center;">
  <input style="text-align: Center;" type = "submit" value="Go To Next Page">
  </td>
  </tr>

</table>
<!--</legend>
</fieldset>-->
</center>

</form>

<script type="text/javascript">
// Initialize the input highlight script
initInputHighlightScript();
</script>

</body>
</html><?php
      }
      function ProcessForm($values)
      {
      //mail('$adminemail', 'Form test', $values['text'], "From: \"{$values['f_name0001']}\" <{$values['email']}>");
      //echo "<script>document.location = \"page2.php\";</script>\n";
       require('taxheader.php');
       echo '<META HTTP-EQUIV="Refresh" Content="0; URL=page2.php">';
      }
      if ($_SERVER['REQUEST_METHOD'] == 'POST')
      {
      $formValues = $_POST;
      $formErrors = array();
      if (!(VerifyForm($formValues, $formErrors))){ //|| !(array_key_exists('f_name0001', $formValues))){
      DisplayForm($formValues, $formErrors);
      }else{
      ProcessForm($formValues);
      }
      }else{
      DisplayForm(null, null);
      }
      ?>

 

page2.php:

 

<?php
session_start();
?>
<?php
require('header.php');
?><html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Image Poseidon</title>
</head>

<body>
<LINK href="style.css" rel="stylesheet" type="text/css">

<script src="view_printable.js"></script>
<script src="mainscripts.js"></script>

<center>
<a href="#" onclick="javascript:view_printable();">Click For Printable Page</a><br>
</center>

<center>
<h2>This is your order so far: </h2>
</center>

<FORM name="f0001" id="f0001" ACTION="processorder.php" method=post>

<center>

<?php
echo "Name: <b><u>".$_SESSION['f_name0001']." ".$_SESSION['l_name0001']."</u></b><br>\n"
."Address: <b><u>".$_SESSION['ad_0001']."</u></b><br>\n"
."Country: <b><u>".$_SESSION['co_0001']."</u></b><br>\n"
."City: <b><u>".$_SESSION['c_0001']."</u></b><br>\n"
."State/Province: <b><u>".$_SESSION['stateSelect']."</u></b><br>\n"
."Amount of CD(s) you want to purchase: <b><u>".$_SESSION['qtycd_0001']."</u></b><br>\n";

if($_SESSION['hasadiscount'] == true){echo "Your coupon code: <b><u>".$_SESSION['customercouponcode']."</u></b><br><br>\n";}

echo "<img src=\"gradient_grey3596386127_footer-iaza.png\"></img><br>\n";

echo "session: ".$_SESSION['hasadiscount'];

if($_SESSION['hasadiscount'] == true){

echo "<br>Original Total: <br><br>\n"
."<b>".$_SESSION['istotal']."-"."10%"."</b>"."<br>\n"
."<br>Your total: <br><br>\n"
."<b>".$_SESSION['isdiscounttotal']."</b><br>\n";

}else if($_SESSION['hasadiscount'] == false){

echo "<br>Your Total: <br><br>\n"
."<b>".$_SESSION['istotal']."</b><br>\n";

}

echo "<br>\n";

echo "<img src=\"gradient_grey3596386127-iaza.png\"></img>\n";

?>

<br>

<a href="#" onclick="javascript:view_printable();">Click For Printable Page</a><br><br>

<input name="subt1" id="subt1" type="submit" value="Submit" onclick="FormControl(1);">

</center>

</form>

</body>

</html>

 

sessionvars.php:

 

<?php

      if(isset($_POST['f_name0001'])){$_SESSION['f_name0001'] = $_POST['f_name0001'];}
      if(isset($_POST['l_name0001'])){$_SESSION['l_name0001'] = $_POST['l_name0001'];}
      if(isset($_POST['ad_0001'])){$_SESSION['ad_0001'] = $_POST['ad_0001'];}
      if(isset($_POST['co_0001'])){$_SESSION['co_0001'] = $_POST['co_0001'];}
      if(isset($_POST['c_0001'])){$_SESSION['c_0001'] = $_POST['c_0001'];}
      if(isset($_POST['stateSelect'])){$_SESSION['stateSelect'] = $_POST['stateSelect'];}
      if(isset($_POST['qtycd_0001'])){$_SESSION['qtycd_0001'] = $_POST['qtycd_0001'];}
      // no need to check the known variable from here on
      $_SESSION['customercouponcode'] = $myCoupon;
      $_SESSION['hasadiscount'] = $hasdiscount;
      $_SESSION['istotal'] = $print_pur_po_total;
      $_SESSION['isdiscounttotal'] = $print_pur_po_total2;
?>

 

the problem is with these lines i believe:

 

if($_SESSION['hasadiscount'] == true){

echo "<br>Original Total: <br><br>\n"
."<b>".$_SESSION['istotal']."-"."10%"."</b>"."<br>\n"
."<br>Your total: <br><br>\n"
."<b>".$_SESSION['isdiscounttotal']."</b><br>\n";

}else if($_SESSION['hasadiscount'] == false){

echo "<br>Your Total: <br><br>\n"
."<b>".$_SESSION['istotal']."</b><br>\n";

}

 

in page2.php

 

the problem is that the coupon code session variable, the has discount session variable, the total variable, and the discount total variable are NOT being passed to page2.php for some reason

Link to comment
Share on other sites

in taxheader.php:

 

<?php

$itemprice = 12;
$taxrate = 7;
$shipping = 1.75;
$discountrate = .90;
$qtycd = $_POST['qtycd_0001'];
$Subtotal = $itemprice;
$Tax = round( ($itemprice * $taxrate / 100 ), 2);
$Total = (($Tax + $Subtotal)*$qtycd)+($shipping*$qtycd);
$DiscountTotal = $Total*$discountrate; //round($Total*($discountrate), 2);
$coupons = file('Vm1wS01HRXhVWGxWYmxKV1lrZG9VRlpyVmt0WGJGSllZM3BHVG1KSFVubFhhMXByWWtkR05sSnJXbFpXYldoeVZrZDRWMDVzV2xsYVIwWlhWakpvVkZaVldrWlBWa0pTVUZRd1BRPT0=.txt', FILE_SKIP_EMPTY_LINES);
$coupons = array_map('trim', $coupons);
$myCoupon = $_POST['sd_0001'];
$hasdiscount = false;

// if found return the position in the array as $key
if(count($errors) == 0){
if(($key = array_search($myCoupon, $coupons)) !== false) {
$hasdiscount = true;
// delete the coupon from the array using $key
unset($coupons[$key]);
file_put_contents('Vm1wS01HRXhVWGxWYmxKV1lrZG9VRlpyVmt0WGJGSllZM3BHVG1KSFVubFhhMXByWWtkR05sSnJXbFpXYldoeVZrZDRWMDVzV2xsYVIwWlhWakpvVkZaVldrWlBWa0pTVUZRd1BRPT0=.txt', implode("\r\n", $coupons));
}
else if(($key = array_search($myCoupon, $coupons)) == false) {
$hasdiscount = false;
}

$number = $Total;
$pur_item_total = $number;
$pur_po_total =  ($pur_po_total + $pur_item_total);
$print_pur_po_total = wims_currency($pur_po_total);

$number2 = $DiscountTotal;
$pur_item_total2 = $number2;
$pur_po_total2 =  ($pur_po_total2 + $pur_item_total2);
$print_pur_po_total2 = wims_currency2($pur_po_total2);

}

function wims_currency($number) {
   if ($number < 0) {
     $print_number = "($" . str_replace('-', '', number_format ($number, 2, ".", ",")) . ")";
    } else {
     $print_number = "$" .  number_format ($number, 2, ".", ",") ;
   }
   return $print_number;
}

function wims_currency2($number2) {
   if ($number2 < 0) {
     $print_number2 = "($" . str_replace('-', '', number_format ($number2, 2, ".", ",")) . ")";
    } else {
     $print_number2 = "$" .  number_format ($number2, 2, ".", ",") ;
   }
   return $print_number2;
}

?>

Link to comment
Share on other sites

orderform.php:

 

<?php
session_start();
require('sessionvars.php');
require('taxheader.php');
?>
      <?php

function spamcheck($field)
  {
  //filter_var() sanitizes the e-mail
  //address using FILTER_SANITIZE_EMAIL
  $field=filter_var($field, FILTER_SANITIZE_EMAIL);

  //filter_var() validates the e-mail
  //address using FILTER_VALIDATE_EMAIL
  if(filter_var($field, FILTER_VALIDATE_EMAIL))
    {
    return TRUE;
    }
  else
    {
    return FALSE;
    }
  }

      function VerifyForm(&$values, &$errors)
      {
      // Do all necessary form verification

      if (strlen($values['f_name0001']) < 3){
      $errors['f_name0001'] = '* First name too short';
      }else if (strlen($values['f_name0001']) > 50){
      $errors['f_name0001'] = '* First name too long';
      }
      if ($values['f_name0001'] == ''){
      $errors['f_name0001'] = '* Please fill in your first name';
      }

      if (strlen($values['l_name0001']) < 3){
      $errors['l_name0001'] = '* Last name too short';
      }else if (strlen($values['l_name0001']) > 50){
      $errors['l_name0001'] = '* Last name too long';
      }
      if (htmlentities($values['l_name0001']) == ''){
      $errors['l_name0001'] = '* Please fill in your last name';
      }

      if (htmlentities($values['ad_0001']) == ''){
      $errors['ad_0001'] = '* Please fill in your address';
      }

      if (htmlentities($values['co_0001']) == ''){
      $errors['co_0001'] = ' * Please fill in your country';
      }

      if(htmlentities($values['c_0001']) == ''){
      $errors['c_0001'] = ' * Please fill in your city';
      }

      if (htmlentities($values['stateSelect']) == ''){
      $errors['stateSelect'] = '* Please fill in your state';
      }

      if (!ctype_digit($values['qtycd_0001'])) {
      $errors['qtycd_0001'] = ' * '.$values['qtycd_0001'].' is an invalid amount';
      }

/*      if (!(spamcheck($values['email']))){
      $errors['email'] = '* Email address invalid';
       }

      if(strlen($values['email']) == 0){
      $errors['email'] = '* Please fill in your email';
       }

      if (strlen($values['text']) == 0)
      $errors['text'] = '* Text required';*/

      if (count($errors) > 0)
      {
      return false;
      }

      return true;

      }

      function DisplayForm($values, $errors)
      {
      ?><html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Image Poseidon</title>
<LINK href="style.css" rel="stylesheet" type="text/css">
</head>
<body>

      <?php
      if (count($errors) > 0){
      $fontstart = "<font color=\"#FF0000\">";
      $fontend = "</font>";
      if(count($errors) > 1){echo "<p>".$fontstart."* There were ".count($errors)." errors in your submitted form, please correct them and try again.".$fontend."</p>"."\n";}
      if(count($errors) == 1){echo "<p>".$fontstart."* There is ".count($errors)." error in your submitted form, please correct it and try again.".$fontend."</p>"."\n";}
      ?>
      <tr>
      <?php if($errors['f_name0001'] != ''){ ?><td class="error"><?= $fontstart.$errors['f_name0001'].$fontend ?></td><br><?php } ?>
      <?php if($errors['l_name0001'] != ''){?><td class="error"><?= $fontstart.$errors['l_name0001'].$fontend ?></td><br><?php } ?>
      <?php if($errors['ad_0001'] != ''){?><td class="error"><?= $fontstart.$errors['ad_0001'].$fontend ?></td><br><?php } ?>
      <?php if($errors['co_0001'] != ''){?><td class="error"><?= $fontstart.$errors['co_0001'].$fontend ?></td><br><?php } ?>
      <?php if($errors['c_0001'] != ''){?><td class="error"><?= $fontstart.$errors['c_0001'].$fontend ?></td><br><?php } ?>
      <?php if($errors['stateSelect'] != ''){?><td class="error"><?= $fontstart.$errors['stateSelect'].$fontend ?></td><br><?php } ?>
      <?php if($errors['qtycd_0001'] != ''){?><td class="error"><?= $fontstart.$errors['qtycd_0001'].$fontend ?></td><br><?php } ?>
      </tr>
      <?php
      }
      ?>

<script type="text/javascript" src="js/highlight-active-input.js"></script>

<?php
require('header.php');
?>

<form action="Orderform.php" method="post">

<center>
<!--<fieldset>
<legend>Image Poseidon Order Form</legend>
-->
<table>
  <tr>
    <td><label for="fname_0001">First Name: </label></td>
    <td><input class="textInput" type="text" name="f_name0001" maxlength="30" id="f_name0001" size="30" /></td>
  </tr>
  <tr>
    <td><label for="lname_0001">Last Name: </label></td>
    <td><input class="textInput" type="text" name="l_name0001" maxlength="30" id="l_name0001" size="30"  /></td>
  </tr>
  <tr>
    <td><label for="a_d0001">Shipping Address: </label></td>
    <td><input class="textInput" type="text" name="ad_0001" maxlength="128" id="ad_0001" size="30"  /></td>
  </tr>
  <tr>
    <td>Country: </td>
    <td><select onfocus="this.style.backgroundColor='#4D6DF3';" onblur="this.style.backgroundColor='';" class="textInput" id='countrySelect' name='co_0001' style="width: 209px;">
<option value="">Choose Country</option>
<option value="Afganistan">Afghanistan</option>
<option value="Albania">Albania</option>
<option value="Algeria">Algeria</option>
<option value="American Samoa">American Samoa</option>
<option value="Andorra">Andorra</option>
<option value="Angola">Angola</option>
<option value="Anguilla">Anguilla</option>
<option value="Antigua & Barbuda">Antigua & Barbuda</option>
<option value="Argentina">Argentina</option>
<option value="Armenia">Armenia</option>
<option value="Aruba">Aruba</option>
<option value="Australia">Australia</option>
<option value="Austria">Austria</option>
<option value="Azerbaijan">Azerbaijan</option>
<option value="Bahamas">Bahamas</option>
<option value="Bahrain">Bahrain</option>
<option value="Bangladesh">Bangladesh</option>
<option value="Barbados">Barbados</option>
<option value="Belarus">Belarus</option>
<option value="Belgium">Belgium</option>
<option value="Belize">Belize</option>
<option value="Benin">Benin</option>
<option value="Bermuda">Bermuda</option>
<option value="Bhutan">Bhutan</option>
<option value="Bolivia">Bolivia</option>
<option value="Bonaire">Bonaire</option>
<option value="Bosnia & Herzegovina">Bosnia & Herzegovina</option>
<option value="Botswana">Botswana</option>
<option value="Brazil">Brazil</option>
<option value="British Indian Ocean Ter">British Indian Ocean Ter</option>
<option value="Brunei">Brunei</option>
<option value="Bulgaria">Bulgaria</option>
<option value="Burkina Faso">Burkina Faso</option>
<option value="Burundi">Burundi</option>
<option value="Cambodia">Cambodia</option>
<option value="Cameroon">Cameroon</option>
<option value="Canada">Canada</option>
<option value="Canary Islands">Canary Islands</option>
<option value="Cape Verde">Cape Verde</option>
<option value="Cayman Islands">Cayman Islands</option>
<option value="Central African Republic">Central African Republic</option>
<option value="Chad">Chad</option>
<option value="Channel Islands">Channel Islands</option>
<option value="Chile">Chile</option>
<option value="China">China</option>
<option value="Christmas Island">Christmas Island</option>
<option value="Cocos Island">Cocos Island</option>
<option value="Colombia">Colombia</option>
<option value="Comoros">Comoros</option>
<option value="Congo">Congo</option>
<option value="Cook Islands">Cook Islands</option>
<option value="Costa Rica">Costa Rica</option>
<option value="Cote DIvoire">Cote D'Ivoire</option>
<option value="Croatia">Croatia</option>
<option value="Cuba">Cuba</option>
<option value="Curaco">Curacao</option>
<option value="Cyprus">Cyprus</option>
<option value="Czech Republic">Czech Republic</option>
<option value="Denmark">Denmark</option>
<option value="Djibouti">Djibouti</option>
<option value="Dominica">Dominica</option>
<option value="Dominican Republic">Dominican Republic</option>
<option value="East Timor">East Timor</option>
<option value="Ecuador">Ecuador</option>
<option value="Egypt">Egypt</option>
<option value="El Salvador">El Salvador</option>
<option value="Equatorial Guinea">Equatorial Guinea</option>
<option value="Eritrea">Eritrea</option>
<option value="Estonia">Estonia</option>
<option value="Ethiopia">Ethiopia</option>
<option value="Falkland Islands">Falkland Islands</option>
<option value="Faroe Islands">Faroe Islands</option>
<option value="Fiji">Fiji</option>
<option value="Finland">Finland</option>
<option value="France">France</option>
<option value="French Guiana">French Guiana</option>
<option value="French Polynesia">French Polynesia</option>
<option value="French Southern Ter">French Southern Ter</option>
<option value="Gabon">Gabon</option>
<option value="Gambia">Gambia</option>
<option value="Georgia">Georgia</option>
<option value="Germany">Germany</option>
<option value="Ghana">Ghana</option>
<option value="Gibraltar">Gibraltar</option>
<option value="Great Britain">Great Britain</option>
<option value="Greece">Greece</option>
<option value="Greenland">Greenland</option>
<option value="Grenada">Grenada</option>
<option value="Guadeloupe">Guadeloupe</option>
<option value="Guam">Guam</option>
<option value="Guatemala">Guatemala</option>
<option value="Guinea">Guinea</option>
<option value="Guyana">Guyana</option>
<option value="Haiti">Haiti</option>
<option value="Hawaii">Hawaii</option>
<option value="Honduras">Honduras</option>
<option value="Hong Kong">Hong Kong</option>
<option value="Hungary">Hungary</option>
<option value="Iceland">Iceland</option>
<option value="India">India</option>
<option value="Indonesia">Indonesia</option>
<option value="Iran">Iran</option>
<option value="Iraq">Iraq</option>
<option value="Ireland">Ireland</option>
<option value="Isle of Man">Isle of Man</option>
<option value="Israel">Israel</option>
<option value="Italy">Italy</option>
<option value="Jamaica">Jamaica</option>
<option value="Japan">Japan</option>
<option value="Jordan">Jordan</option>
<option value="Kazakhstan">Kazakhstan</option>
<option value="Kenya">Kenya</option>
<option value="Kiribati">Kiribati</option>
<option value="Korea North">Korea North</option>
<option value="Korea Sout">Korea South</option>
<option value="Kuwait">Kuwait</option>
<option value="Kyrgyzstan">Kyrgyzstan</option>
<option value="Laos">Laos</option>
<option value="Latvia">Latvia</option>
<option value="Lebanon">Lebanon</option>
<option value="Lesotho">Lesotho</option>
<option value="Liberia">Liberia</option>
<option value="Libya">Libya</option>
<option value="Liechtenstein">Liechtenstein</option>
<option value="Lithuania">Lithuania</option>
<option value="Luxembourg">Luxembourg</option>
<option value="Macau">Macau</option>
<option value="Macedonia">Macedonia</option>
<option value="Madagascar">Madagascar</option>
<option value="Malaysia">Malaysia</option>
<option value="Malawi">Malawi</option>
<option value="Maldives">Maldives</option>
<option value="Mali">Mali</option>
<option value="Malta">Malta</option>
<option value="Marshall Islands">Marshall Islands</option>
<option value="Martinique">Martinique</option>
<option value="Mauritania">Mauritania</option>
<option value="Mauritius">Mauritius</option>
<option value="Mayotte">Mayotte</option>
<option value="Mexico">Mexico</option>
<option value="Midway Islands">Midway Islands</option>
<option value="Moldova">Moldova</option>
<option value="Monaco">Monaco</option>
<option value="Mongolia">Mongolia</option>
<option value="Montserrat">Montserrat</option>
<option value="Morocco">Morocco</option>
<option value="Mozambique">Mozambique</option>
<option value="Myanmar">Myanmar</option>
<option value="Nambia">Nambia</option>
<option value="Nauru">Nauru</option>
<option value="Nepal">Nepal</option>
<option value="Netherland Antilles">Netherland Antilles</option>
<option value="Netherlands">Netherlands (Holland, Europe)</option>
<option value="Nevis">Nevis</option>
<option value="New Caledonia">New Caledonia</option>
<option value="New Zealand">New Zealand</option>
<option value="Nicaragua">Nicaragua</option>
<option value="Niger">Niger</option>
<option value="Nigeria">Nigeria</option>
<option value="Niue">Niue</option>
<option value="Norfolk Island">Norfolk Island</option>
<option value="Norway">Norway</option>
<option value="Oman">Oman</option>
<option value="Pakistan">Pakistan</option>
<option value="Palau Island">Palau Island</option>
<option value="Palestine">Palestine</option>
<option value="Panama">Panama</option>
<option value="Papua New Guinea">Papua New Guinea</option>
<option value="Paraguay">Paraguay</option>
<option value="Peru">Peru</option>
<option value="Phillipines">Philippines</option>
<option value="Pitcairn Island">Pitcairn Island</option>
<option value="Poland">Poland</option>
<option value="Portugal">Portugal</option>
<option value="Puerto Rico">Puerto Rico</option>
<option value="Qatar">Qatar</option>
<option value="Republic of Montenegro">Republic of Montenegro</option>
<option value="Republic of Serbia">Republic of Serbia</option>
<option value="Reunion">Reunion</option>
<option value="Romania">Romania</option>
<option value="Russia">Russia</option>
<option value="Rwanda">Rwanda</option>
<option value="St Barthelemy">St Barthelemy</option>
<option value="St Eustatius">St Eustatius</option>
<option value="St Helena">St Helena</option>
<option value="St Kitts-Nevis">St Kitts-Nevis</option>
<option value="St Lucia">St Lucia</option>
<option value="St Maarten">St Maarten</option>
<option value="St Pierre & Miquelon">St Pierre & Miquelon</option>
<option value="St Vincent & Grenadines">St Vincent & Grenadines</option>
<option value="Saipan">Saipan</option>
<option value="Samoa">Samoa</option>
<option value="Samoa American">Samoa American</option>
<option value="San Marino">San Marino</option>
<option value="Sao Tome & Principe">Sao Tome & Principe</option>
<option value="Saudi Arabia">Saudi Arabia</option>
<option value="Senegal">Senegal</option>
<option value="Seychelles">Seychelles</option>
<option value="Sierra Leone">Sierra Leone</option>
<option value="Singapore">Singapore</option>
<option value="Slovakia">Slovakia</option>
<option value="Slovenia">Slovenia</option>
<option value="Solomon Islands">Solomon Islands</option>
<option value="Somalia">Somalia</option>
<option value="South Africa">South Africa</option>
<option value="Spain">Spain</option>
<option value="Sri Lanka">Sri Lanka</option>
<option value="Sudan">Sudan</option>
<option value="Suriname">Suriname</option>
<option value="Swaziland">Swaziland</option>
<option value="Sweden">Sweden</option>
<option value="Switzerland">Switzerland</option>
<option value="Syria">Syria</option>
<option value="Tahiti">Tahiti</option>
<option value="Taiwan">Taiwan</option>
<option value="Tajikistan">Tajikistan</option>
<option value="Tanzania">Tanzania</option>
<option value="Thailand">Thailand</option>
<option value="Togo">Togo</option>
<option value="Tokelau">Tokelau</option>
<option value="Tonga">Tonga</option>
<option value="Trinidad & Tobago">Trinidad & Tobago</option>
<option value="Tunisia">Tunisia</option>
<option value="Turkey">Turkey</option>
<option value="Turkmenistan">Turkmenistan</option>
<option value="Turks & Caicos Is">Turks & Caicos Is</option>
<option value="Tuvalu">Tuvalu</option>
<option value="Uganda">Uganda</option>
<option value="Ukraine">Ukraine</option>
<option value="United Arab Erimates">United Arab Emirates</option>
<option value="United Kingdom">United Kingdom</option>
<option value="United States of America">United States of America</option>
<option value="Uraguay">Uruguay</option>
<option value="Uzbekistan">Uzbekistan</option>
<option value="Vanuatu">Vanuatu</option>
<option value="Vatican City State">Vatican City State</option>
<option value="Venezuela">Venezuela</option>
<option value="Vietnam">Vietnam</option>
<option value="Virgin Islands (Brit)">Virgin Islands (Brit)</option>
<option value="Virgin Islands (USA)">Virgin Islands (USA)</option>
<option value="Wake Island">Wake Island</option>
<option value="Wallis & Futana Is">Wallis & Futana Is</option>
<option value="Yemen">Yemen</option>
<option value="Zaire">Zaire</option>
<option value="Zambia">Zambia</option>
<option value="Zimbabwe">Zimbabwe</option>
</select>

  </tr>

  <tr>
    <td><label for="c0001">City: </label></td>
    <td><input class="textInput" type="text" name="c_0001" maxlength="30" id="c_0001"  size="30"  /></td>
  </tr>
<br><br>
<tr>
<td>State: </td>
<td>
<select onfocus="this.style.backgroundColor='#4D6DF3';" onblur="this.style.backgroundColor='';" class="textInput" name="stateSelect" id="stateSelect" style="width: 209px;">
<option selected value="">Choose State</option>
<option value="">-- UNITED STATES --</option>
<option value="Alabama">Alabama</option>
<option value="Alaska">Alaska</option>
<option value="Arizona">Arizona</option>
<option value="Arkansas">Arkansas</option>
<option value="California">California</option>
<option value="Colorado">Colorado</option>
<option value="Connecticut">Connecticut</option>
<option value="Delaware">Delaware</option>
<option value="Florida">Florida</option>
<option value="Georgia">Georgia</option>
<option value="Hawaii">Hawaii</option>
<option value="Idaho">Idaho</option>
<option value="Illinois">Illinois</option>
<option value="Indiana">Indiana</option>
<option value="Iowa">Iowa</option>
<option value="Kansas">Kansas</option>
<option value="Kentucky">Kentucky</option>
<option value="Louisiana">Louisiana</option>
<option value="Maine">Maine</option>
<option value="Maryland">Maryland</option>
<option value="Massachusetts">Massachusetts</option>
<option value="Michigan">Michigan</option>
<option value="Minnesota">Minnesota</option>
<option value="Mississippi">Mississippi</option>
<option value="Missouri">Missouri</option>
<option value="Montana">Montana</option>
<option value="Nebraska">Nebraska</option>
<option value="Nevada">Nevada</option>
<option value="New Hampshire">New Hampshire</option>
<option value="New Jersey">New Jersey</option>
<option value="New Mexico">New Mexico</option>
<option value="New York">New York</option>
<option value="North Carolina">North Carolina</option>
<option value="North Dakota">North Dakota</option>
<option value="Ohio">Ohio</option>
<option value="Oklahoma">Oklahoma</option>
<option value="Oregon">Oregon</option>
<option value="Pennsylvania">Pennsylvania</option>
<option value="Rhode Island">Rhode Island</option>
<option value="South Carolina">South Carolina</option>
<option value="South Dakota">South Dakota</option>
<option value="Tennessee">Tennessee</option>
<option value="Texas">Texas</option>
<option value="Utah">Utah</option>
<option value="Vermont">Vermont</option>
<option value="Virginia">Virginia</option>
<option value="Washington">Washington</option>
<option value="West Virginia">West Virginia</option>
<option value="Wisconsin">Wisconsin</option>
<option value="Wyoming">Wyoming</option>
<option value="">-- CANADA --</option>
<option value="Alberta">Alberta</option>
<option value="British Columbia">British Columbia</option>
<option value="Manitoba">Manitoba</option>
<option value="New Brunswick">New Brunswick</option>
<option value="Newfoundland and Labrador">Newfoundland and Labrador</option>
<option value="Northwest Territories">Northwest Territories</option>
<option value="Nova Scotia">Nova Scotia</option>
<option value="Nunavut">Nunavut</option>
<option value="Ontario">Ontario</option>
<option value="Prince Edward Island">Prince Edward Island</option>
<option value="Quebec">Quebec</option>
<option value="Saskatchewan">Saskatchewan</option>
<option value="Yukon Territory">Yukon Territory</option>
<option value="">-- AUSTRALIA --</option>
<option value="Australian Capital Territory">Australian Capital Territory</option>
<option value="New South Wales">New South Wales</option>
<option value="Northern Territory">Northern Territory</option>
<option value="Queensland">Queensland</option>
<option value="South Australia">South Australia</option>
<option value="Tasmania">Tasmania</option>
<option value="Victoria">Victoria</option>
<option value="Western Australia">Western Australia</option>
</select>
</td>
</tr>
  <tr>
  </tr>
  <tr>
  </tr>
  <tr>
  </tr>
  <tr>
  </tr>
  <tr>
  </tr>
  </tr>
  <tr>
  </tr>
  <tr>
  </tr>
  <tr>
  </tr>
  <tr>
  </tr>
  <tr>
  </tr>
  <tr>
    <td width=150>Item: <br>
     </td>
    <td width=15>Quantity: <br>
     </td>
  </tr>
  <tr>
    <td>CD</td>
    <td><input class="textInput" type="text" name="qtycd_0001" id="qtycd_0001" value = "1" size="30" maxlength="7"></td>
  </tr>
  <tr>
  </tr>
  <tr>
  </tr>
  <tr>
  </tr>
  <tr>
  </tr>
  <tr>
  </tr>
  <tr>
  </tr>
  <tr>
  </tr>
  <tr>
  </tr>
  <tr>
  </tr>
  <tr>
  </tr>
  <tr>
  <td>Please enter a discount code if you have one: </td>
  <td><input class="textInput" type="text" name="sd_0001" value="000-000-00000" size="30" maxlength="64"></td>
  </tr>
  <tr style="text-align: center;">
  <td style="text-align: center;">
  <input style="text-align: Center;" type = "submit" value="Go To Next Page">
  </td>
  </tr>

</table>
<!--</legend>
</fieldset>-->
</center>

</form>

<script type="text/javascript">
// Initialize the input highlight script
initInputHighlightScript();
</script>

</body>
</html><?php
      }
      function ProcessForm($values)
      {
      //mail('$adminemail', 'Form test', $values['text'], "From: \"{$values['f_name0001']}\" <{$values['email']}>");
      //echo "<script>document.location = \"page2.php\";</script>\n";
      echo '<META HTTP-EQUIV="Refresh" Content="0; URL=page2.php">';
      }
      if ($_SERVER['REQUEST_METHOD'] == 'POST')
      {
      $formValues = $_POST;
      $formErrors = array();
      if (!(VerifyForm($formValues, $formErrors))){ //|| !(array_key_exists('f_name0001', $formValues))){
      DisplayForm($formValues, $formErrors);
      }else{
      ProcessForm($formValues);
      }
      }else{
      DisplayForm(null, null);
      }
      ?>

 

here to prevent it from deleting a discount code from the discount file if the user entered one, but forgot to fill in correctly ANY of the input boxes:

 

<?php
      }
      function ProcessForm($values)
      {
      //mail('$adminemail', 'Form test', $values['text'], "From: \"{$values['f_name0001']}\" <{$values['email']}>");
      //echo "<script>document.location = \"page2.php\";</script>\n";
      require('taxheader.php');
      echo '<META HTTP-EQUIV="Refresh" Content="0; URL=page2.php">';
      }
      if ($_SERVER['REQUEST_METHOD'] == 'POST')
      {
      $formValues = $_POST;
      $formErrors = array();
      if (!(VerifyForm($formValues, $formErrors))){ //|| !(array_key_exists('f_name0001', $formValues))){
      DisplayForm($formValues, $formErrors);
      }else{
      ProcessForm($formValues);
      }
      }else{
      DisplayForm(null, null);
      }
      ?>

Link to comment
Share on other sites

it ALMOST worked.

 

now im having a problem where its not sending $_SESSION['hasadiscount'] to page2.php

 

here's what it outputs:

 

My coupon: 000-000-00000
Has discount:
Print pur po total: $14.59
Print pur po total 2: $13.13 

 

orderform.php:

 

<?php
session_start();
require('taxheader.php');
require('sessionvars.php');
?>
      <?php

function spamcheck($field)
  {
  //filter_var() sanitizes the e-mail
  //address using FILTER_SANITIZE_EMAIL
  $field=filter_var($field, FILTER_SANITIZE_EMAIL);

  //filter_var() validates the e-mail
  //address using FILTER_VALIDATE_EMAIL
  if(filter_var($field, FILTER_VALIDATE_EMAIL))
    {
    return TRUE;
    }
  else
    {
    return FALSE;
    }
  }

      function VerifyForm(&$values, &$errors)
      {
      // Do all necessary form verification

      if (strlen($values['f_name0001']) < 3){
      $errors['f_name0001'] = '* First name too short';
      }else if (strlen($values['f_name0001']) > 50){
      $errors['f_name0001'] = '* First name too long';
      }
      if ($values['f_name0001'] == ''){
      $errors['f_name0001'] = '* Please fill in your first name';
      }

      if (strlen($values['l_name0001']) < 3){
      $errors['l_name0001'] = '* Last name too short';
      }else if (strlen($values['l_name0001']) > 50){
      $errors['l_name0001'] = '* Last name too long';
      }
      if (htmlentities($values['l_name0001']) == ''){
      $errors['l_name0001'] = '* Please fill in your last name';
      }

      if (htmlentities($values['ad_0001']) == ''){
      $errors['ad_0001'] = '* Please fill in your address';
      }

      if (htmlentities($values['co_0001']) == ''){
      $errors['co_0001'] = ' * Please fill in your country';
      }

      if(htmlentities($values['c_0001']) == ''){
      $errors['c_0001'] = ' * Please fill in your city';
      }

      if (htmlentities($values['stateSelect']) == ''){
      $errors['stateSelect'] = '* Please fill in your state';
      }

      if (!ctype_digit($values['qtycd_0001'])) {
      $errors['qtycd_0001'] = ' * '.$values['qtycd_0001'].' is an invalid amount';
      }

/*      if (!(spamcheck($values['email']))){
      $errors['email'] = '* Email address invalid';
       }

      if(strlen($values['email']) == 0){
      $errors['email'] = '* Please fill in your email';
       }

      if (strlen($values['text']) == 0)
      $errors['text'] = '* Text required';*/

      if (count($errors) > 0)
      {
      return false;
      }

      return true;

      }

      function DisplayForm($values, $errors)
      {
      ?><html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Image Poseidon</title>
<LINK href="style.css" rel="stylesheet" type="text/css">
</head>
<body>

      <?php
      if (count($errors) > 0){
      $fontstart = "<font color=\"#FF0000\">";
      $fontend = "</font>";
      if(count($errors) > 1){echo "<p>".$fontstart."* There were ".count($errors)." errors in your submitted form, please correct them and try again.".$fontend."</p>"."\n";}
      if(count($errors) == 1){echo "<p>".$fontstart."* There is ".count($errors)." error in your submitted form, please correct it and try again.".$fontend."</p>"."\n";}
      ?>
      <tr>
      <?php if($errors['f_name0001'] != ''){ ?><td class="error"><?= $fontstart.$errors['f_name0001'].$fontend ?></td><br><?php } ?>
      <?php if($errors['l_name0001'] != ''){?><td class="error"><?= $fontstart.$errors['l_name0001'].$fontend ?></td><br><?php } ?>
      <?php if($errors['ad_0001'] != ''){?><td class="error"><?= $fontstart.$errors['ad_0001'].$fontend ?></td><br><?php } ?>
      <?php if($errors['co_0001'] != ''){?><td class="error"><?= $fontstart.$errors['co_0001'].$fontend ?></td><br><?php } ?>
      <?php if($errors['c_0001'] != ''){?><td class="error"><?= $fontstart.$errors['c_0001'].$fontend ?></td><br><?php } ?>
      <?php if($errors['stateSelect'] != ''){?><td class="error"><?= $fontstart.$errors['stateSelect'].$fontend ?></td><br><?php } ?>
      <?php if($errors['qtycd_0001'] != ''){?><td class="error"><?= $fontstart.$errors['qtycd_0001'].$fontend ?></td><br><?php } ?>
      </tr>
      <?php
      }
      ?>

<script type="text/javascript" src="js/highlight-active-input.js"></script>

<?php
require('header.php');
?>

<form action="Orderform.php" method="post">

<center>
<!--<fieldset>
<legend>Image Poseidon Order Form</legend>
-->
<table>
  <tr>
    <td><label for="fname_0001">First Name: </label></td>
    <td><input class="textInput" type="text" name="f_name0001" maxlength="30" id="f_name0001" size="30" /></td>
  </tr>
  <tr>
    <td><label for="lname_0001">Last Name: </label></td>
    <td><input class="textInput" type="text" name="l_name0001" maxlength="30" id="l_name0001" size="30"  /></td>
  </tr>
  <tr>
    <td><label for="a_d0001">Shipping Address: </label></td>
    <td><input class="textInput" type="text" name="ad_0001" maxlength="128" id="ad_0001" size="30"  /></td>
  </tr>
  <tr>
    <td>Country: </td>
    <td><select onfocus="this.style.backgroundColor='#4D6DF3';" onblur="this.style.backgroundColor='';" class="textInput" id='countrySelect' name='co_0001' style="width: 209px;">
<option value="">Choose Country</option>
<option value="Afganistan">Afghanistan</option>
<option value="Albania">Albania</option>
<option value="Algeria">Algeria</option>
<option value="American Samoa">American Samoa</option>
<option value="Andorra">Andorra</option>
<option value="Angola">Angola</option>
<option value="Anguilla">Anguilla</option>
<option value="Antigua & Barbuda">Antigua & Barbuda</option>
<option value="Argentina">Argentina</option>
<option value="Armenia">Armenia</option>
<option value="Aruba">Aruba</option>
<option value="Australia">Australia</option>
<option value="Austria">Austria</option>
<option value="Azerbaijan">Azerbaijan</option>
<option value="Bahamas">Bahamas</option>
<option value="Bahrain">Bahrain</option>
<option value="Bangladesh">Bangladesh</option>
<option value="Barbados">Barbados</option>
<option value="Belarus">Belarus</option>
<option value="Belgium">Belgium</option>
<option value="Belize">Belize</option>
<option value="Benin">Benin</option>
<option value="Bermuda">Bermuda</option>
<option value="Bhutan">Bhutan</option>
<option value="Bolivia">Bolivia</option>
<option value="Bonaire">Bonaire</option>
<option value="Bosnia & Herzegovina">Bosnia & Herzegovina</option>
<option value="Botswana">Botswana</option>
<option value="Brazil">Brazil</option>
<option value="British Indian Ocean Ter">British Indian Ocean Ter</option>
<option value="Brunei">Brunei</option>
<option value="Bulgaria">Bulgaria</option>
<option value="Burkina Faso">Burkina Faso</option>
<option value="Burundi">Burundi</option>
<option value="Cambodia">Cambodia</option>
<option value="Cameroon">Cameroon</option>
<option value="Canada">Canada</option>
<option value="Canary Islands">Canary Islands</option>
<option value="Cape Verde">Cape Verde</option>
<option value="Cayman Islands">Cayman Islands</option>
<option value="Central African Republic">Central African Republic</option>
<option value="Chad">Chad</option>
<option value="Channel Islands">Channel Islands</option>
<option value="Chile">Chile</option>
<option value="China">China</option>
<option value="Christmas Island">Christmas Island</option>
<option value="Cocos Island">Cocos Island</option>
<option value="Colombia">Colombia</option>
<option value="Comoros">Comoros</option>
<option value="Congo">Congo</option>
<option value="Cook Islands">Cook Islands</option>
<option value="Costa Rica">Costa Rica</option>
<option value="Cote DIvoire">Cote D'Ivoire</option>
<option value="Croatia">Croatia</option>
<option value="Cuba">Cuba</option>
<option value="Curaco">Curacao</option>
<option value="Cyprus">Cyprus</option>
<option value="Czech Republic">Czech Republic</option>
<option value="Denmark">Denmark</option>
<option value="Djibouti">Djibouti</option>
<option value="Dominica">Dominica</option>
<option value="Dominican Republic">Dominican Republic</option>
<option value="East Timor">East Timor</option>
<option value="Ecuador">Ecuador</option>
<option value="Egypt">Egypt</option>
<option value="El Salvador">El Salvador</option>
<option value="Equatorial Guinea">Equatorial Guinea</option>
<option value="Eritrea">Eritrea</option>
<option value="Estonia">Estonia</option>
<option value="Ethiopia">Ethiopia</option>
<option value="Falkland Islands">Falkland Islands</option>
<option value="Faroe Islands">Faroe Islands</option>
<option value="Fiji">Fiji</option>
<option value="Finland">Finland</option>
<option value="France">France</option>
<option value="French Guiana">French Guiana</option>
<option value="French Polynesia">French Polynesia</option>
<option value="French Southern Ter">French Southern Ter</option>
<option value="Gabon">Gabon</option>
<option value="Gambia">Gambia</option>
<option value="Georgia">Georgia</option>
<option value="Germany">Germany</option>
<option value="Ghana">Ghana</option>
<option value="Gibraltar">Gibraltar</option>
<option value="Great Britain">Great Britain</option>
<option value="Greece">Greece</option>
<option value="Greenland">Greenland</option>
<option value="Grenada">Grenada</option>
<option value="Guadeloupe">Guadeloupe</option>
<option value="Guam">Guam</option>
<option value="Guatemala">Guatemala</option>
<option value="Guinea">Guinea</option>
<option value="Guyana">Guyana</option>
<option value="Haiti">Haiti</option>
<option value="Hawaii">Hawaii</option>
<option value="Honduras">Honduras</option>
<option value="Hong Kong">Hong Kong</option>
<option value="Hungary">Hungary</option>
<option value="Iceland">Iceland</option>
<option value="India">India</option>
<option value="Indonesia">Indonesia</option>
<option value="Iran">Iran</option>
<option value="Iraq">Iraq</option>
<option value="Ireland">Ireland</option>
<option value="Isle of Man">Isle of Man</option>
<option value="Israel">Israel</option>
<option value="Italy">Italy</option>
<option value="Jamaica">Jamaica</option>
<option value="Japan">Japan</option>
<option value="Jordan">Jordan</option>
<option value="Kazakhstan">Kazakhstan</option>
<option value="Kenya">Kenya</option>
<option value="Kiribati">Kiribati</option>
<option value="Korea North">Korea North</option>
<option value="Korea Sout">Korea South</option>
<option value="Kuwait">Kuwait</option>
<option value="Kyrgyzstan">Kyrgyzstan</option>
<option value="Laos">Laos</option>
<option value="Latvia">Latvia</option>
<option value="Lebanon">Lebanon</option>
<option value="Lesotho">Lesotho</option>
<option value="Liberia">Liberia</option>
<option value="Libya">Libya</option>
<option value="Liechtenstein">Liechtenstein</option>
<option value="Lithuania">Lithuania</option>
<option value="Luxembourg">Luxembourg</option>
<option value="Macau">Macau</option>
<option value="Macedonia">Macedonia</option>
<option value="Madagascar">Madagascar</option>
<option value="Malaysia">Malaysia</option>
<option value="Malawi">Malawi</option>
<option value="Maldives">Maldives</option>
<option value="Mali">Mali</option>
<option value="Malta">Malta</option>
<option value="Marshall Islands">Marshall Islands</option>
<option value="Martinique">Martinique</option>
<option value="Mauritania">Mauritania</option>
<option value="Mauritius">Mauritius</option>
<option value="Mayotte">Mayotte</option>
<option value="Mexico">Mexico</option>
<option value="Midway Islands">Midway Islands</option>
<option value="Moldova">Moldova</option>
<option value="Monaco">Monaco</option>
<option value="Mongolia">Mongolia</option>
<option value="Montserrat">Montserrat</option>
<option value="Morocco">Morocco</option>
<option value="Mozambique">Mozambique</option>
<option value="Myanmar">Myanmar</option>
<option value="Nambia">Nambia</option>
<option value="Nauru">Nauru</option>
<option value="Nepal">Nepal</option>
<option value="Netherland Antilles">Netherland Antilles</option>
<option value="Netherlands">Netherlands (Holland, Europe)</option>
<option value="Nevis">Nevis</option>
<option value="New Caledonia">New Caledonia</option>
<option value="New Zealand">New Zealand</option>
<option value="Nicaragua">Nicaragua</option>
<option value="Niger">Niger</option>
<option value="Nigeria">Nigeria</option>
<option value="Niue">Niue</option>
<option value="Norfolk Island">Norfolk Island</option>
<option value="Norway">Norway</option>
<option value="Oman">Oman</option>
<option value="Pakistan">Pakistan</option>
<option value="Palau Island">Palau Island</option>
<option value="Palestine">Palestine</option>
<option value="Panama">Panama</option>
<option value="Papua New Guinea">Papua New Guinea</option>
<option value="Paraguay">Paraguay</option>
<option value="Peru">Peru</option>
<option value="Phillipines">Philippines</option>
<option value="Pitcairn Island">Pitcairn Island</option>
<option value="Poland">Poland</option>
<option value="Portugal">Portugal</option>
<option value="Puerto Rico">Puerto Rico</option>
<option value="Qatar">Qatar</option>
<option value="Republic of Montenegro">Republic of Montenegro</option>
<option value="Republic of Serbia">Republic of Serbia</option>
<option value="Reunion">Reunion</option>
<option value="Romania">Romania</option>
<option value="Russia">Russia</option>
<option value="Rwanda">Rwanda</option>
<option value="St Barthelemy">St Barthelemy</option>
<option value="St Eustatius">St Eustatius</option>
<option value="St Helena">St Helena</option>
<option value="St Kitts-Nevis">St Kitts-Nevis</option>
<option value="St Lucia">St Lucia</option>
<option value="St Maarten">St Maarten</option>
<option value="St Pierre & Miquelon">St Pierre & Miquelon</option>
<option value="St Vincent & Grenadines">St Vincent & Grenadines</option>
<option value="Saipan">Saipan</option>
<option value="Samoa">Samoa</option>
<option value="Samoa American">Samoa American</option>
<option value="San Marino">San Marino</option>
<option value="Sao Tome & Principe">Sao Tome & Principe</option>
<option value="Saudi Arabia">Saudi Arabia</option>
<option value="Senegal">Senegal</option>
<option value="Seychelles">Seychelles</option>
<option value="Sierra Leone">Sierra Leone</option>
<option value="Singapore">Singapore</option>
<option value="Slovakia">Slovakia</option>
<option value="Slovenia">Slovenia</option>
<option value="Solomon Islands">Solomon Islands</option>
<option value="Somalia">Somalia</option>
<option value="South Africa">South Africa</option>
<option value="Spain">Spain</option>
<option value="Sri Lanka">Sri Lanka</option>
<option value="Sudan">Sudan</option>
<option value="Suriname">Suriname</option>
<option value="Swaziland">Swaziland</option>
<option value="Sweden">Sweden</option>
<option value="Switzerland">Switzerland</option>
<option value="Syria">Syria</option>
<option value="Tahiti">Tahiti</option>
<option value="Taiwan">Taiwan</option>
<option value="Tajikistan">Tajikistan</option>
<option value="Tanzania">Tanzania</option>
<option value="Thailand">Thailand</option>
<option value="Togo">Togo</option>
<option value="Tokelau">Tokelau</option>
<option value="Tonga">Tonga</option>
<option value="Trinidad & Tobago">Trinidad & Tobago</option>
<option value="Tunisia">Tunisia</option>
<option value="Turkey">Turkey</option>
<option value="Turkmenistan">Turkmenistan</option>
<option value="Turks & Caicos Is">Turks & Caicos Is</option>
<option value="Tuvalu">Tuvalu</option>
<option value="Uganda">Uganda</option>
<option value="Ukraine">Ukraine</option>
<option value="United Arab Erimates">United Arab Emirates</option>
<option value="United Kingdom">United Kingdom</option>
<option value="United States of America">United States of America</option>
<option value="Uraguay">Uruguay</option>
<option value="Uzbekistan">Uzbekistan</option>
<option value="Vanuatu">Vanuatu</option>
<option value="Vatican City State">Vatican City State</option>
<option value="Venezuela">Venezuela</option>
<option value="Vietnam">Vietnam</option>
<option value="Virgin Islands (Brit)">Virgin Islands (Brit)</option>
<option value="Virgin Islands (USA)">Virgin Islands (USA)</option>
<option value="Wake Island">Wake Island</option>
<option value="Wallis & Futana Is">Wallis & Futana Is</option>
<option value="Yemen">Yemen</option>
<option value="Zaire">Zaire</option>
<option value="Zambia">Zambia</option>
<option value="Zimbabwe">Zimbabwe</option>
</select>

  </tr>

  <tr>
    <td><label for="c0001">City: </label></td>
    <td><input class="textInput" type="text" name="c_0001" maxlength="30" id="c_0001"  size="30"  /></td>
  </tr>
<br><br>
<tr>
<td>State: </td>
<td>
<select onfocus="this.style.backgroundColor='#4D6DF3';" onblur="this.style.backgroundColor='';" class="textInput" name="stateSelect" id="stateSelect" style="width: 209px;">
<option selected value="">Choose State</option>
<option value="">-- UNITED STATES --</option>
<option value="Alabama">Alabama</option>
<option value="Alaska">Alaska</option>
<option value="Arizona">Arizona</option>
<option value="Arkansas">Arkansas</option>
<option value="California">California</option>
<option value="Colorado">Colorado</option>
<option value="Connecticut">Connecticut</option>
<option value="Delaware">Delaware</option>
<option value="Florida">Florida</option>
<option value="Georgia">Georgia</option>
<option value="Hawaii">Hawaii</option>
<option value="Idaho">Idaho</option>
<option value="Illinois">Illinois</option>
<option value="Indiana">Indiana</option>
<option value="Iowa">Iowa</option>
<option value="Kansas">Kansas</option>
<option value="Kentucky">Kentucky</option>
<option value="Louisiana">Louisiana</option>
<option value="Maine">Maine</option>
<option value="Maryland">Maryland</option>
<option value="Massachusetts">Massachusetts</option>
<option value="Michigan">Michigan</option>
<option value="Minnesota">Minnesota</option>
<option value="Mississippi">Mississippi</option>
<option value="Missouri">Missouri</option>
<option value="Montana">Montana</option>
<option value="Nebraska">Nebraska</option>
<option value="Nevada">Nevada</option>
<option value="New Hampshire">New Hampshire</option>
<option value="New Jersey">New Jersey</option>
<option value="New Mexico">New Mexico</option>
<option value="New York">New York</option>
<option value="North Carolina">North Carolina</option>
<option value="North Dakota">North Dakota</option>
<option value="Ohio">Ohio</option>
<option value="Oklahoma">Oklahoma</option>
<option value="Oregon">Oregon</option>
<option value="Pennsylvania">Pennsylvania</option>
<option value="Rhode Island">Rhode Island</option>
<option value="South Carolina">South Carolina</option>
<option value="South Dakota">South Dakota</option>
<option value="Tennessee">Tennessee</option>
<option value="Texas">Texas</option>
<option value="Utah">Utah</option>
<option value="Vermont">Vermont</option>
<option value="Virginia">Virginia</option>
<option value="Washington">Washington</option>
<option value="West Virginia">West Virginia</option>
<option value="Wisconsin">Wisconsin</option>
<option value="Wyoming">Wyoming</option>
<option value="">-- CANADA --</option>
<option value="Alberta">Alberta</option>
<option value="British Columbia">British Columbia</option>
<option value="Manitoba">Manitoba</option>
<option value="New Brunswick">New Brunswick</option>
<option value="Newfoundland and Labrador">Newfoundland and Labrador</option>
<option value="Northwest Territories">Northwest Territories</option>
<option value="Nova Scotia">Nova Scotia</option>
<option value="Nunavut">Nunavut</option>
<option value="Ontario">Ontario</option>
<option value="Prince Edward Island">Prince Edward Island</option>
<option value="Quebec">Quebec</option>
<option value="Saskatchewan">Saskatchewan</option>
<option value="Yukon Territory">Yukon Territory</option>
<option value="">-- AUSTRALIA --</option>
<option value="Australian Capital Territory">Australian Capital Territory</option>
<option value="New South Wales">New South Wales</option>
<option value="Northern Territory">Northern Territory</option>
<option value="Queensland">Queensland</option>
<option value="South Australia">South Australia</option>
<option value="Tasmania">Tasmania</option>
<option value="Victoria">Victoria</option>
<option value="Western Australia">Western Australia</option>
</select>
</td>
</tr>
  <tr>
  </tr>
  <tr>
  </tr>
  <tr>
  </tr>
  <tr>
  </tr>
  <tr>
  </tr>
  </tr>
  <tr>
  </tr>
  <tr>
  </tr>
  <tr>
  </tr>
  <tr>
  </tr>
  <tr>
  </tr>
  <tr>
    <td width=150>Item: <br>
     </td>
    <td width=15>Quantity: <br>
     </td>
  </tr>
  <tr>
    <td>CD</td>
    <td><input class="textInput" type="text" name="qtycd_0001" id="qtycd_0001" value = "1" size="30" maxlength="7"></td>
  </tr>
  <tr>
  </tr>
  <tr>
  </tr>
  <tr>
  </tr>
  <tr>
  </tr>
  <tr>
  </tr>
  <tr>
  </tr>
  <tr>
  </tr>
  <tr>
  </tr>
  <tr>
  </tr>
  <tr>
  </tr>
  <tr>
  <td>Please enter a discount code if you have one: </td>
  <td><input class="textInput" type="text" name="sd_0001" value="000-000-00000" size="30" maxlength="64"></td>
  </tr>
  <tr style="text-align: center;">
  <td style="text-align: center;">
  <input style="text-align: Center;" type = "submit" value="Go To Next Page">
  </td>
  </tr>

</table>
<!--</legend>
</fieldset>-->
</center>

</form>

<script type="text/javascript">
// Initialize the input highlight script
initInputHighlightScript();
</script>

</body>
</html><?php
      }
      function ProcessForm($values)
      {
      //mail('$adminemail', 'Form test', $values['text'], "From: \"{$values['f_name0001']}\" <{$values['email']}>");
      //echo "<script>document.location = \"page2.php\";</script>\n";
      echo '<META HTTP-EQUIV="Refresh" Content="0; URL=page2.php">';
      }
      if ($_SERVER['REQUEST_METHOD'] == 'POST')
      {
      $formValues = $_POST;
      $formErrors = array();
      if (!(VerifyForm($formValues, $formErrors))){
//      require('taxfooter.php');
      DisplayForm($formValues, $formErrors);
      }else{
      ProcessForm($formValues);
      }
      }else{
      DisplayForm(null, null);
      }
      ?>

 

sessionvars.php:

 

    <?php
          echo "My coupon: ".$myCoupon."\n<br>\n"."Has discount: ".$hasdiscount."\n<br>\n"."Print pur po total: ".$print_pur_po_total."\n<br>\n"."Print pur po total 2: ".$print_pur_po_total2."\n<br>\n";
          if(isset($_POST['f_name0001'])){$_SESSION['f_name0001'] = $_POST['f_name0001'];}
          if(isset($_POST['l_name0001'])){$_SESSION['l_name0001'] = $_POST['l_name0001'];}
          if(isset($_POST['ad_0001'])){$_SESSION['ad_0001'] = $_POST['ad_0001'];}
          if(isset($_POST['co_0001'])){$_SESSION['co_0001'] = $_POST['co_0001'];}
          if(isset($_POST['c_0001'])){$_SESSION['c_0001'] = $_POST['c_0001'];}
          if(isset($_POST['stateSelect'])){$_SESSION['stateSelect'] = $_POST['stateSelect'];}
          if(isset($_POST['qtycd_0001'])){$_SESSION['qtycd_0001'] = $_POST['qtycd_0001'];}
         // no need to check the known variable from here on
         $_SESSION['customercouponcode'] = $myCoupon;
         $_SESSION['hasadiscount'] = $hasdiscount;
         $_SESSION['istotal'] = $print_pur_po_total;
         $_SESSION['isdiscounttotal'] = $print_pur_po_total2;
   ?>

 

taxheader.php:

 

<?php

$itemprice = 12;
$taxrate = 7;
$shipping = 1.75;
$discountrate = .90;
$qtycd = $_POST['qtycd_0001'];
$Subtotal = $itemprice;
$Tax = round( ($itemprice * $taxrate / 100 ), 2);
$Total = (($Tax + $Subtotal)*$qtycd)+($shipping*$qtycd);
$DiscountTotal = $Total*$discountrate; //round($Total*($discountrate), 2);

$coupons = file('Vm1wS01HRXhVWGxWYmxKV1lrZG9VRlpyVmt0WGJGSllZM3BHVG1KSFVubFhhMXByWWtkR05sSnJXbFpXYldoeVZrZDRWMDVzV2xsYVIwWlhWakpvVkZaVldrWlBWa0pTVUZRd1BRPT0=.txt', FILE_SKIP_EMPTY_LINES);
$coupons = array_map('trim', $coupons);
$myCoupon = $_POST['sd_0001'];
$hasdiscount = false;

// if found return the position in the array as $key

if(($key = array_search($myCoupon, $coupons)) !== false) {
$hasdiscount = true;
// delete the coupon from the array using $key
unset($coupons[$key]);
file_put_contents('Vm1wS01HRXhVWGxWYmxKV1lrZG9VRlpyVmt0WGJGSllZM3BHVG1KSFVubFhhMXByWWtkR05sSnJXbFpXYldoeVZrZDRWMDVzV2xsYVIwWlhWakpvVkZaVldrWlBWa0pTVUZRd1BRPT0=.txt', implode("\r\n", $coupons));
}
else if(($key = array_search($myCoupon, $coupons)) == false) {
$hasdiscount = false;
}

$number = $Total;
$pur_item_total = $number;
$pur_po_total =  ($pur_po_total + $pur_item_total);
$print_pur_po_total = wims_currency($pur_po_total);

$number2 = $DiscountTotal;
$pur_item_total2 = $number2;
$pur_po_total2 =  ($pur_po_total2 + $pur_item_total2);
$print_pur_po_total2 = wims_currency2($pur_po_total2);

function wims_currency($number) {
   if ($number < 0) {
     $print_number = "($" . str_replace('-', '', number_format ($number, 2, ".", ",")) . ")";
    } else {
     $print_number = "$" .  number_format ($number, 2, ".", ",") ;
   }
   return $print_number;
}

function wims_currency2($number2) {
   if ($number2 < 0) {
     $print_number2 = "($" . str_replace('-', '', number_format ($number2, 2, ".", ",")) . ")";
    } else {
     $print_number2 = "$" .  number_format ($number2, 2, ".", ",") ;
   }
   return $print_number2;
}

?>

 

page2.php:

 

<?php
session_start();
?>
<?php
require('header.php');
?><html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Image Poseidon</title>
</head>

<body>
<LINK href="style.css" rel="stylesheet" type="text/css">

<script src="view_printable.js"></script>
<script src="mainscripts.js"></script>

<center>
<a href="#" onclick="javascript:view_printable();">Click For Printable Page</a><br>
</center>

<center>
<h2>This is your order so far: </h2>
</center>

<FORM name="f0001" id="f0001" ACTION="processorder.php" method=post>

<center>

<?php

echo "$"."_SESSION['customercouponcode']=".$_SESSION['customercouponcode']."<br>\n";
echo "$"."_SESSION['hasadiscount']=".$_SESSION['hasadiscount']."<br>\n";
echo "$"."_SESSION['istotal']=".$_SESSION['istotal']."<br>\n";
echo "$"."_SESSION['isdiscount']=".$_SESSION['isdiscounttotal']."<br>\n";
echo "$"."myCoupon=".$myCoupon."<br>\n";
echo "$"."hasdiscount=".$hasdiscount."<br>\n";
echo "$"."print_pur_po_total=".$print_pur_po_total."<br>\n";
echo "$"."print_pur_po_total=".$print_pur_po_total2."<br>\n";
echo "<br><br>\n";
echo "Name: <b><u>".$_SESSION['f_name0001']." ".$_SESSION['l_name0001']."</u></b><br>\n"
."Address: <b><u>".$_SESSION['ad_0001']."</u></b><br>\n"
."Country: <b><u>".$_SESSION['co_0001']."</u></b><br>\n"
."City: <b><u>".$_SESSION['c_0001']."</u></b><br>\n"
."State/Province: <b><u>".$_SESSION['stateSelect']."</u></b><br>\n"
."Amount of CD(s) you want to purchase: <b><u>".$_SESSION['qtycd_0001']."</u></b><br>\n";

if($_SESSION['hasadiscount'] == true){echo "Your coupon code: <b><u>".$_SESSION['customercouponcode']."</u></b><br><br>\n";}

echo "<img src=\"gradient_grey3596386127_footer-iaza.png\"></img><br>\n";

echo "session: ".$_SESSION['hasadiscount'];

if($_SESSION['hasadiscount'] == true){

echo "<br>Original Total: <br><br>\n"
."<b>".$_SESSION['istotal']."-"."10%"."</b>"."<br>\n"
."<br>Your total: <br><br>\n"
."<b>".$_SESSION['isdiscounttotal']."</b><br>\n";

}else if($_SESSION['hasadiscount'] == false){

echo "<br>Your Total: <br><br>\n"
."<b>".$_SESSION['istotal']."</b><br>\n";

}

echo "<br>\n";

echo "<img src=\"gradient_grey3596386127-iaza.png\"></img>\n";

?>

<br>

<a href="#" onclick="javascript:view_printable();">Click For Printable Page</a><br><br>

<input name="subt1" id="subt1" type="submit" value="Submit" onclick="FormControl(1);">

</center>

</form>

</body>

</html>

Link to comment
Share on other sites

this is what it outputs:

 

$key=
session: Array
$_SESSION['customercouponcode']=Vm1wS01HRXhVWGxWYmxKV1lrZG9VRlpyVmt0WGJGSllZM3BHVG1KSFVubFhhMXBy
$_SESSION['hasadiscount']=
$_SESSION['istotal']=$14.59
$_SESSION['isdiscount']=$13.13
$myCoupon=Vm1wS01HRXhVWGxWYmxKV1lrZG9VRlpyVmt0WGJGSllZM3BHVG1KSFVubFhhMXBy
$hasdiscount=
$print_pur_po_total=$14.59
$print_pur_po_total=$13.13

Link to comment
Share on other sites

this is what it outputs:

 

$key=
session: Array
$_SESSION['customercouponcode']=Vm1wS01HRXhVWGxWYmxKV1lrZG9VRlpyVmt0WGJGSllZM3BHVG1KSFVubFhhMXBy
$_SESSION['hasadiscount']=
$_SESSION['istotal']=$14.59
$_SESSION['isdiscount']=$13.13
$myCoupon=Vm1wS01HRXhVWGxWYmxKV1lrZG9VRlpyVmt0WGJGSllZM3BHVG1KSFVubFhhMXBy
$hasdiscount=
$print_pur_po_total=$14.59
$print_pur_po_total=$13.13

Link to comment
Share on other sites

it outputs:

 

$_SESSION['customercouponcode']=000-000-00000
$_SESSION['hasadiscount']=
$_SESSION['istotal']=$14.59
$_SESSION['isdiscount']=$13.13
$myCoupon=
$hasdiscount=
$print_pur_po_total=
$print_pur_po_total=

 

Is this an actual print_r of $_SESSION?

 

Usual output is something like

 

Array
(
    [test_var] => 1
    [text_var1] => testing
)

Link to comment
Share on other sites

print_r returns the SAME thing

 

$_SESSION['customercouponcode']=000-000-00000
$_SESSION['hasadiscount']=
$_SESSION['istotal']=$14.59
$_SESSION['isdiscount']=$13.13
$myCoupon=
$hasdiscount=
$print_pur_po_total=
$print_pur_po_total=

 

UNLESS u mean "session: ".print_r($_SESSION) which returns: session: array

Link to comment
Share on other sites

Ok I see where you're getting that output now.

 

Just do

print_r($_SESSION);

 

And it will print out the entire session array like I posted above.

 

Also in page2.php you are outputting undefined variables. sessionvars and taxheaders are not included, which are the files that define those variables, so any variables you output that aren't in the session will be null.

 

ex.

$myCoupon=
$hasdiscount=
$print_pur_po_total=
$print_pur_po_total=

 

will be blank because they are not defined.

Link to comment
Share on other sites

HOWEVER. var_dump returns this:

 

string(19) "session: Array
" string(50) "$_SESSION['customercouponcode']=000-000-00000
" string(31) "$_SESSION['hasadiscount']=
" string(32) "$_SESSION['istotal']=$14.59
" string(35) "$_SESSION['isdiscount']=$13.13
" string(28) "$myCoupon=000-000-00000
" string(18) "$hasdiscount=
" string(31) "$print_pur_po_total=$14.59
" string(31) "$print_pur_po_total=$13.13
" string(10) "$key=
" string(9) "

" 

Link to comment
Share on other sites

i got it to work.

 

here:

 

ALL the data i have so far:

 

$key=
session: Array
$_SESSION['customercouponcode']=000-000-00000
$_SESSION['hasadiscount']=
$_SESSION['istotal']=$14.59
$_SESSION['isdiscount']=$13.13
$myCoupon=000-000-00000
$hasdiscount=
$print_pur_po_total=$14.59
$print_pur_po_total=$13.13


Array ( [customercouponcode] => 000-000-00000 [hasadiscount] => [istotal] => $14.59 [isdiscounttotal] => $13.13 [f_name0001] => [l_name0001] => [ad_0001] => [co_0001] => [c_0001] => [qtycd_0001] => 1 ) $_SESSION['customercouponcode']=000-000-00000
$_SESSION['hasadiscount']=
$_SESSION['istotal']=$14.59
$_SESSION['isdiscount']=$13.13
$myCoupon=000-000-00000
$hasdiscount=
$print_pur_po_total=$14.59
$print_pur_po_total=$13.13
$key=


array(10) { ["customercouponcode"]=> string(13) "000-000-00000" ["hasadiscount"]=> bool(false) ["istotal"]=> string(6) "$14.59" ["isdiscounttotal"]=> string(6) "$13.13" ["f_name0001"]=> string(0) "" ["l_name0001"]=> string(0) "" ["ad_0001"]=> string(0) "" ["co_0001"]=> string(0) "" ["c_0001"]=> string(0) "" ["qtycd_0001"]=> string(1) "1" } string(50) "$_SESSION['customercouponcode']=000-000-00000
" string(31) "$_SESSION['hasadiscount']=
" string(32) "$_SESSION['istotal']=$14.59
" string(35) "$_SESSION['isdiscount']=$13.13
" string(28) "$myCoupon=000-000-00000
" string(18) "$hasdiscount=
" string(31) "$print_pur_po_total=$14.59
" string(31) "$print_pur_po_total=$13.13
" string(10) "$key=
" string(9) "

" 
* There were 6 errors in your submitted form, please correct them and try again.

* Please fill in your first name
* Please fill in your last name
* Please fill in your address
* Please fill in your country
* Please fill in your city
* Please fill in your state

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.