Jump to content

KevinM1

Moderators
  • Posts

    5,222
  • Joined

  • Last visited

  • Days Won

    26

Everything posted by KevinM1

  1. I hate to keep bumping this up, but the only thing stopping my site from going live is this error, which, for the life of me, I cannot solve. To recap: I have a script, named viewitem.php, that [i]should[/i] allow the user to move back one step to a script named viewcat.php.  This navigation is performed by a small, simple form at the bottom of viewitem.php.  The problem is, rather than bring the user to viewcat.php, it instead brings the user to the startpage.  I'm thinking that this may be caused by viewcat.php's automatic redirection if the get part of its url is not set, but I explicitly make sure that viewitem.php's header call includes the category value that viewcat.php expects.  I'm going to post both scripts below. viewitem.php: [code] <?php #viewitem.php script session_start(); ob_start(); include('../php_config/config.php'); include('../dbconnect.php'); include('../templates/sub_header.inc'); if(isset($_GET['cat'])){   $tableName = $_GET['cat']; } else{   $_SESSION['ip'] = urlencode(serialize($ip));   $_SESSION['myCart'] = urlencode(serialize($myCart));   header("Location: http://www.thinkingmachinestore.com/");   exit(); } if(isset($_GET['id'])){   $id = $_GET['id']; } else{   $_SESSION['ip'] = urlencode(serialize($ip));   $_SESSION['myCart'] = urlencode(serialize($myCart));   header("Location: http://www.thinkingmachinestore.com/");   exit(); } if(isset($_POST['back'])){ //<-- the condition that doesn't seem to be working   $_SESSION['ip'] = urlencode(serialize($ip));   $_SESSION['myCart'] = urlencode(serialize($myCart));   header("Location: http://www.thinkingmachinestore.com/viewcat.php?cat={$_POST['tableName2']}");   exit(); } if(isset($_POST['restart'])){   $_SESSION['ip'] = urlencode(serialize($ip));   $_SESSION['myCart'] = urlencode(serialize($myCart));   header("Location: http://www.thinkingmachinestore.com/");   exit(); } $query = "SELECT * FROM $tableName WHERE {$tableName}_id = '$id'"; $result = mysql_query($query); $row = mysql_fetch_assoc($result); $description = nl2br($row['description']); $src = $row['pic_url']; $name = $row['name']; $price = $row['price']; //start outputting the product info echo <<<EOT   <div style='text-align: center;'><a href='checkout.php'><img src='images/store/storefront_02a.jpg' alt='' /></a><img src='../images/store/{$tableName}_banner.jpg' alt='' style='margin-top: 5px;' /><a href='viewcart.php'><img src='../images/store/storefront_02.jpg' alt='View Cart' /></a><br /><div id='leftside'>\n<img src='$src' alt='' />   <br />\n<p style='text-align: left;'>$description</p></div>\n EOT; ?> <form name="iteminfo" action="addcart.php" method="post" style="margin-left: auto; margin-right: auto; text-align: center;">   Quantity: <input name="quantity" type="text" size="4" maxlength="4"/>   <input type="submit" value="Put in cart" />   <input name="name" type="hidden" value="<?php echo $name; ?>" />   <input name="price" type="hidden" value="<?php echo $price; ?>" />   <input name="tableName" type="hidden" value="<?php echo $tableName; ?>" />   <input name="id" type="hidden" value="<?php echo $id; ?>" /> </form> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <?php // <-- the form in question ?>   <input type="hidden" name="tableName2" value="<?php echo $tableName; ?>" />   <input type="submit" name="back" value="Go Back" /><input type="submit" name="restart" value="Go Back to the Beginning" /> </form> <?php include('../templates/sub_footer.inc'); ?> [/code] viewcat.php: [code] <?php #viewcat.php script session_start(); ob_start(); include('../php_config/config.php'); include('../dbconnect.php'); include('../templates/sub_header.inc'); if(isset($_GET['cat'])){   $tableName = $_GET['cat']; } else{ // <-- the segment of code that redirects the user back to the start if, for some reason, they don't select a category to view   $_SESSION['ip'] = urlencode(serialize($ip));   $_SESSION['myCart'] = urlencode(serialize($myCart));   header("Location: http://www.thinkingmachinestore.com/");   exit(); } if(isset($_POST['submit'])){   $_SESSION['ip'] = urlencode(serialize($ip));   $_SESSION['myCart'] = urlencode(serialize($myCart));   header("Location: http://www.thinkingmachinestore.com/");   exit(); } $query = "SELECT * FROM $tableName WHERE availability='y'"; $result = mysql_query($query); echo "<div style='margin-left: auto; margin-right: auto; text-align: center;'><a href='checkout.php'><img src='images/store/storefront_02a.jpg' alt='' /></a><img src='../images/store/{$tableName}_banner.jpg' alt='' style='margin-top: 5px;' /><a href='viewcart.php'><img src='../images/store/storefront_02.jpg' alt='View Cart' /></a>\n<br /><br />\n"; $count = 0; while($row = mysql_fetch_assoc($result)){   $id = $row["$tableName" . "_id"];   $pic = $row["pic_url"];   echo "<a href='viewitem.php?cat=$tableName&id=$id'><img src='$pic' alt='' /></a>";   $count++;   if($count == 2){       echo "<hr /><br />\n";       $count = 0;   } } ?> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <input type="submit" name="submit" value="Go Back" /> </form></div> <?php include('../templates/sub_footer.inc'); ?> [/code] Like I said above, I wouldn't think that viewcat.php's redirect would be invoked since I explicitly set a category in my header call in viewitem.php.  That said, I can't see anything else that would be causing this problem. Please help.
  2. Anyone able to help me out with this?  Anyone?  Bueller?
  3. [quote author=ted_chou12 link=topic=124014.msg516148#msg516148 date=1170085345] so there are two variables you want to pass from viewitem.php to viewcat.php, is that true? and you pass these two variables through the url. However, your back button is suppose to bring the user to viewcat.php from viewitem.php, is it true? correct me if i am wrong. Ted [/quote] There are two values that are passed from viewcat.php to viewitem.php -- the category name and the item id.  In order to go back one step (from viewitem.php back to viewcat.php), all that's needed is the category name (I call it $tableName in my script).  But, for some reason, that button is taking me back to storefront.php, almost as though both submit buttons are being checked by just one of my isset conditionals (if(isset($_POST['restart'])){...} instead of if(isset($_POST['back'])){...}).
  4. [quote author=ted_chou12 link=topic=124014.msg516134#msg516134 date=1170084565] inorder to make my life easier, :) what is the url for: 1. the previous page 2. the back page Ted [/quote] The url is for the back page.  The logical order is: storefront.php (which is where the "Go Back to the Beginning" submit button is supposed to take the user) -> viewcat.php?cat=something (short for view category.  link is derived by the value passed to it by storefront.php via the GET method) -> viewitem.php?cat=something&id=somethingelse (cat and id obtained via GET... this is the problem script -- I want the "Go Back" submit button to bring the user back to viewcat.php, not storefront.php like it is currently). As you can see, the "Go Back" button is supposed to use an HTML header to redirect the user back to viewcat.php?cat={$tableName}, but instead it's bring me back to storefront.php.
  5. Hate to bump this up, but I still haven't figured it out.  The code looks fine to me and my somewhat untrained eye.  Please help.
  6. [quote author=SemiApocalyptic link=topic=124014.msg513424#msg513424 date=1169753299] Is $_GET['cat'] and $_GET['id'] set on the page that you're clicking the back button? [/quote] Yes, the viewcat.php script passes the cat and id values to viewitem.php via the GET method. I tried explicitly passing the $tableName value retrieved by cat by using a hidden input, but it still hasn't helped.  I'll post my code below.  I did try giving my hidden tableName input a different name, in case there was a naming conflict, but that didn't help. [code] <?php #viewitem.php script session_start(); ob_start(); include('../php_config/config.php'); include('../dbconnect.php'); include('../templates/sub_header.inc'); if(isset($_GET['cat'])){   $tableName = $_GET['cat']; } else{   $_SESSION['ip'] = urlencode(serialize($ip));   $_SESSION['myCart'] = urlencode(serialize($myCart));   header("Location: http://www.thinkingmachinestore.com/storefront.php");   exit(); } if(isset($_GET['id'])){   $id = $_GET['id']; } else{   $_SESSION['ip'] = urlencode(serialize($ip));   $_SESSION['myCart'] = urlencode(serialize($myCart));   header("Location: http://www.thinkingmachinestore.com/storefront.php");   exit(); } if(isset($_POST['back'])){   $_SESSION['ip'] = urlencode(serialize($ip));   $_SESSION['myCart'] = urlencode(serialize($myCart));   header("Location: http://www.thinkingmachinestore.com/viewcat.php?cat={$_POST['tableName']}");   exit(); } if(isset($_POST['restart'])){   $_SESSION['ip'] = urlencode(serialize($ip));   $_SESSION['myCart'] = urlencode(serialize($myCart));   header("Location: http://www.thinkingmachinestore.com/storefront.php");   exit(); } $query = "SELECT * FROM $tableName WHERE {$tableName}_id = '$id'"; $result = mysql_query($query); $row = mysql_fetch_assoc($result); $description = nl2br($row['description']); $src = $row['pic_url']; $name = $row['name']; $price = $row['price']; //start outputting the product info echo <<<EOT   <div style='text-align: center;'><a href='checkout.php'><img src='images/store/storefront_02a.jpg' alt='' /></a><img src='../images/store/{$tableName}_banner.jpg' alt='' style='margin-top: 5px;' /><a href='viewcart.php'><img src='../images/store/storefront_02.jpg' alt='View Cart' /></a><br /><div id='leftside'>\n<img src='$src' alt='' />   <br />\n<p style='text-align: left;'>$description</p></div>\n EOT; ?> <form name="iteminfo" action="addcart.php" method="POST" style="margin-left: auto; margin-right: auto; text-align: center;">   Quantity: <input name="quantity" type="text" size="4" maxlength="4"/>   <input type="submit" value="Put in cart" />   <input name="name" type="hidden" value="<?php echo $name; ?>" />   <input name="price" type="hidden" value="<?php echo $price; ?>" />   <input name="tableName" type="hidden" value="<?php echo $tableName; ?>" />   <input name="id" type="hidden" value="<?php echo $id; ?>" /> </form> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST">   <input type="hidden" name="tableName" value="<?php echo $tableName; ?>" />   <input type="submit" name="back" value="Go Back" /><input type="submit" name="restart" value="Go Back to the Beginning" /> </form> <?php include('../templates/sub_footer.inc'); ?> [/code]
  7. I have a form with two submit buttons.  One is supposed to take the user to the previous page, the other to the starting page.  The second button works fine, but the first also takes the user to the starting page.  I've looked over the code a few times and can't find the problem.  Below is my code.  The form in question is at the bottom, with the submit button named 'back' the source of the problem.  Please help. [code] <?php #viewitem.php script session_start(); ob_start(); include('../php_config/config.php'); include('../dbconnect.php'); include('../templates/sub_header.inc'); if(isset($_GET['cat'])){   $tableName = $_GET['cat']; } else{   $_SESSION['ip'] = urlencode(serialize($ip));   $_SESSION['myCart'] = urlencode(serialize($myCart));   header("Location: http://www.thinkingmachinestore.com/storefront.php");   exit(); } if(isset($_GET['id'])){   $id = $_GET['id']; } else{   $_SESSION['ip'] = urlencode(serialize($ip));   $_SESSION['myCart'] = urlencode(serialize($myCart));   header("Location: http://www.thinkingmachinestore.com/storefront.php");   exit(); } if(isset($_POST['back'])){   $_SESSION['ip'] = urlencode(serialize($ip));   $_SESSION['myCart'] = urlencode(serialize($myCart));   header("Location: http://www.thinkingmachinestore.com/viewcat.php?cat={$tableName}");   exit(); } if(isset($_POST['restart'])){   $_SESSION['ip'] = urlencode(serialize($ip));   $_SESSION['myCart'] = urlencode(serialize($myCart));   header("Location: http://www.thinkingmachinestore.com/storefront.php");   exit(); } $query = "SELECT * FROM $tableName WHERE {$tableName}_id = '$id'"; $result = mysql_query($query); $row = mysql_fetch_assoc($result); $description = nl2br($row['description']); $src = $row['pic_url']; $name = $row['name']; $price = $row['price']; //start outputting the product info echo <<<EOT   <div style='text-align: center;'><a href='checkout.php'><img src='images/store/storefront_02a.jpg' alt='' /></a><img src='../images/store/{$tableName}_banner.jpg' alt='' style='margin-top: 5px;' /><a href='viewcart.php'><img src='../images/store/storefront_02.jpg' alt='View Cart' /></a><br /><div id='leftside'>\n<img src='$src' alt='' />   <br />\n<p style='text-align: left;'>$description</p></div>\n EOT; ?> <form name="iteminfo" action="addcart.php" method="POST" style="margin-left: auto; margin-right: auto; text-align: center;">   Quantity: <input name="quantity" type="text" size="4" maxlength="4"/>   <input type="submit" value="Put in cart" />   <input name="name" type="hidden" value="<?php echo $name; ?>" />   <input name="price" type="hidden" value="<?php echo $price; ?>" />   <input name="tableName" type="hidden" value="<?php echo $tableName; ?>" />   <input name="id" type="hidden" value="<?php echo $id; ?>" /> </form> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST">   <input type="submit" name="back" value="Go Back" /><input type="submit" name="restart" value="Go Back to the Beginning" /> </form> <?php include('../templates/sub_footer.inc'); ?> [/code]
  8. I consider myself to be a beginner with PHP.  I know syntax (more or less), but the actual computer [i]science[/i] part of things is lagging behind.  I'm a much better procedural programmer than OO programmer, but I'd love to get fluent with the OO side of things (beyond, of course, knowing how to construct classes and instantiate objects), but some of the patterns I've read are a bit baffling (example: is there any real difference between the factory method of generating objects and the abstract factory method?). I'm basically useless on the MySQL side of things.  The syntax is a bit..clunky, which has been slowing me down.  I can use phpMyAdmin, though. ;) I'm okay with newbie JavaScript, but I really haven't found a place to use it.  The bulk of what I can do can be replaced by either CSS (yay mouseovers) or PHP (for not having to deal with the client/server variable passing mess). I'm pretty good with CSS.  Positioning still screws me up from time to time, as well as the cross-browser issues (a lot of which fall into the positioning category).  It took me forever to get comfortable with doing more than changing a font's attributes, though.  They never taught us the box model in my university's web development class, so I basically had a CSS epiphany when I learned it.
  9. I'm trying to float two images to the left and right of a div, respectively, with a third item in the middle.  Since the images are small, they looked out of place when I enlarged them and floated all three to the left.  So, now I'm trying to float one left, one right, and leave the middle one alone (the div has text-align: center, so the middle image should be centered).  Unfortunately, my right-floated image keeps jumping down a line, so it looks pretty bad.  I tried restricting the containing div's height to 90px, but this hasn't helped the problem. The problem can be seen at http://www.thinkingmachinestore.com/storefront.php.  I've put a black border around the div in question.  Interestingly, in IE7, it looks like the incorrectly floated image stretches the div vertically.  In Firefox, the div is the correct height, with the incorrectly floated image overlapping the lower-right border. Please help. Thanks :)
  10. The things I'm interested in reading about re: PHP6 is namespaces and the new OOP goodies they're including.  I never got into namespaces in college...dropped out of the cs department before I got to that point.  Is it basically just a way for a coder to create their own named local scope?  Or is it something else?  Also, any word on if PHP6 will allow for multiple inheritance or true polymorphism?
  11. [quote author=businessman332211 link=topic=122655.msg506229#msg506229 date=1168970552] ;D I never had experience specifically with GOTO, I know it's a way a lot of the older programmers use to have to program in other languages.  I have heard that it is used heavily in other languages too Does it have anything to do with OOP? [/quote] This was my professors' stance on GOTO: GOTO is used primarily by those 'programmers' who are too lazy/ignorant to write correctly formed, logical code.  Since they all had their Ph. d's in computer science, and had 20+ years of experience with C, C++, assembly, and other things, I'll trust their judgement on this. GOTO has nothing to do with OOP.  It basically just says "Go to this specified chunk (line) of code when a certain condition is met."  It's power comes from it not being limited in scope.  It's a very powerful feature, and as such, a lot of newbie coders rely on it because it's so easy to use. The problem is that this leads to spaghetti code, which is both hard to read and hard to extend/fix because of the tight coupling it produces.  A change in one part of code will create problems that cascade throughout the rest of the code.  This is the antithesis of OOP, whose design philosophy is to [i]reduce or negate[/i] coupling.  The pinnacle of OOP code should be seen as modularity -- something beneficial that can be plugged into code without screwing things up and without needing much (if any) modification of the original code in order to work.
  12. [quote author=Crayon Violent link=topic=122655.msg506206#msg506206 date=1168969006] uh...the word 'sarcasm' comes to mind... [/quote] Yeah, I was just about to post the same thing, in addition that, in my experience, most programmers treat GOTO as a (bad) four-letter word.  Hell, in my university, any student caught using GOTO would automatically fail that assignment.
  13. Still haven't found the answer myself, so bumpity bump bump.
  14. I figured I'd ressurect this thread, as I seem to be having more centering issues. In both my viewitem.php (since the page is created dynamically based on what the user clicks (yay $_GET), here's an instance of the problem: http://www.thinkingmachinestore.com/viewitem.php?cat=lenovo_desktops&id=1) and my checkout.php page (http://www.thinkingmachinestore.com/checkout.php), Firefox is ignoring my CSS that should be centering the contents of the lower table cell.  What's strange is that the lower-most form inputs are centered, but the rest isn't.  I use a bit of floating positioning for the form in checkout.php, so I couldn't be surprised if there was a conflict there, but my viewitem.php has no floats to interfere with the main div's positioning.  Everything appears correct in IE7. Any ideas?
  15. Turns out I'm an idiot...I should be checking for numbers 10-11 digits long.  I need more caffiene.... Thanks for responding! :)
  16. I have a simple form in which I ask the user to enter in the telephone number of their credit card company.  I try validating that it's either a 16 digit number (normal telephone number) or a 17 digit number (telephone number beginning with a 1, like 1800 something).  Unfortunately, it doesn't seem to be working as I keep getting my error message which is created if the field fails the test. My validation is: [code] <?php   if(!empty($_POST['bank_num']) && preg_match("/^[0-9]{16,17}$/i", $_POST['bank_num'])){       $bankNum = $_POST['bank_num'];       $bn = TRUE;   }   else{       $errMessage .= "Please enter your credit card's telephone number!<br />\n";   } ?> [/code] I know I don't need to tell it to be case insensative in this case, but I wouldn't think that would be the cause of the error (especially as both validating one's home phone number and their credit card's CID seem to work correctly with it like that).  Any ideas on why I'm getting my error message, even if I input the correct number of digits?
  17. Aha, I knew it had to be something dumb on my part! Thanks. :)
  18. Hate to bump this up, but an answer would be nice. ;)
  19. $tablename is simply created through a $_GET assignment: [code] <?php $tablename = $_GET['cat']; ?> [/code] My full script is: [code] <?php #viewcat.php script session_start(); ob_start(); include('../php_config/config.php'); include('../dbconnect.php'); include('../templates/sub_header.inc'); if(isset($_GET['cat'])){    $tableName = $_GET['cat']; } else{    $_SESSION['ip'] = urlencode(serialize($ip));    $_SESSION['myCart'] = urlencode(serialize($myCart));    header("Location: http://www.thinkingmachinestore.com/storefront.php");    exit(); } $query = "SELECT * FROM $tableName WHERE availability='y'"; $result = mysql_query($query); echo "<div style='margin-left: auto; margin-right: auto; text-align: center;'><img src='../images/store/{$tablename}_banner.jpg' alt='' /><a href='viewcart.php'><img src='../images/store/storefront_02.jpg' alt='View Cart' /></a>\n<br /><br />\n"; $count = 0; while($row = mysql_fetch_assoc($result)){    $id = $row["$tableName" . "_id"];    $pic = $row["pic_url"];    echo "<a href='viewitem.php?cat=$tableName&id=$id'><img src='$pic' alt='' /></a>";    $count++;    if($count == 2){       echo "<br />\n";       $count = 0;    } } echo "</div>"; include('../templates/sub_footer.inc'); ?> [/code] EDIT: When I remove the brackets from $tablename, my src name actually shrinks to /images/store/.jpg, so that's not the problem.
  20. [quote author=obsidian link=topic=121796.msg501450#msg501450 date=1168451538] Did you actually try giving the containing element a "text-align: center;" and see if you can handle it that way? [/quote] ...Apparently I'm an idiot, heh. ;) Thanks! :D
  21. I'm trying to dynamically create an image's src attribute.  I have the following echo statement: [code] <?php echo "<img src='../images/store/{$tablename}_banner.jpg' alt='' /><a href='viewcart.php'><img src='../images/store/storefront_02.jpg' alt='View Cart' /></a>\n\n<div>"; ?> [/code] The problem is that $tablename is not inserted into the image's src attribute, leaving me with the script trying to display /images/store/_banner.jpg, which is definitely not what I want.  Please help.
  22. I'm trying to center the laptop and desktop images for my work's storefront page (found at http://www.thinkingmachinestore.com/storefront.php), but I can't seem to get them to center at all.  They stay glued to the left of the table cell*, even when I use margin-left: auto, margin-right: auto.  Any ideas?
  23. I hate to bump this up, but I still haven't found the solution yet.  Anyone mind helping?  Anyone?  Bueller?
  24. [quote author=Jay2391 link=topic=120690.msg495465#msg495465 date=1167761750] one more ? I put this on my session test ... but it won't show the name,  if I put the $_SESSION['fname'] in a variable if i do           """"       echo $_SESSION['fname'];      """""  that display the name but when i do a variable like below it just show """""   You are loged In """"" <?php session_start();         if($_SESSION['session_var'] == "skipLogin"){            $_SESSION['fname'] = $fname;            echo "You are loged In $fname";               }else{           echo "You stinky";     } ?> [/quote] You have to remember how variable assignment works.  The left side of the statement is assigned the value of the right side.  So, if you haven't defined $fname in your script, you're merely overwriting your session variable with an empty local variable, hence no output.  Since it looks like you're trying to assign a local variable the contents of your session variable, switch the statement around.  In other words: $fname = $_SESSION['fname'];
  25. I'm still in the process of creating my work's online store.  Since we're small, my boss decided that the design shouldn't be fully automated, so upon checkout, we're sent an e-mail with the order the customer wants, which we then use to contact our distributor in order to fulfill that order (clunky and inefficient, I know...not my choice).  I figured the easiest way to put a person's shopping cart in an e-mail would be to use the __toString magic method.  Unfortunately, I keep getting 'Object id #1' instead of the products in my cart.  Here's the relevant bits of ShoppingCart code: [code] <? class ShoppingCart{   private $Cart = array();   public function addProduct($name, $price, $quantity){       $this -> Cart[] = new Product($name, $price, $quantity);   } . . . public function getTotal(){       $total = 0;       foreach($this -> Cart as $value){         $total += $value -> getPrice();       }       return $total;   }   public function __toString(){       $message = NULL;       $message .= "Name:\tQuantity\tPrice:\n";       foreach($this -> Cart as $value){         $message .= "{$value->getName()}\t{$value->getQuan()}\t{$value->getPrice()}\n";       }       $message .= "\t\t\t--------\nTotal:\t\t{$this->getTotal()}";       return $message;   } . . . ?> [/code] And here's my checkout script: [code] <?php #checkout.php include('../php_config/config.php'); include('../templates/header.inc'); $errMessage = NULL; $mailMessage = NULL; if(isset($_POST['submit'])){   if(!empty($_POST['name']) && preg_match("/^[a-zA-Z]+([ a-zA-Z-]+)*$/i", $_POST['name'])){       $name = $_POST['name'];       $n = TRUE;   }   else{       $errMessage .= "Please enter your name!<br />\n";   }   if(!empty($_POST['address1']) && preg_match("/^[0-9a-zA-Z\.\-\ ]+$/i", $_POST['address1'])){       $address1 = $_POST['address1'];       $a1 = TRUE;   }   else{       $errMessage .= "Please enter your address!<br />\n";   }   if(!empty($_POST['address2']) && preg_match("/^[0-9a-zA-Z\.\-\ ]+$/i", $_POST['address2'])){       $address2 = $_POST['address2'];   }   else{       $address2 = '';   }   if(!empty($_POST['city']) && preg_match("/^[a-zA-Z\.\-\ ]+$/i", $_POST['city'])){       $city = $_POST['city'];       $c = TRUE;   }   else{       $errMessage .= "Please enter your city!<br />\n";   }   if(!empty($_POST['state']) && preg_match("/^[a-zA-Z]{2}$/i", $_POST['state'])){       $state = $_POST['state'];       $s = TRUE;   }   else{       $errMessage .= "Please enter your state!<br />\n";   }   if(!empty($_POST['zipcode']) && preg_match("/^[0-9]{5}([\-0-9]{4})?$/i", $_POST['zipcode'])){       $zipcode = $_POST['zipcode'];       $z = TRUE;   }   else{       $errMessage .= "Please enter your zipcode!<br />\n";   }   if($n && $a1 && $c && $s && $z){       $mailMessage .= "$name\n$address1\n$address2\n$city, $state $zipcode\n\n$myCart";       mail('kevin@thinkingmachineonline.com', 'Test message', $mailMessage);       echo "Your mail has been sent, $name<br />\n";   }   else{       echo "<div style='color: red;'>$errMessage</div>\n";   } } ?> <form name="checkout" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST">   Name: <input type="text" name="name" value="<?php if(isset($_POST['name'])) echo $_POST['name']; ?>" /><br />   Address 1: <input type="text" name="address1" value="<?php if(isset($_POST['address1'])) echo $_POST['address1']; ?>" /><br />   Address 2: <input type="text" name="address2" value="<?php if(isset($_POST['address2'])) echo $_POST['address2']; ?>" /><br />   City: <input type="text" name="city" value="<?php if(isset($_POST['city'])) echo $_POST['city']; ?>" /><br />   State: <input type="text" name="state" value="<?php if(isset($_POST['state'])) echo $_POST['state']; ?>" /><br />   Zipcode: <input type="text" name="zipcode" value="<?php if(isset($_POST['zipcode'])) echo $_POST['zipcode']; ?>" /><br />   <input type="submit" name="submit" value="Checkout" /> </form> <?php $_SESSION['myCart'] = NULL; $_SESSION['ip'] = urlencode(serialize($ip)); ob_end_flush(); ?> [/code] I'm thinking that the error may have something to do with the cart calling getTotal on itself...my syntax is probably wrong there.  Other than that, though, I'm at a loss as to why it's not working.  Please help.
×
×
  • 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.