Jump to content

aebstract

Members
  • Posts

    1,105
  • Joined

  • Last visited

Posts posted by aebstract

  1. This shouldn't be that hard at all. I'll explain what you should be doing with a few examples and explanations. (why don't you try doing it with just one digit at first, when that is working, go ahead and add the other 5 in to the equation, as it seems each digit can run on its own piece of code). So let's just look at getting one digit to work:

     

    #1: 1

     

    T#: 3

     

    Subtract #1 from your target number. 3-1 = 2. Now you want to divide that by 2, getting 1. M1 and M2 can both equal 1.

     

     

    #1: 6

     

    T3: 3

     

    Subtract #1 from your target number. 3-6 = -3. Now you want to divide that by 2, getting -1.5. You want whole numbers, so round this number down to the nearest whole number, getting -1. Get your difference between -3 and -1, being -2 and you now have a M1 of -1 and a M2 of -2.

     

    The first solution seemed easier, though you need to go with the second solution if you want to be able to calculate every situation. If I understand correctly, this is what you are trying to do.. correct me if I am wrong, and second example has both negative and decimals to show that what needs to be done to make it all work correctly. Any questions or if you want some code examples just ask.

  2. Time for edits passed by time I typed this up, I am sorry for double posting but:

     

     

     

    ps: keep in mind, I am echoing the results of session [tempaddress] and it is displaying a 1 when the new address has been submitted, and a 0 when it is not submitted, though when it is displaying the 1.. it isn't showing the correct (new) address.

     

    Here is what the two differences in format look like:

     

    temp = 0

    301 East Cherry Street

    Clarksville, AR - 72830

     

     

    temp = 1

    301 East Cherry Street

    Clarksville, AR 72830

     

     

    Notice the - in the original, the second is formatted differently (not on purpose, but it does show that it is setting it by the rules we told it to go by, its just using the variables from the database...) I'm also entering in random wordings/numbers for this address, so it shouldn't be anywhere near the same.

  3. See the problem with all the help suggestions is, each thing you guys are saying to change, isn't the problem. Those are simply error message call outs. I'm not using elseif because that will stop whenever it hits a problem, and I want to display multiple problems. This works perfectly fine. The reason I posted the entire script is because a lot of times, I'll post the part that is important and people will tell me to post the entire code. Let me try and pinpoint the problematic areas though:

     

    if ($_GET['alternate'] == "change"){
    $result = mysql_query("SELECT * FROM plants WHERE id='$id'") or DIE(mysql_error());
    
    while($r=mysql_fetch_array($result))
    {
    
    $id=$r["id"];
    $plantloc=$r["plantloc"];
    $address=$r["address"];
    $ph=$r["PH"];
    
    
    }
    
    
    
    
    if (isset ($_POST['submit2']))
    {
    
    $problem = FALSE;
    
    
          if (empty ($_POST['street'])) {
    $problem = TRUE;
    $error .= 'Street is a required field. <br />';
          }
    
          if (empty ($_POST['city'])) {
    $problem = TRUE;
    $error .= 'City is a required field. <br />';
          }
    
          if (empty ($_POST['state'])) {
    $problem = TRUE;
    $error .= 'State is a required field. <br />';
          }
    
          if (empty ($_POST['zip'])) {
    $problem = TRUE;
    $error .= 'Zip is a required field. <br />';
          }
    
    
    
    
    
    if (!$problem) {
    
    $_SESSION['city'] = ucwords($_POST['city']);
    $_SESSION['state'] = strtoupper($_POST['state']);
    
    $_SESSION['zip'] = $_POST['zip'];
    $_SESSION['street'] = $_POST['street'];
    $_SESSION['tempaddress'] = 1;
    
                          header("Location: index.php?page=checkout");
    					exit;
    
    }
    
    }
    
    
    
    
    $content .= "
    <p><u><a href=\"index.php?page=accounthome\">$plantloc</a></u> - Alternate Address </p>
    
    <form action=\"index.php?page=checkout&alternate=change\" method=\"post\">
    Street:<br />
    <input type=\"text\" size=\"20\" name=\"street\" value=\"$_POST[street]\" /><br /><br />
    <table><tr><td>
    City:
    </td><td>
    State:
    </td><td>
    Zip:
    </td></tr>
    <tr><td>
    <input type=\"text\" size=\"10\" name=\"city\" value=\"$_POST[city]\" />
    </td><td>
    <input type=\"text\" size=\"2\" name=\"state\" value=\"$_POST[state]\" />
    </td><td>
    <input type=\"text\" size=\"5\" name=\"zip\" value=\"$_POST[zip]\" />
    </td></tr></table>
    <br />
    <input type=\"submit\" name=\"submit2\" class=\"textfield\" value=\"Submit Address\" />
    </form>
    ";
    
    
    
    
    }
    

     

    With the above code, if the variable is set in the url (which we are assuming it is) then the change address form will be presented for the user. Once submitted, they will still be at the page with that variable set and it will hit the if (isset(submit2)) part of the script and if there are no errors, it will set the sessions and throw them back to the normal checkout page (without the variable being set in the url).

     

    On the normal checkout page, we try to check if they set a new address, if they did we display it and if not we use the old address:

     

    if ($_SESSION['tempaddress'] == 1){
    $displayaddress = "
    $_SESSION[street]<br />
    $_SESSION[city], $_SESSION[state] $_SESSION[zip]<br />
    ";
    }
    
    
    if ($_SESSION['tempaddress'] == 1) {
    $address2 = $displayaddress;
    } else {
    $address2 = $address;
    }
    

     

     

    Maybe with pinpointing the exact portions of the code that this problem is persisting to, it'll be easier to read through and figure out the problem? Thanks!

  4. Still sets the $_SESSION['tempaddress'] to 1 but it isn't changing the other sessions:

    $_SESSION['city'] = ucwords($_POST['city']);

    $_SESSION['state'] = strtoupper($_POST['state']);

     

    $_SESSION['zip'] = $_POST['zip'];

    $_SESSION['street'] = $_POST['street'];

     

  5. Yeah you can, I recommend using sessions for logins, though its whatever preference you have I suppose. I have only heard that sessions are more secure and solid to work with. That and some people block cookies, though I'm not sure if it would override that or not, that may be an issue to.

  6. The code I keep posting,

    <?php
    ini_set ("display_errors", "1");
    error_reporting(E_ALL);
    session_start();
    header("Cache-control: private");
    if(!isset($_SESSION["id"]))
    {
    header("Location: index.php?page=login");
    					exit;
    }
    if(!isset($_SESSION["cart"]))
    {
    header("Location: index.php?page=accounthome");
    					exit;
    }
    
      $default = $_GET['default'];
    
    
    if ($alternate == change){
    $result = mysql_query("SELECT * FROM plants WHERE id='$id'") or DIE(mysql_error());
    
    while($r=mysql_fetch_array($result))
    {
    
    $id=$r["id"];
    $plantloc=$r["plantloc"];
    $address=$r["address"];
    $ph=$r["PH"];
    
    
    }
    
    
    
    
    if (isset ($_POST['submit2']))
    {
    
    $problem = FALSE;
    
    
          if (empty ($_POST['street'])) {
    $problem = TRUE;
    $error .= 'Street is a required field. <br />';
          }
    
          if (empty ($_POST['city'])) {
    $problem = TRUE;
    $error .= 'City is a required field. <br />';
          }
    
          if (empty ($_POST['state'])) {
    $problem = TRUE;
    $error .= 'State is a required field. <br />';
          }
    
          if (empty ($_POST['zip'])) {
    $problem = TRUE;
    $error .= 'Zip is a required field. <br />';
          }
    
    
    
    
    
    if (!$problem) {
    
    $_SESSION['city'] = ucwords($_POST['city']);
    $_SESSION['state'] = strtoupper($_POST['state']);
    
    $_SESSION['zip'] = $_POST['zip'];
    $_SESSION['street'] = $_POST['street'];
    $_SESSION['tempaddress'] = 1;
    
                          header("Location: index.php?page=checkout");
    					exit;
    
    }
    
    }
    
    
    
    
    $content .= "
    <p><u><a href=\"index.php?page=accounthome\">$plantloc</a></u> - Alternate Address </p>
    
    <form action=\"index.php?page=checkout&alternate=change\" method=\"post\">
    Street:<br />
    <input type=\"text\" size=\"20\" name=\"street\" value=\"$_POST[street]\" /><br /><br />
    <table><tr><td>
    City:
    </td><td>
    State:
    </td><td>
    Zip:
    </td></tr>
    <tr><td>
    <input type=\"text\" size=\"10\" name=\"city\" value=\"$_POST[city]\" />
    </td><td>
    <input type=\"text\" size=\"2\" name=\"state\" value=\"$_POST[state]\" />
    </td><td>
    <input type=\"text\" size=\"5\" name=\"zip\" value=\"$_POST[zip]\" />
    </td></tr></table>
    <br />
    <input type=\"submit\" name=\"submit2\" class=\"textfield\" value=\"Submit Address\" />
    </form>
    ";
    
    
    
    
    } else {
    
    $result = mysql_query("SELECT * FROM plants WHERE id='$id'") or DIE(mysql_error());
    while($r=mysql_fetch_array($result))
    {
    
    $id=$r["id"];
    $plantloc=$r["plantloc"];
    $city=$r["city"];
    $state=$r["state"];
    $zip=$r["zip"];
    $street=$r["street"];
    
    }
    
    $address = "$street<br />$city, $state - $zip";
    
    if (isset($default)){
    $_SESSION['tempaddress'] = 0;
    header("Location: index.php?page=checkout");
    }
    
    if ($_SESSION['tempaddress'] == 1){
    $displayaddress = "
    $_SESSION[street]<br />
    $_SESSION[city], $_SESSION[state] $_SESSION[zip]<br />
    ";
    }
    
    
    
    if (isset ($_POST['submit']))
    {
    
    $problem = FALSE;
    
          if (!isset($_POST['checktos'])) {
    $problem = TRUE;
    $error .= 'You must agree to the Terms of Service to complete your order. <br />';
          }
    
          if (empty ($_POST['ponumber'])) {
    $problem = TRUE;
    $error .= 'A PO number is required for checkout. <br />';
          }
    
          if (empty ($_POST['firstname'])) {
    $problem = TRUE;
    $error .= 'Your first name is required for checkout. <br />';
          }
    
          if (empty ($_POST['lastname'])) {
    $problem = TRUE;
    $error .= 'Your last name is required for checkout. <br />';
          }
    
          if (empty ($_POST['phonenumber1'])) {
    $problem = TRUE;
    $error .= 'Phone Number is a required field and all three blanks must be completed. <br />';
          } elseif (empty ($_POST['phonenumber2'])) {
    $problem = TRUE;
    $error .= 'Phone Number is a required field and all three blanks must be completed. <br />';
          } elseif (empty ($_POST['phonenumber3'])) {
    $problem = TRUE;
    $error .= 'Phone Number is a required field and all three blanks must be completed. <br />';
          }
    
    if (!$problem) {
    
    $ponumber = $_POST['ponumber'];
    $shipping = $_POST['shipping'];
    $notes = $_POST['notes'];
    $firstname = $_POST['firstname'];
    $lastname = $_POST['lastname'];
    $name = "$firstname $lastname";
    $phonenumber1 = $_POST['phonenumber1'];
    $phonenumber2 = $_POST['phonenumber2'];
    $phonenumber3 = $_POST['phonenumber3'];
    $telephone = "$_POST[phonenumber1]-$_POST[phonenumber2]-$_POST[phonenumber3]";
    
    if (isset($default)){
    $_SESSION['tempaddress'] = 0;
    }
    
    if ($_SESSION['tempaddress'] == 1){
    $displayaddress = "
    $_SESSION[street]<br />
    $_SESSION[city], $_SESSION[state] $_SESSION[zip]<br />
    ";
    }
    
    $color1 = "#dddddd";
        $color2 = "#c0c0c0";
        $row_count = 0;
    
    $parts .= "
    <table width=732 cellpadding=3><tr bgcolor=#8d8d8d cellspacing=6><td width=10 align=center><b>LOC</b></td><td width=100><b>Part Number</b></td><td width=330><b>Description</b></td><td><b>Price</b></td><td><b>QTY</b></td></tr>";
    
    $result2 = mysql_query("SELECT * FROM parts ORDER BY id ASC") or DIE(mysql_error());
    while($r2=mysql_fetch_array($result2))
    {
    $pid=$r2["id"];
    $loc=$r2["LOC"];
    $pn=$r2["PN"];
    $desc=$r2["DESC"];
    $price=$r2["PRICE"];
    $sub = $r2["SUB"];
    
    $row_color = ($row_count % 2) ? $color1 : $color2;
    
    
    $quan = ($_SESSION['cart'][$pid] < 1) ? "0" : $_SESSION['cart'][$pid];
    
    if ($quan > 0){
    
    if ($sub == 0){
    $parts .= "<tr cellspacing=6><td align=center bgcolor=\"$row_color\">$loc</td><td bgcolor=\"$row_color\" width=\"100\">$pn</td><td bgcolor=\"$row_color\" width=\"330\">$desc</td><td bgcolor=\"$row_color\">$price</td><td bgcolor=\"$row_color\">$quan</td></tr>";
    $row_count++;
    } else {
    $parts .= "<tr cellspacing=6><td align=center bgcolor=\"$row_color\">$loc-$sub</td><td bgcolor=\"$row_color\" width=\"100\">$pn</td><td bgcolor=\"$row_color\" width=\"330\">$desc</td><td bgcolor=\"$row_color\">$price</td><td bgcolor=\"$row_color\">$quan</td></tr>";
    $row_count++;
    }
    $total = $total + ($price * $quan);
    
    }
    
    
    
    }
    include "Rate.php5";
    
    $parts .= "<tr cellspacing=6><td align=center></td><td></td><td align=right><B>TOTAL</B></td><td bgcolor=yellow>$total</td><td></td></tr></table>";
    
    
    $datetime = date('m/d/Y - g:i A');
    
    
    $result = MYSQL_QUERY("INSERT INTO orders (po,plantloc,address,telephone,name,notes,shipping,parts,datetime)".
    "VALUES ('$ponumber', '$plantloc', '$address2', '$telephone', '$name', '$notes', '$shipping', '$parts', '$datetime')") or die (mysql_error());
    
    $emailbody = "<font style=verdana>
    <table width=732 cellpadding=3><tr bgcolor=#f3f3f3 cellspacing=6><td>
    <u>$plantloc</u></td><td>$name - $telephone</td><tr><td>
    $address2</td><td>
    
    <table><tr><td align=right>
    <b>PO #:</b>
    </td><td>
    $ponumber
    </td></tr><tr><td align=right>
    <b>Shipping:</b>
    </td><td>
    $shipping
    </td></tr><tr><td align=right>
    <b>Date:</b>
    </td><td>
    $datetime
    </td></tr></table>
    
    </td></tr></table>
    <br />
       <u>Special Notes</u>
    <table width=732 cellpadding=3 bgcolor=f3f3f3>
    <tr><td>$notes</td></tr>
    </table>
    <br />
    $parts<br /><br />
    </font>
    ";
    
    
    $to  = 'tcantwell@berryequipment.net' . ', '; // note the comma
    
    // subject
    $subject = 'Purchase Orders';
    
    // message
    $message = "
    <html>
    <head>
    </head>
    <body>
    $emailbody
    </body>
    </html>
    ";
    
    // To send HTML mail, the Content-type header must be set
    $headers  = 'MIME-Version: 1.0' . "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
    
    // Additional headers
    $headers .= 'To: Candace Painter <cpainter@berryequipment.net>' . "\r\n";
    
    // Mail it
    mail($to, $subject, $message, $headers);
    
    
                          header("Location: index.php?page=thankyou");
    					exit;
    
    
    
    
    } }
    
    
    
    
    
    
    
    
    
    $content .= "
    <h1>Checkout</h1>
    ";
    
    $color1 = "#dddddd";
        $color2 = "#c0c0c0";
        $row_count = 0;
    
    $content .= "
    <table width=732 cellpadding=3><tr bgcolor=#8d8d8d cellspacing=6><td width=10 align=center>LOC</td><td width=100>Part Number</td><td width=330>Description</td><td>Price</td><td>QTY</td></tr>";
    
    $result2 = mysql_query("SELECT * FROM parts ORDER BY LOC ASC") or DIE(mysql_error());
    while($r2=mysql_fetch_array($result2))
    {
    $pid=$r2["id"];
    $loc=$r2["LOC"];
    $pn=$r2["PN"];
    $desc=$r2["DESC"];
    $price=$r2["PRICE"];
    $sub=$r["SUB"];
    
    $row_color = ($row_count % 2) ? $color1 : $color2;
    
    
    $quan = ($_SESSION['cart'][$pid] < 1) ? "0" : $_SESSION['cart'][$pid];
    
    if ($quan > 0){
    if ($sub == 0) {
    $content .= "<tr cellspacing=6><td align=center bgcolor=\"$row_color\">$loc</td><td bgcolor=\"$row_color\" width=\"100\">$pn</td><td bgcolor=\"$row_color\" width=\"330\">$desc</td><td bgcolor=\"$row_color\">$price</td><td bgcolor=\"$row_color\">$quan</td></tr>";
    $row_count++;
    } else {
    $content .= "<tr cellspacing=6><td align=center bgcolor=\"$row_color\">$loc-$sub</td><td bgcolor=\"$row_color\" width=\"100\">$pn</td><td bgcolor=\"$row_color\" width=\"330\">$desc</td><td bgcolor=\"$row_color\">$price</td><td bgcolor=\"$row_color\">$quan</td></tr>";
    $row_count++;
    }
    $total = $total + ($price * $quan);
    
    }
    
    
    }
    $content .= "<tr cellspacing=6><td align=center></td><td></td><td></td><td bgcolor=yellow><b>$total</b></td><td></td></tr>";
    
    if ($_SESSION['tempaddress'] == 1) {
    $address2 = $displayaddress;
    } else {
    $address2 = $address;
    }
    
    $content .= "
    <form action=\"index.php?page=checkout\" method=\"post\" name=\"checkout\">
    <table>
    <tr><td width=250 valign=top>
    Shipping Address:<br />
    $_SESSION[tempaddress]
    <p>$address2</p><br />
    <a href=index.php?page=checkout&alternate=change>Ship to alternate location</a>
    <br />
    <a href=index.php?page=checkout&default=true>Reset default address</a>
    </td><td valign=top width=450>
    First Name:<br />
    <input type=\"text\" size=\"20\" name=\"firstname\" value=\"$_POST[firstname]\" /><br /><br />
    Last Name:<br />
    <input type=\"text\" size=\"20\" name=\"lastname\" value=\"$_POST[lastname]\" /><br /><br />
    Shipping Method:<br />
    <select name=shipping>
    <option value=\"Ground\">Ground</option>\n
    <option value=\"Expedite\">Expedite</option>\n
    <option value=\"Expedite A.M.\">Expedite A.M.</option>\n
    <option value=\"Expedite Saturday\">Expedite Saturday</option>\n
    <option value=\"2 Day\">2nd Day</option>\n
    <option value=\"3 Day\">3rd Day</option>\n
    </select>
    <br /><br />
    PO Number:<br />
    <input type=\"text\" size=\"20\" name=\"ponumber\" value=\"$_POST[ponumber]\" /><br /><br />
    Contact Telephone #:<br />
    <input type=\"text\" size=\"3\" onKeyup=\"autotab(this, document.checkout.phonenumber2)\" maxlength=3 name=\"phonenumber1\" value=\"$_POST[phonenumber1]\" />
    <input type=\"text\" size=\"3\"  onKeyup=\"autotab(this, document.checkout.phonenumber3)\" maxlength=3 name=\"phonenumber2\" value=\"$_POST[phonenumber2]\" />
    <input type=\"text\" size=\"3\" maxlength=4 name=\"phonenumber3\" value=\"$_POST[phonenumber3]\" />
    <br /><br />
    Special Notes:<br />
    <textarea cols=\"30\" rows=\"3\" name=\"notes\" value=\"$_POST[notes]\"></textarea>
    
    </td></tr></table>
    
    <p align=left><input type=\"checkbox\" name=\"checktos\" value=\"tos\"> I agree to the <a href=#>Terms of Service</a>.</p>
    <p align=right><input type=\"submit\" name=\"submit\" class=\"textfield\" value=\"Checkout\" /></p>
    </form>
    ";
    
    }
    
    
    
    
    ?>
    

     

     

    It has the checkout page and the address change combined. The link to change your address is on the checkout page, if it sets to that it shows the address change form and then when you submit it, it'll run the script to set the sessions and whatnot and then go back to the main checkout page.

  7. Okay, but read what I am trying to tell you. Yes that may be correct, and I did change it.. however, it is already letting me access my change address form. The problem is that it isn't setting the session variables to the correct values.. (and the change didn't fix it)

     

     

    Maybe this error is significant?

    Notice: A session had already been started - ignoring session_start() in /home/virtual/site21/fst/var/www/html/2/checkout.php on line 4
    

  8. Craygo: Alternate is set in the url, alternate=change. If it wasn't set then the form to change the address wouldn't display cause of the if statement on line 18.

     

    phpSensei: Alternate Var? no.. I don't think so. If I understand your question, see above sentance. $_SESSION['tempaddress'] = 1; gets set when the alternate address is submitted. When you're on the checkout page, it checks to see if that session is set to 0 or set to 1. If it is set to 1, it should be reading the newly entered address (saved as the sessions) and if not it should be reading the address from the database.

     

    PFMaBiSmAd: I turned the errors on, got many errors. Some of which I believe are just from the form I have on the checkout page and the fields not having anything in them yet. Here are the errors that it displays:

     

    Notice: A session had already been started - ignoring session_start() in /home/virtual/site21/fst/var/www/html/2/checkout.php on line 4
    
    Notice: Undefined index: default in /home/virtual/site21/fst/var/www/html/2/checkout.php on line 17
    
    Notice: Use of undefined constant change - assumed 'change' in /home/virtual/site21/fst/var/www/html/2/checkout.php on line 20
    
    Notice: Undefined variable: total in /home/virtual/site21/fst/var/www/html/2/checkout.php on line 362
    
    Notice: Undefined index: firstname in /home/virtual/site21/fst/var/www/html/2/checkout.php on line 388
    
    Notice: Undefined index: lastname in /home/virtual/site21/fst/var/www/html/2/checkout.php on line 390
    
    Notice: Undefined index: ponumber in /home/virtual/site21/fst/var/www/html/2/checkout.php on line 402
    
    Notice: Undefined index: phonenumber1 in /home/virtual/site21/fst/var/www/html/2/checkout.php on line 404
    
    Notice: Undefined index: phonenumber2 in /home/virtual/site21/fst/var/www/html/2/checkout.php on line 405
    
    Notice: Undefined index: phonenumber3 in /home/virtual/site21/fst/var/www/html/2/checkout.php on line 406
    
    Notice: Undefined index: notes in /home/virtual/site21/fst/var/www/html/2/checkout.php on line 409
    
    Notice: Use of undefined constant id - assumed 'id' in /home/virtual/site21/fst/var/www/html/2/index.php on line 164
        Logout
    
    Notice: Use of undefined constant id - assumed 'id' in /home/virtual/site21/fst/var/www/html/2/index.php
    

     

    I also added the exit; statements and I understand that it is good to use, and will begin doing so (didn't solve problem though).

     

     

    New code: (though not much changed, just what I stated above)

     

    <?php
    ini_set ("display_errors", "1");
    error_reporting(E_ALL);
    session_start();
    header("Cache-control: private");
    if(!isset($_SESSION["id"]))
    {
    header("Location: index.php?page=login");
    					exit;
    }
    if(!isset($_SESSION["cart"]))
    {
    header("Location: index.php?page=accounthome");
    					exit;
    }
    
      $default = $_GET['default'];
    
    
    if ($alternate == change){
    $result = mysql_query("SELECT * FROM plants WHERE id='$id'") or DIE(mysql_error());
    
    while($r=mysql_fetch_array($result))
    {
    
    $id=$r["id"];
    $plantloc=$r["plantloc"];
    $address=$r["address"];
    $ph=$r["PH"];
    
    
    }
    
    
    
    
    if (isset ($_POST['submit2']))
    {
    
    $problem = FALSE;
    
    
          if (empty ($_POST['street'])) {
    $problem = TRUE;
    $error .= 'Street is a required field. <br />';
          }
    
          if (empty ($_POST['city'])) {
    $problem = TRUE;
    $error .= 'City is a required field. <br />';
          }
    
          if (empty ($_POST['state'])) {
    $problem = TRUE;
    $error .= 'State is a required field. <br />';
          }
    
          if (empty ($_POST['zip'])) {
    $problem = TRUE;
    $error .= 'Zip is a required field. <br />';
          }
    
    
    
    
    
    if (!$problem) {
    
    $_SESSION['city'] = ucwords($_POST['city']);
    $_SESSION['state'] = strtoupper($_POST['state']);
    
    $_SESSION['zip'] = $_POST['zip'];
    $_SESSION['street'] = $_POST['street'];
    $_SESSION['tempaddress'] = 1;
    
                          header("Location: index.php?page=checkout");
    					exit;
    
    }
    
    }
    
    
    
    
    $content .= "
    <p><u><a href=\"index.php?page=accounthome\">$plantloc</a></u> - Alternate Address </p>
    
    <form action=\"index.php?page=checkout&alternate=change\" method=\"post\">
    Street:<br />
    <input type=\"text\" size=\"20\" name=\"street\" value=\"$_POST[street]\" /><br /><br />
    <table><tr><td>
    City:
    </td><td>
    State:
    </td><td>
    Zip:
    </td></tr>
    <tr><td>
    <input type=\"text\" size=\"10\" name=\"city\" value=\"$_POST[city]\" />
    </td><td>
    <input type=\"text\" size=\"2\" name=\"state\" value=\"$_POST[state]\" />
    </td><td>
    <input type=\"text\" size=\"5\" name=\"zip\" value=\"$_POST[zip]\" />
    </td></tr></table>
    <br />
    <input type=\"submit\" name=\"submit2\" class=\"textfield\" value=\"Submit Address\" />
    </form>
    ";
    
    
    
    
    } else {
    
    $result = mysql_query("SELECT * FROM plants WHERE id='$id'") or DIE(mysql_error());
    while($r=mysql_fetch_array($result))
    {
    
    $id=$r["id"];
    $plantloc=$r["plantloc"];
    $city=$r["city"];
    $state=$r["state"];
    $zip=$r["zip"];
    $street=$r["street"];
    
    }
    
    $address = "$street<br />$city, $state - $zip";
    
    if (isset($default)){
    $_SESSION['tempaddress'] = 0;
    header("Location: index.php?page=checkout");
    }
    
    if ($_SESSION['tempaddress'] == 1){
    $displayaddress = "
    $_SESSION[street]<br />
    $_SESSION[city], $_SESSION[state] $_SESSION[zip]<br />
    ";
    }
    
    
    
    if (isset ($_POST['submit']))
    {
    
    $problem = FALSE;
    
          if (!isset($_POST['checktos'])) {
    $problem = TRUE;
    $error .= 'You must agree to the Terms of Service to complete your order. <br />';
          }
    
          if (empty ($_POST['ponumber'])) {
    $problem = TRUE;
    $error .= 'A PO number is required for checkout. <br />';
          }
    
          if (empty ($_POST['firstname'])) {
    $problem = TRUE;
    $error .= 'Your first name is required for checkout. <br />';
          }
    
          if (empty ($_POST['lastname'])) {
    $problem = TRUE;
    $error .= 'Your last name is required for checkout. <br />';
          }
    
          if (empty ($_POST['phonenumber1'])) {
    $problem = TRUE;
    $error .= 'Phone Number is a required field and all three blanks must be completed. <br />';
          } elseif (empty ($_POST['phonenumber2'])) {
    $problem = TRUE;
    $error .= 'Phone Number is a required field and all three blanks must be completed. <br />';
          } elseif (empty ($_POST['phonenumber3'])) {
    $problem = TRUE;
    $error .= 'Phone Number is a required field and all three blanks must be completed. <br />';
          }
    
    if (!$problem) {
    
    $ponumber = $_POST['ponumber'];
    $shipping = $_POST['shipping'];
    $notes = $_POST['notes'];
    $firstname = $_POST['firstname'];
    $lastname = $_POST['lastname'];
    $name = "$firstname $lastname";
    $phonenumber1 = $_POST['phonenumber1'];
    $phonenumber2 = $_POST['phonenumber2'];
    $phonenumber3 = $_POST['phonenumber3'];
    $telephone = "$_POST[phonenumber1]-$_POST[phonenumber2]-$_POST[phonenumber3]";
    
    if (isset($default)){
    $_SESSION['tempaddress'] = 0;
    }
    
    if ($_SESSION['tempaddress'] == 1){
    $displayaddress = "
    $_SESSION[street]<br />
    $_SESSION[city], $_SESSION[state] $_SESSION[zip]<br />
    ";
    }
    
    $color1 = "#dddddd";
        $color2 = "#c0c0c0";
        $row_count = 0;
    
    $parts .= "
    <table width=732 cellpadding=3><tr bgcolor=#8d8d8d cellspacing=6><td width=10 align=center><b>LOC</b></td><td width=100><b>Part Number</b></td><td width=330><b>Description</b></td><td><b>Price</b></td><td><b>QTY</b></td></tr>";
    
    $result2 = mysql_query("SELECT * FROM parts ORDER BY id ASC") or DIE(mysql_error());
    while($r2=mysql_fetch_array($result2))
    {
    $pid=$r2["id"];
    $loc=$r2["LOC"];
    $pn=$r2["PN"];
    $desc=$r2["DESC"];
    $price=$r2["PRICE"];
    $sub = $r2["SUB"];
    
    $row_color = ($row_count % 2) ? $color1 : $color2;
    
    
    $quan = ($_SESSION['cart'][$pid] < 1) ? "0" : $_SESSION['cart'][$pid];
    
    if ($quan > 0){
    
    if ($sub == 0){
    $parts .= "<tr cellspacing=6><td align=center bgcolor=\"$row_color\">$loc</td><td bgcolor=\"$row_color\" width=\"100\">$pn</td><td bgcolor=\"$row_color\" width=\"330\">$desc</td><td bgcolor=\"$row_color\">$price</td><td bgcolor=\"$row_color\">$quan</td></tr>";
    $row_count++;
    } else {
    $parts .= "<tr cellspacing=6><td align=center bgcolor=\"$row_color\">$loc-$sub</td><td bgcolor=\"$row_color\" width=\"100\">$pn</td><td bgcolor=\"$row_color\" width=\"330\">$desc</td><td bgcolor=\"$row_color\">$price</td><td bgcolor=\"$row_color\">$quan</td></tr>";
    $row_count++;
    }
    $total = $total + ($price * $quan);
    
    }
    
    
    
    }
    include "Rate.php5";
    
    $parts .= "<tr cellspacing=6><td align=center></td><td></td><td align=right><B>TOTAL</B></td><td bgcolor=yellow>$total</td><td></td></tr></table>";
    
    
    $datetime = date('m/d/Y - g:i A');
    
    
    $result = MYSQL_QUERY("INSERT INTO orders (po,plantloc,address,telephone,name,notes,shipping,parts,datetime)".
    "VALUES ('$ponumber', '$plantloc', '$address2', '$telephone', '$name', '$notes', '$shipping', '$parts', '$datetime')") or die (mysql_error());
    
    $emailbody = "<font style=verdana>
    <table width=732 cellpadding=3><tr bgcolor=#f3f3f3 cellspacing=6><td>
    <u>$plantloc</u></td><td>$name - $telephone</td><tr><td>
    $address2</td><td>
    
    <table><tr><td align=right>
    <b>PO #:</b>
    </td><td>
    $ponumber
    </td></tr><tr><td align=right>
    <b>Shipping:</b>
    </td><td>
    $shipping
    </td></tr><tr><td align=right>
    <b>Date:</b>
    </td><td>
    $datetime
    </td></tr></table>
    
    </td></tr></table>
    <br />
       <u>Special Notes</u>
    <table width=732 cellpadding=3 bgcolor=f3f3f3>
    <tr><td>$notes</td></tr>
    </table>
    <br />
    $parts<br /><br />
    </font>
    ";
    
    
    $to  = 'tcantwell@berryequipment.net' . ', '; // note the comma
    
    // subject
    $subject = 'Purchase Orders';
    
    // message
    $message = "
    <html>
    <head>
    </head>
    <body>
    $emailbody
    </body>
    </html>
    ";
    
    // To send HTML mail, the Content-type header must be set
    $headers  = 'MIME-Version: 1.0' . "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
    
    // Additional headers
    $headers .= 'To: Candace Painter <cpainter@berryequipment.net>' . "\r\n";
    
    // Mail it
    mail($to, $subject, $message, $headers);
    
    
                          header("Location: index.php?page=thankyou");
    					exit;
    
    
    
    
    } }
    
    
    
    
    
    
    
    
    
    $content .= "
    <h1>Checkout</h1>
    ";
    
    $color1 = "#dddddd";
        $color2 = "#c0c0c0";
        $row_count = 0;
    
    $content .= "
    <table width=732 cellpadding=3><tr bgcolor=#8d8d8d cellspacing=6><td width=10 align=center>LOC</td><td width=100>Part Number</td><td width=330>Description</td><td>Price</td><td>QTY</td></tr>";
    
    $result2 = mysql_query("SELECT * FROM parts ORDER BY LOC ASC") or DIE(mysql_error());
    while($r2=mysql_fetch_array($result2))
    {
    $pid=$r2["id"];
    $loc=$r2["LOC"];
    $pn=$r2["PN"];
    $desc=$r2["DESC"];
    $price=$r2["PRICE"];
    $sub=$r["SUB"];
    
    $row_color = ($row_count % 2) ? $color1 : $color2;
    
    
    $quan = ($_SESSION['cart'][$pid] < 1) ? "0" : $_SESSION['cart'][$pid];
    
    if ($quan > 0){
    if ($sub == 0) {
    $content .= "<tr cellspacing=6><td align=center bgcolor=\"$row_color\">$loc</td><td bgcolor=\"$row_color\" width=\"100\">$pn</td><td bgcolor=\"$row_color\" width=\"330\">$desc</td><td bgcolor=\"$row_color\">$price</td><td bgcolor=\"$row_color\">$quan</td></tr>";
    $row_count++;
    } else {
    $content .= "<tr cellspacing=6><td align=center bgcolor=\"$row_color\">$loc-$sub</td><td bgcolor=\"$row_color\" width=\"100\">$pn</td><td bgcolor=\"$row_color\" width=\"330\">$desc</td><td bgcolor=\"$row_color\">$price</td><td bgcolor=\"$row_color\">$quan</td></tr>";
    $row_count++;
    }
    $total = $total + ($price * $quan);
    
    }
    
    
    }
    $content .= "<tr cellspacing=6><td align=center></td><td></td><td></td><td bgcolor=yellow><b>$total</b></td><td></td></tr>";
    
    if ($_SESSION['tempaddress'] == 1) {
    $address2 = $displayaddress;
    } else {
    $address2 = $address;
    }
    
    $content .= "
    <form action=\"index.php?page=checkout\" method=\"post\" name=\"checkout\">
    <table>
    <tr><td width=250 valign=top>
    Shipping Address:<br />
    $_SESSION[tempaddress]
    <p>$address2</p><br />
    <a href=index.php?page=checkout&alternate=change>Ship to alternate location</a>
    <br />
    <a href=index.php?page=checkout&default=true>Reset default address</a>
    </td><td valign=top width=450>
    First Name:<br />
    <input type=\"text\" size=\"20\" name=\"firstname\" value=\"$_POST[firstname]\" /><br /><br />
    Last Name:<br />
    <input type=\"text\" size=\"20\" name=\"lastname\" value=\"$_POST[lastname]\" /><br /><br />
    Shipping Method:<br />
    <select name=shipping>
    <option value=\"Ground\">Ground</option>\n
    <option value=\"Expedite\">Expedite</option>\n
    <option value=\"Expedite A.M.\">Expedite A.M.</option>\n
    <option value=\"Expedite Saturday\">Expedite Saturday</option>\n
    <option value=\"2 Day\">2nd Day</option>\n
    <option value=\"3 Day\">3rd Day</option>\n
    </select>
    <br /><br />
    PO Number:<br />
    <input type=\"text\" size=\"20\" name=\"ponumber\" value=\"$_POST[ponumber]\" /><br /><br />
    Contact Telephone #:<br />
    <input type=\"text\" size=\"3\" onKeyup=\"autotab(this, document.checkout.phonenumber2)\" maxlength=3 name=\"phonenumber1\" value=\"$_POST[phonenumber1]\" />
    <input type=\"text\" size=\"3\"  onKeyup=\"autotab(this, document.checkout.phonenumber3)\" maxlength=3 name=\"phonenumber2\" value=\"$_POST[phonenumber2]\" />
    <input type=\"text\" size=\"3\" maxlength=4 name=\"phonenumber3\" value=\"$_POST[phonenumber3]\" />
    <br /><br />
    Special Notes:<br />
    <textarea cols=\"30\" rows=\"3\" name=\"notes\" value=\"$_POST[notes]\"></textarea>
    
    </td></tr></table>
    
    <p align=left><input type=\"checkbox\" name=\"checktos\" value=\"tos\"> I agree to the <a href=#>Terms of Service</a>.</p>
    <p align=right><input type=\"submit\" name=\"submit\" class=\"textfield\" value=\"Checkout\" /></p>
    </form>
    ";
    
    }
    
    
    
    
    ?>
    

  9. <?php
    session_start();
    header("Cache-control: private");
    if(!isset($_SESSION["id"]))
    {
    header("Location: index.php?page=login");
    }
    if(!isset($_SESSION["cart"]))
    {
    header("Location: index.php?page=accounthome");
    }
    
      $default = $_GET['default'];
    
    
    if ($alternate == change){
    $result = mysql_query("SELECT * FROM plants WHERE id='$id'") or DIE(mysql_error());
    
    while($r=mysql_fetch_array($result))
    {
    
    $id=$r["id"];
    $plantloc=$r["plantloc"];
    $address=$r["address"];
    $ph=$r["PH"];
    
    
    }
    
    
    
    
    if (isset ($_POST['submit2']))
    {
    
    $problem = FALSE;
    
    
          if (empty ($_POST['street'])) {
    $problem = TRUE;
    $error .= 'Street is a required field. <br />';
          }
    
          if (empty ($_POST['city'])) {
    $problem = TRUE;
    $error .= 'City is a required field. <br />';
          }
    
          if (empty ($_POST['state'])) {
    $problem = TRUE;
    $error .= 'State is a required field. <br />';
          }
    
          if (empty ($_POST['zip'])) {
    $problem = TRUE;
    $error .= 'Zip is a required field. <br />';
          }
    
    
    
    
    
    if (!$problem) {
    
    $_SESSION['city'] = ucwords($_POST['city']);
    $_SESSION['state'] = strtoupper($_POST['state']);
    
    $_SESSION['zip'] = $_POST['zip'];
    $_SESSION['street'] = $_POST['street'];
    $_SESSION['tempaddress'] = 1;
    
                          header("Location: index.php?page=checkout");
    
    
    }
    
    }
    
    
    
    
    $content .= "
    <p><u><a href=\"index.php?page=accounthome\">$plantloc</a></u> - Alternate Address </p>
    
    <form action=\"index.php?page=checkout&alternate=change\" method=\"post\">
    Street:<br />
    <input type=\"text\" size=\"20\" name=\"street\" value=\"$_POST[street]\" /><br /><br />
    <table><tr><td>
    City:
    </td><td>
    State:
    </td><td>
    Zip:
    </td></tr>
    <tr><td>
    <input type=\"text\" size=\"10\" name=\"city\" value=\"$_POST[city]\" />
    </td><td>
    <input type=\"text\" size=\"2\" name=\"state\" value=\"$_POST[state]\" />
    </td><td>
    <input type=\"text\" size=\"5\" name=\"zip\" value=\"$_POST[zip]\" />
    </td></tr></table>
    <br />
    <input type=\"submit\" name=\"submit2\" class=\"textfield\" value=\"Submit Address\" />
    </form>
    ";
    
    
    
    
    } else {
    
    $result = mysql_query("SELECT * FROM plants WHERE id='$id'") or DIE(mysql_error());
    while($r=mysql_fetch_array($result))
    {
    
    $id=$r["id"];
    $plantloc=$r["plantloc"];
    $city=$r["city"];
    $state=$r["state"];
    $zip=$r["zip"];
    $street=$r["street"];
    
    }
    
    $address = "$street<br />$city, $state - $zip";
    
    if (isset($default)){
    $_SESSION['tempaddress'] = 0;
    header("Location: index.php?page=checkout");
    }
    
    if ($_SESSION['tempaddress'] == 1){
    $displayaddress = "
    $_SESSION[street]<br />
    $_SESSION[city], $_SESSION[state] $_SESSION[zip]<br />
    ";
    }
    
    
    
    if (isset ($_POST['submit']))
    {
    
    $problem = FALSE;
    
          if (!isset($_POST['checktos'])) {
    $problem = TRUE;
    $error .= 'You must agree to the Terms of Service to complete your order. <br />';
          }
    
          if (empty ($_POST['ponumber'])) {
    $problem = TRUE;
    $error .= 'A PO number is required for checkout. <br />';
          }
    
          if (empty ($_POST['firstname'])) {
    $problem = TRUE;
    $error .= 'Your first name is required for checkout. <br />';
          }
    
          if (empty ($_POST['lastname'])) {
    $problem = TRUE;
    $error .= 'Your last name is required for checkout. <br />';
          }
    
          if (empty ($_POST['phonenumber1'])) {
    $problem = TRUE;
    $error .= 'Phone Number is a required field and all three blanks must be completed. <br />';
          } elseif (empty ($_POST['phonenumber2'])) {
    $problem = TRUE;
    $error .= 'Phone Number is a required field and all three blanks must be completed. <br />';
          } elseif (empty ($_POST['phonenumber3'])) {
    $problem = TRUE;
    $error .= 'Phone Number is a required field and all three blanks must be completed. <br />';
          }
    
    if (!$problem) {
    
    $ponumber = $_POST['ponumber'];
    $shipping = $_POST['shipping'];
    $notes = $_POST['notes'];
    $firstname = $_POST['firstname'];
    $lastname = $_POST['lastname'];
    $name = "$firstname $lastname";
    $phonenumber1 = $_POST['phonenumber1'];
    $phonenumber2 = $_POST['phonenumber2'];
    $phonenumber3 = $_POST['phonenumber3'];
    $telephone = "$_POST[phonenumber1]-$_POST[phonenumber2]-$_POST[phonenumber3]";
    
    if (isset($default)){
    $_SESSION['tempaddress'] = 0;
    }
    
    if ($_SESSION['tempaddress'] == 1){
    $displayaddress = "
    $_SESSION[street]<br />
    $_SESSION[city], $_SESSION[state] $_SESSION[zip]<br />
    ";
    }
    
    $color1 = "#dddddd";
        $color2 = "#c0c0c0";
        $row_count = 0;
    
    $parts .= "
    <table width=732 cellpadding=3><tr bgcolor=#8d8d8d cellspacing=6><td width=10 align=center><b>LOC</b></td><td width=100><b>Part Number</b></td><td width=330><b>Description</b></td><td><b>Price</b></td><td><b>QTY</b></td></tr>";
    
    $result2 = mysql_query("SELECT * FROM parts ORDER BY id ASC") or DIE(mysql_error());
    while($r2=mysql_fetch_array($result2))
    {
    $pid=$r2["id"];
    $loc=$r2["LOC"];
    $pn=$r2["PN"];
    $desc=$r2["DESC"];
    $price=$r2["PRICE"];
    $sub = $r2["SUB"];
    
    $row_color = ($row_count % 2) ? $color1 : $color2;
    
    
    $quan = ($_SESSION['cart'][$pid] < 1) ? "0" : $_SESSION['cart'][$pid];
    
    if ($quan > 0){
    
    if ($sub == 0){
    $parts .= "<tr cellspacing=6><td align=center bgcolor=\"$row_color\">$loc</td><td bgcolor=\"$row_color\" width=\"100\">$pn</td><td bgcolor=\"$row_color\" width=\"330\">$desc</td><td bgcolor=\"$row_color\">$price</td><td bgcolor=\"$row_color\">$quan</td></tr>";
    $row_count++;
    } else {
    $parts .= "<tr cellspacing=6><td align=center bgcolor=\"$row_color\">$loc-$sub</td><td bgcolor=\"$row_color\" width=\"100\">$pn</td><td bgcolor=\"$row_color\" width=\"330\">$desc</td><td bgcolor=\"$row_color\">$price</td><td bgcolor=\"$row_color\">$quan</td></tr>";
    $row_count++;
    }
    $total = $total + ($price * $quan);
    
    }
    
    
    
    }
    include "Rate.php5";
    
    $parts .= "<tr cellspacing=6><td align=center></td><td></td><td align=right><B>TOTAL</B></td><td bgcolor=yellow>$total</td><td></td></tr></table>";
    
    
    $datetime = date('m/d/Y - g:i A');
    
    
    $result = MYSQL_QUERY("INSERT INTO orders (po,plantloc,address,telephone,name,notes,shipping,parts,datetime)".
    "VALUES ('$ponumber', '$plantloc', '$address2', '$telephone', '$name', '$notes', '$shipping', '$parts', '$datetime')") or die (mysql_error());
    
    $emailbody = "<font style=verdana>
    <table width=732 cellpadding=3><tr bgcolor=#f3f3f3 cellspacing=6><td>
    <u>$plantloc</u></td><td>$name - $telephone</td><tr><td>
    $address2</td><td>
    
    <table><tr><td align=right>
    <b>PO #:</b>
    </td><td>
    $ponumber
    </td></tr><tr><td align=right>
    <b>Shipping:</b>
    </td><td>
    $shipping
    </td></tr><tr><td align=right>
    <b>Date:</b>
    </td><td>
    $datetime
    </td></tr></table>
    
    </td></tr></table>
    <br />
       <u>Special Notes</u>
    <table width=732 cellpadding=3 bgcolor=f3f3f3>
    <tr><td>$notes</td></tr>
    </table>
    <br />
    $parts<br /><br />
    </font>
    ";
    
    
    $to  = 'tcantwell@berryequipment.net' . ', '; // note the comma
    
    // subject
    $subject = 'Purchase Orders';
    
    // message
    $message = "
    <html>
    <head>
    </head>
    <body>
    $emailbody
    </body>
    </html>
    ";
    
    // To send HTML mail, the Content-type header must be set
    $headers  = 'MIME-Version: 1.0' . "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
    
    // Additional headers
    $headers .= 'To: Candace Painter <cpainter@berryequipment.net>' . "\r\n";
    
    // Mail it
    mail($to, $subject, $message, $headers);
    
    
                          header("Location: index.php?page=thankyou");
    
    
    
    
    
    } }
    
    
    
    
    
    
    
    
    
    $content .= "
    <h1>Checkout</h1>
    ";
    
    $color1 = "#dddddd";
        $color2 = "#c0c0c0";
        $row_count = 0;
    
    $content .= "
    <table width=732 cellpadding=3><tr bgcolor=#8d8d8d cellspacing=6><td width=10 align=center>LOC</td><td width=100>Part Number</td><td width=330>Description</td><td>Price</td><td>QTY</td></tr>";
    
    $result2 = mysql_query("SELECT * FROM parts ORDER BY LOC ASC") or DIE(mysql_error());
    while($r2=mysql_fetch_array($result2))
    {
    $pid=$r2["id"];
    $loc=$r2["LOC"];
    $pn=$r2["PN"];
    $desc=$r2["DESC"];
    $price=$r2["PRICE"];
    $sub=$r["SUB"];
    
    $row_color = ($row_count % 2) ? $color1 : $color2;
    
    
    $quan = ($_SESSION['cart'][$pid] < 1) ? "0" : $_SESSION['cart'][$pid];
    
    if ($quan > 0){
    if ($sub == 0) {
    $content .= "<tr cellspacing=6><td align=center bgcolor=\"$row_color\">$loc</td><td bgcolor=\"$row_color\" width=\"100\">$pn</td><td bgcolor=\"$row_color\" width=\"330\">$desc</td><td bgcolor=\"$row_color\">$price</td><td bgcolor=\"$row_color\">$quan</td></tr>";
    $row_count++;
    } else {
    $content .= "<tr cellspacing=6><td align=center bgcolor=\"$row_color\">$loc-$sub</td><td bgcolor=\"$row_color\" width=\"100\">$pn</td><td bgcolor=\"$row_color\" width=\"330\">$desc</td><td bgcolor=\"$row_color\">$price</td><td bgcolor=\"$row_color\">$quan</td></tr>";
    $row_count++;
    }
    $total = $total + ($price * $quan);
    
    }
    
    
    }
    $content .= "<tr cellspacing=6><td align=center></td><td></td><td></td><td bgcolor=yellow><b>$total</b></td><td></td></tr>";
    
    if ($_SESSION['tempaddress'] == 1) {
    $address2 = $displayaddress;
    } else {
    $address2 = $address;
    }
    
    $content .= "
    <form action=\"index.php?page=checkout\" method=\"post\" name=\"checkout\">
    <table>
    <tr><td width=250 valign=top>
    Shipping Address:<br />
    $_SESSION[tempaddress]
    <p>$address2</p><br />
    <a href=index.php?page=checkout&alternate=change>Ship to alternate location</a>
    <br />
    <a href=index.php?page=checkout&default=true>Reset default address</a>
    </td><td valign=top width=450>
    First Name:<br />
    <input type=\"text\" size=\"20\" name=\"firstname\" value=\"$_POST[firstname]\" /><br /><br />
    Last Name:<br />
    <input type=\"text\" size=\"20\" name=\"lastname\" value=\"$_POST[lastname]\" /><br /><br />
    Shipping Method:<br />
    <select name=shipping>
    <option value=\"Ground\">Ground</option>\n
    <option value=\"Expedite\">Expedite</option>\n
    <option value=\"Expedite A.M.\">Expedite A.M.</option>\n
    <option value=\"Expedite Saturday\">Expedite Saturday</option>\n
    <option value=\"2 Day\">2nd Day</option>\n
    <option value=\"3 Day\">3rd Day</option>\n
    </select>
    <br /><br />
    PO Number:<br />
    <input type=\"text\" size=\"20\" name=\"ponumber\" value=\"$_POST[ponumber]\" /><br /><br />
    Contact Telephone #:<br />
    <input type=\"text\" size=\"3\" onKeyup=\"autotab(this, document.checkout.phonenumber2)\" maxlength=3 name=\"phonenumber1\" value=\"$_POST[phonenumber1]\" />
    <input type=\"text\" size=\"3\"  onKeyup=\"autotab(this, document.checkout.phonenumber3)\" maxlength=3 name=\"phonenumber2\" value=\"$_POST[phonenumber2]\" />
    <input type=\"text\" size=\"3\" maxlength=4 name=\"phonenumber3\" value=\"$_POST[phonenumber3]\" />
    <br /><br />
    Special Notes:<br />
    <textarea cols=\"30\" rows=\"3\" name=\"notes\" value=\"$_POST[notes]\"></textarea>
    
    </td></tr></table>
    
    <p align=left><input type=\"checkbox\" name=\"checktos\" value=\"tos\"> I agree to the <a href=#>Terms of Service</a>.</p>
    <p align=right><input type=\"submit\" name=\"submit\" class=\"textfield\" value=\"Checkout\" /></p>
    </form>
    ";
    
    }
    
    
    
    
    ?>
    

     

    This is the entire checkout page, the part that is mostly being used that has the problem is the top section, where alternate=change. When they fill out the form for street, city, state and zip.. it should set the sessions accordingly, and then if the alternateaddress session is set to 1, it should read those session values as the new address. It's formatting it differently (since the formatting between the two is slightly different) even though it is formatting the way it should when address is changed, it's still using the stored address for the account. This script was working when I had it as two separate pages and once I combined and used an if to split it up so I could run it off the same file it started acting up.

  10. $orderid = array();
      $quantity = array();
      $price = array();
      
    $total = 0;
    
      foreach($_POST['orderid'] as $id){
    	$orderid[] = $id;
    	$quantity[] = $_POST['quantity'][$id];
    	$price[] = $_POST['price'][$id];
    	$total = "$price + $total";
    	 }
    
    $price = implode(',', $price);
    

     

    You need to multiply the totals by eachother?

    Like 6.59 * 7.54 * 7.01 etc?

    If so, change that + sign between price and total to a *

  11. $orderid = array();
      $quantity = array();
      $price = array();
      
    $total = 0;
    
      foreach($_POST['orderid'] as $id){
    	$orderid[] = $id;
    	$quantity[] = $_POST['quantity'][$id];
    	$price[] = $_POST['price'][$id];
    	$total = "$price[] + $total";
    	 }
    
    $price = implode(',', $price);

     

    Try that and see if it does what you need.

  12. Hi,

    I have a little script that replaces the src of an image when I click a link. This presents a gallery type of deal, click a link and the image shows. Well that image needs to link to another specific image, but I don't know how to get the specific part of the href to change to what it needs to be.

     

    Here is what I have:

    <table align=center>
    <tr><td>
    <a onclick=\"return showPic(this)\" href=\"$sheet/main.jpg\" title=\"Main $sheet assembly\">Main $sheet assembly</a>
    <br />
    <a onclick=\"return showPic(this)\" href=\"$sheet/A.jpg\" title=\"Assembly A\">Assembly A</a>
    </td><td align=\"center\" width=\"375\" height=\"375\">
    <a href=\"$sheet/mainL.jpg\" rel=\"lightbox\" title=\"$sheet\"><img id=\"placeholder\" src=\"$sheet/main.jpg\" alt=\"\" border=\"0\" /></a>
    <br />
    Click image to view full size.
    <p id=\desc\">Main $sheet assembly</p>
    </td><td>
    
    
    </td></tr>
    </table>
    

     

    When I click on a link, it changes the src to either main or A, however the href stays as $sheet/mainL.jpg, though if I click the second one that changes it to A, it needs to change the href to $sheet/AL.jpg. Basically needs to just change the letter/word between the / & L.

     

    Heres the javascript I have currently:

    <script type="text/javascript" language="javascript">
    function showPic (whichpic) {
    if (document.getElementById) {
    document.getElementById('placeholder').src = whichpic.href;
      return false;
    } else {
      return true;
    }
    }
    </script>
    

     

    Thanks!

  13. Having some trouble, code should be correct.. It's giving me a 404 error when I try to go to:

    http://www.berryequipment.net/2/PH/

     

    Here is what I have as a .htaccess file in the same directory as my index.php file:

    RewriteEngine On
    
    RewriteBase /
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^([A-Z]+)/$ /index.php?page=$1 [NC,L]
    RewriteRule ^([A-Z]+)/([0-9]+)/$ /index.php?page=$1&var1=$2 [NC,L]
    

     

    Will the rewrite only work if I am running it from the root directory? Trying to run this from the folder /2/, it's just a test folder until the site is complete, then it will all get moved to the main directory. If it has to be in the main to work correctly, I'll end up waiting and doing it very last, but please let me know. Thanks!

  14. well.. like I said, the $_SESSION[tempaddress] IS setting to 1 when I submit the form, and I have a reset button that changes it back to a 0, and everytime I fill out the change address form, it sets it to 1. So the sessions ARE getting set. The session start IS at the top of the page.

  15. I have a page that allows the user to change their saved default address. Basically by setting sessions for each part of the address and another session that tells me if they have changed it or not. When I go and check if it is set, I'm getting a positive response back telling me that it either is or isn't set, though my sessions are displaying my normal address information.

     

    if (isset ($_POST['submit']))
    {
    
    $problem = FALSE;
    
    
          if (empty ($_POST['street'])) {
    $problem = TRUE;
    $error .= 'Street is a required field. <br />';
          }
    
          if (empty ($_POST['city'])) {
    $problem = TRUE;
    $error .= 'City is a required field. <br />';
          }
    
          if (empty ($_POST['state'])) {
    $problem = TRUE;
    $error .= 'State is a required field. <br />';
          }
    
          if (empty ($_POST['zip'])) {
    $problem = TRUE;
    $error .= 'Zip is a required field. <br />';
          }
    
    
    
    
    
    if (!$problem) {
    
    $_SESSION['city'] = ucwords($_POST['city']);
    $_SESSION['state'] = strtoupper($_POST['state']);
    
    $_SESSION['zip'] = $_POST['zip'];
    $_SESSION['street'] = $_POST['street'];
    $_SESSION['tempaddress'] = 1;
    
                          header("Location: index.php?page=checkout");
    
    
    }
    
    }
    
    
    
    
    $content .= "
    <p><u><a href=\"index.php?page=accounthome\">$plantloc</a></u> - Alternate Address </p>
    
    <form action=\"index.php?page=checkout&alternate=change\" method=\"post\">
    Street:<br />
    <input type=\"text\" size=\"20\" name=\"street\" value=\"$_POST[street]\" /><br /><br />
    <table><tr><td>
    City:
    </td><td>
    State:
    </td><td>
    Zip:
    </td></tr>
    <tr><td>
    <input type=\"text\" size=\"10\" name=\"city\" value=\"$_POST[city]\" />
    </td><td>
    <input type=\"text\" size=\"2\" name=\"state\" value=\"$_POST[state]\" />
    </td><td>
    <input type=\"text\" size=\"5\" name=\"zip\" value=\"$_POST[zip]\" />
    </td></tr></table>
    <br />
    <input type=\"submit\" name=\"submit\" class=\"textfield\" value=\"Submit Address\" />
    </form>
    ";
    
    
    
    
    } else {
    

    This is the code that I use to set the session variables (the form and processing code)

     

     

    This is where I am taking it and setting my current address (be it the regular or temporary changed one)

    if ($_SESSION['tempaddress'] == 1){
    $displayaddress = "
    $_SESSION[street]<br />
    $_SESSION[city], $_SESSION[state] $_SESSION[zip]<br />
    ";
    }
    
    
    if ($_SESSION['tempaddress'] == 1) {
    $address2 = $displayaddress;
    } else {
    $address2 = $address;
    }
    

     

     

    $address2 displays the stored database information regardless of if I set the session or not..

  16.       if (!isset($_POST['checktos'])) {
    $problem = TRUE;
    $error .= 'You must agree to the Terms of Service to complete your order. <br />';
          }
    

     

    <p align=right><input type=\"submit\" name=\"submit\" class=\"textfield\" value=\"Checkout\" /></p>
    

     

     

    I just want to check if the box is checked, I've gone through about 10 different ideas and nothing is displaying the error when it isn't checked. I'm completely confused.

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