ponx82 Posted May 11, 2010 Share Posted May 11, 2010 Alright so i'm writing a E-commerce website for school project, and i'm missing the littlest thing and I can't see it and my classmates can't either. Can someone please help me? The problem is that you click on a product and select quantity then when you go to the "shopping cart" page it shows you how much your total is and what you ordered, << up to now everything shows up in the mysql prompt when you do "select * from order_details. then it goes to a page that allows you to put in your name address bla bla bla << THIS does not show up in the mysql prompt when you do "select * from customers". This is the page that puts all of this into action, *and not into action* ------------------------------------------------------------------- <? include("includes/db.php"); include("includes/functions.php"); //error_reporting(~E_NOTICE); if(isset($_GET['action'])){ $name=$_GET['name']; $email=$_GET['email']; $address=$_GET['address']; $phone=$_GET['phone']; $customerid=mysql_insert_id(); mysql_query("insert into customers values($customerid,$name,$email,$address,$phone)"); $orderid=mysql_insert_id(); $date=date('YY-mm-dd'); mysql_query("insert into orders values($orderid,$date,$customerid)"); $max=count($_SESSION['cart']); for($i=0;$i<$max;$i++){ $pid=$_SESSION['cart'][$i]['productid']; $q=$_SESSION['cart'][$i]['qty']; $price=get_price($pid); mysql_query("insert into order_detail values ($orderid,$pid,$q,$price)"); unset($_SESSION['cart']); } die('Thank You! your order has been placed! <br> <br> <a href="products.php">Go to the Product Page</a>'); } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Billing Info</title> <script language="javascript"> function validate(){ var f=document.form1; if(f.name.value==''){ alert('Your name is required'); f.name.focus(); return false; } if(f.address.value==''){ alert('Your address is required'); f.address.focus(); return false; } if(f.email.value==''){ alert('Your email is required'); f.email.focus(); return false; } if(f.phone.value==''){ alert('Your phone is required'); f.phone.focus(); return false; } f.action.value='update'; f.submit(); } </script> </head> <body> <form name="form1" onsubmit="return validate()" method="GET"> <input type="hidden" name="action" /> <div align="center"> <h1 align="center">Billing Info</h1> <table border="0" cellpadding="2px"> <tr><td>Order Total:</td><td><?=get_order_total()?></td></tr> <tr><td>Your Name:</td><td><input type="text" name="name" /></td></tr> <tr><td>Address:</td><td><input type="text" name="address" /></td></tr> <tr><td>Email:</td><td><input type="text" name="email" /></td></tr> <tr><td>Phone:</td><td><input type="text" name="phone" /></td></tr> <tr><td> </td><td><input type="submit" value="Place Order" /></td></tr> </table> </div> </form> </body> </html> ---------------------------------------------------------- Someone please help it's been since friday i've been trying to figure it out and I know it's the littlest thing that isn't working... If you need more info just ask I dont know what else to say or put on here that would make it easier... Thanks!! Quote Link to comment https://forums.phpfreaks.com/topic/201364-please-help-im-missing-something-here-and-i-cant-see-it/ Share on other sites More sharing options...
Muddy_Funster Posted May 11, 2010 Share Posted May 11, 2010 I'm probably not alone here, but I really can be bothered looking at your code for you when you can't even be bothered to enclose it in the proper tags (and if your thinking about the "I didn't know about those" then you clearly didn't bother to read the 'Rules & TOS' before you posted either). Although, that siad...Why the hell do you have an unconditional die statement in the middle of your page? Quote Link to comment https://forums.phpfreaks.com/topic/201364-please-help-im-missing-something-here-and-i-cant-see-it/#findComment-1056475 Share on other sites More sharing options...
ignace Posted May 11, 2010 Share Posted May 11, 2010 <? should be <?php ALWAYS //error_reporting(~E_NOTICE); should be error_reporting(E_ALL); ALWAYS $customerid=mysql_insert_id(); only works after you actually inserted something mysql_query("insert into customers values($customerid,$name,$email,$address,$phone)"); this query fails everytime use ' to surround the values mysql_query("insert into orders values($orderid,$date,$customerid)"); same as before $date=date('YY-mm-dd'); seriously consult the manual on date <?=get_order_total()?> should be <?php echo get_order_total(); ?> validate both client and server-side as the client can disable JS Quote Link to comment https://forums.phpfreaks.com/topic/201364-please-help-im-missing-something-here-and-i-cant-see-it/#findComment-1056548 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.