dh526 Posted May 25, 2009 Share Posted May 25, 2009 Hi, I'm trying to create a simple shop system with MS Access. I want to choose which product to buy, then when you click buy go to a confirm order page, then actually buy the item. Currently only the 1st of these works. I don't know if my method is correct, but any help would be massively appreciated subscribe.php <?php if (isset($_COOKIE['username'])) {$username= $_COOKIE['username']; $set = 1 ;} else { $set=0; } ?> <!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>tech!</title> <LINK href="favicon.ico" rel="favicon" /> <link rel="stylesheet" type="text/css" href="style.css" /> <script type="text/javascript" src="js/jquery.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("#zone-bar li em").click(function() { var hidden = $(this).parents("li").children("ul").is(":hidden"); $("#zone-bar>ul>li>ul").hide() $("#zone-bar>ul>li>a").removeClass(); if (hidden) { $(this) .parents("li").children("ul").toggle() .parents("li").children("a").addClass("zoneCur"); } }); }); </script> </head> <body> <div id="page-wrap"> <div id="top-bar"> <a href="index.php"> <img src="images/logo.png" alt="DZone" class="floatleft height="200" width="500" /> </a> <div id="right-side"> <img src="images/usericon.jpg" alt="user icon" /> <?php if ($set==1) { echo "<a href='signedin.php'>$username</a> <a href='cart.php'>Basket</a>"; } else { echo "<a href='login1.php'>login</a> <a href='register1.php'>register</a>"; } ?> <a href="logout.php"> logout </a> <form id="main-search"> <label for="search-field" id="search-field-label">Search</label> <input type="text" tabindex="1" maxlength="255"id="search-field"/> <input type="image" alt="Search" value="Search" src="images/search.png" id="search-button"/> </form> </div> </div> <div id="zone-bar"> <ul> <li> <a href="#"><span> News <em class="opener-news"> <img src="images/zonebar-downarrow.png" alt="dropdown" padding="5px" /> </em> </span></a> <ul class="Newssublist"> <li><a href="#">Gaming</a></li> <li><a href="#">Audio</a></li> <li><a href="#">Visual</a></li <li><a href="#">Travel</a></li> <li><a href="#">Computing</a></li> <li><a href="#">Photography</a></li> <li><a href="#">Software</a></li> <li><a href="#">Outdoor</a></li> </ul> </li> <li> <a href="#"><span> Reviews <em class="opener-reviews"> <img src="images/zonebar-downarrow.png" alt="dropdown" padding= "5px" /> </em> </span></a> <ul class="reviewssublist"> <li><a href="#">Top 10's</a></li> <li><a href="#">Gaming</a></li> <li><a href="#">Audio</a></li> <li><a href="#">Visual</a></li> <li><a href="#">Travel</a></li> <li><a href="#">Computing</a></li> <li><a href="#">Photography</a></li> <li><a href="#">Software</a></li> <li><a href="#">Outdoor</a></li> </ul> </li> <li> <a href="#"><span> Shop <em class="opener-shop"> <img src="images/zonebar-downarrow.png" alt="dropdown" padding = "5px" /> </em> </span></a> <ul class="shopsublist"> <li><a href="#">Subscribe</a></li> <li><a href="#">Back Issues</a></li> <li><a href="#">Merchandise</a></li> </ul> </li> <li> <a href="#"><span> Competitions <em class="opener-competitions"> <img src="images/zonebar-downarrow.png" alt="dropdown" /> </em> </span></a> <ul class="competitionsublist"> <li><a href="#">New Competition</a></li> <li><a href="#">Previous Winners</a></li> </ul> </li> <li> <a href="#"><span> Photos <em class="opener-photos"> <img src="images/zonebar-downarrow.png" alt="dropdown" /> </em> </span></a> <ul class="photosublist"> <li><a href="#">Tech! things</a></li> <li><a href="#">Tech! places</a></li> <li><a href="#">Tech! people</a></li> </ul> </li> <li> <a href="#"><span> Video <em class="opener-video"> <img src="images/zonebar-downarrow.png" alt="dropdown" /> </em> </span></a> <ul class="videosublist"> <li><a href="#">Gaming</a></li> <li><a href="#">Movies</a></li> <li><a href="#">Music</a></li> <li><a href="#">Television</a></li> <li><a href="#">Comics & Animation</a></li> </ul> </li> <li> <a href="#"><span> About Us <em class="opener-aboutus"> <img src="images/zonebar-downarrow.png" alt="dropdown" /> </em> </span></a> <ul class="aboutussublist"> <li><a href="#">What we do</a></li> <li><a href="#">Jobs at tech!</a></li> <li><a href="#">Contact us</a></li> </ul> </li> </div> <div id='main-content'> <div id='feature-content'> <div id='feature-left'> <h1><a href="#">Subscribe</a></h1> <?php if ($set==1) { echo "<br><br><h2>6 months subscription</h2><br><img src='magazine.png', width='100%'/><br><br><form method='POST' action='basket.php'><table><tr><td> Price : </td> <td> £20 <input type='hidden' name='product' value='1'/></td> </tr><tr><td> Description : </td> <td> 6 issues of tech! magazine delivered to your door </td></tr><tr><td> <input type='submit' value='Buy 6 months subscription Now' value='1'></td></tr></table></form><img src='line1.png' width='100%'><br><br><br><br><h2>12 months subscription </h2><br><img src='magazine.png', width='100%'/><br><br><form method='POST' action='basket.php'><table><tr><td> Price : </td> <td> £30 <input type='hidden' name='product' value='2'/></td></tr><tr><td> Description : </td> <td> 12 issues of tech! magazine delivered to your door </td></tr><tr><td> <input type='submit' value='Buy 12 months subscription Now'></td></tr></table></form><br><img src='line1.png' width='100%'><br><br>"; } else { echo "You need to be signed in to view this page : please <a href='login1.php'>login</a> or <a href='register1.php'>register</a>"; } ?> </div> <div id='feature-right'> <div class='feature-mini'> <h2><a href='subscribe.html'>Subscribe</a></h2> <br> <a href='#'><h3>Subscribe to tech! magazine</h3> <img src='images/logo.png' width='100%' /></a> <p> Subscribe! 50% of retail price! That is a saving of £30 per year!...<a href='#'>subcribe</a> </p> <br> <img src='line.png' width='100%'> <br> <br> <p> <a href='twitter.php'><img src='twitter.png' width='100%'></a> <br> <p align='center'> <a href='http://twitter.com/techmaguk'> <h4>Follow us!<h4> </a> </p> </p> <br> <img src='line.png' width='100%'> <br> <br> <h2>Feature</h2> <br> <a href='#'><h3>Dell Adamo vs Mac Air</h3> <br> <img src='adamomac.png' width='100%' /></a> <p> The new adamo has been touted as an Air killer... We test them both...<a href='#'>read more</a> </p> <br> <img src='line.png' width='100%' /> <br> <br> <a href='#'><h3>Windows 7 revealed</h3> <br> <img src="win7.png" width="100%" /></a> <p> Windows 7 revealed, and we have a play with it!...<a href='#'>read more</a> </p> <br> <img src='line.png' width='100%'> <br> <br> </div> <div class="clear"></div> </div> <div class="clear"></div> </div> </div> <div id="footer" align="center"> <a href='#'> | contact us | </a> <a href='#'> Accessibility | </a> </div> </div> </body> </html> basket.php <?php if (isset($_COOKIE['username'])) {$username= $_COOKIE['username']; $set = 1 ; $product=$_POST('product'); setcookie('product', $product, time()+3600); } else { $set=0; } ?> <!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>tech!</title> <LINK href="favicon.ico" rel="favicon" /> <link rel="stylesheet" type="text/css" href="style.css" /> <script type="text/javascript" src="js/jquery.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("#zone-bar li em").click(function() { var hidden = $(this).parents("li").children("ul").is(":hidden"); $("#zone-bar>ul>li>ul").hide() $("#zone-bar>ul>li>a").removeClass(); if (hidden) { $(this) .parents("li").children("ul").toggle() .parents("li").children("a").addClass("zoneCur"); } }); }); </script> </head> <body> <div id="page-wrap"> <div id="top-bar"> <a href="index.php"> <img src="images/logo.png" alt="DZone" class="floatleft height="200" width="500" /> </a> <div id="right-side"> <img src="images/usericon.jpg" alt="user icon" /> <?php if ($set==1) { echo "<a href='signedin.php'>$username</a> <a href='cart.php'>Basket</a>"; } else { echo "<a href='login1.php'>login</a> <a href='register1.php'>register</a>"; } ?> <a href="logout.php"> logout </a> <form id="main-search"> <label for="search-field" id="search-field-label">Search</label> <input type="text" tabindex="1" maxlength="255"id="search-field"/> <input type="image" alt="Search" value="Search" src="images/search.png" id="search-button"/> </form> </div> </div> <div id="zone-bar"> <ul> <li> <a href="#"><span> News <em class="opener-news"> <img src="images/zonebar-downarrow.png" alt="dropdown" padding="5px" /> </em> </span></a> <ul class="Newssublist"> <li><a href="#">Gaming</a></li> <li><a href="#">Audio</a></li> <li><a href="#">Visual</a></li <li><a href="#">Travel</a></li> <li><a href="#">Computing</a></li> <li><a href="#">Photography</a></li> <li><a href="#">Software</a></li> <li><a href="#">Outdoor</a></li> </ul> </li> <li> <a href="#"><span> Reviews <em class="opener-reviews"> <img src="images/zonebar-downarrow.png" alt="dropdown" padding= "5px" /> </em> </span></a> <ul class="reviewssublist"> <li><a href="#">Top 10's</a></li> <li><a href="#">Gaming</a></li> <li><a href="#">Audio</a></li> <li><a href="#">Visual</a></li> <li><a href="#">Travel</a></li> <li><a href="#">Computing</a></li> <li><a href="#">Photography</a></li> <li><a href="#">Software</a></li> <li><a href="#">Outdoor</a></li> </ul> </li> <li> <a href="#"><span> Shop <em class="opener-shop"> <img src="images/zonebar-downarrow.png" alt="dropdown" padding = "5px" /> </em> </span></a> <ul class="shopsublist"> <li><a href="#">Subscribe</a></li> <li><a href="#">Back Issues</a></li> <li><a href="#">Merchandise</a></li> </ul> </li> <li> <a href="#"><span> Competitions <em class="opener-competitions"> <img src="images/zonebar-downarrow.png" alt="dropdown" /> </em> </span></a> <ul class="competitionsublist"> <li><a href="#">New Competition</a></li> <li><a href="#">Previous Winners</a></li> </ul> </li> <li> <a href="#"><span> Photos <em class="opener-photos"> <img src="images/zonebar-downarrow.png" alt="dropdown" /> </em> </span></a> <ul class="photosublist"> <li><a href="#">Tech! things</a></li> <li><a href="#">Tech! places</a></li> <li><a href="#">Tech! people</a></li> </ul> </li> <li> <a href="#"><span> Video <em class="opener-video"> <img src="images/zonebar-downarrow.png" alt="dropdown" /> </em> </span></a> <ul class="videosublist"> <li><a href="#">Gaming</a></li> <li><a href="#">Movies</a></li> <li><a href="#">Music</a></li> <li><a href="#">Television</a></li> <li><a href="#">Comics & Animation</a></li> </ul> </li> <li> <a href="#"><span> About Us <em class="opener-aboutus"> <img src="images/zonebar-downarrow.png" alt="dropdown" /> </em> </span></a> <ul class="aboutussublist"> <li><a href="#">What we do</a></li> <li><a href="#">Jobs at tech!</a></li> <li><a href="#">Contact us</a></li> </ul> </li> </div> <div id='main-content'> <div id='feature-content'> <div id='feature-left'> <h1><a href="#">Subscribe</a></h1> <?php if ($set==1) { $conn=odbc_connect('db09,'',''); $sqladd="SELECT AddressID, HouseNumber, Street, Town, Postcode FROM tblAddress WHERE username=$username"; $sqlcard="SELECT CardID, type, mynum FROM tblCard WHERE username=$username"; $sqlcust="SELECT Forename, Surname, [Email Address] FROM tblCustomer WHERE username=$username"; $sqlprod="SELECT ProductID, Name, Cost, Description FROM tblProducts WHERE ProductID=$product"; $rsadd=odbc_exec($conn, $sqladd); $rscard=odbc_exec($conn, $sqlcard); $rscust=odbc_exec($conn, $sqlcust); $rsprod=odbc_exec($conn, $sqlprod); if (odbc_fetch_row($rsadd)) { $housenumber=odbc_result($rsadd,"HouseNumber"); $street=odbc_result($rsadd,"Street"); $town=odbc_result($rsadd,"Town"); $postcode=odbc_result($rsadd,"Postcode"); $addid=odbc_result($rsadd,"AddressIDID"); } if (odbc_fetch_row($rscard)) { $type=odbc_result($rscard,"HouseNumber"); $mynum=odbc_result($rscard,"Street"); $cardid=odbc_result($rsadd,"CardID"); } if (odbc_fetch_row($rscust)) { $forename=odbc_result($rscust,"Forename"); $surname=odbc_result($rscust,"Surname"); } if (odbc_fetch_row($rsprod)) { $name=odbc_result($rsadd,"Name"); $cost=odbc_result($rsadd,"Cost"); $description=odbc_result($rsadd,"Description"); $prodid=odbc_result($rsadd,"ProductID"); } echo "<h1>Order details</h1><br><br><form Action='buy.php' Method='POST'> Name: $forename $surname <br> Delivery Address: $housenumber $street, $town, $postcode -- <a href='address.php'>add/edit address details</a><br> <br> card used: $type ( $mynyum ) -- <a href='card.php'>add/edit card details</a> <br> <br> <h3>item bought<h3><br> Name:$name <br> Cost: $cost <br> Description:$description <br><br><input type='hidden' value=$username name='username1'> <input type='hidden' value=$cardid name='cardid'><input type='hidden' value=$prodid name='prodid'><input type='hidden' value=$addid name='addid'> <input type='hidden' value=$email name='email'> <input type='submit' value='confirm order'> </form>"; } else { echo "You need to be signed in to view this page : please <a href='login1.php'>login</a> or <a href='register1.php'>register</a>"; } ?> </div> <div id='feature-right'> <div class='feature-mini'> <h2><a href='subscribe.html'>Subscribe</a></h2> <br> <a href='#'><h3>Subscribe to tech! magazine</h3> <img src='images/logo.png' width='100%' /></a> <p> Subscribe! 50% of retail price! That is a saving of £30 per year!...<a href='#'>subcribe</a> </p> <br> <img src='line.png' width='100%'> <br> <br> <p> <a href='twitter.php'><img src='twitter.png' width='100%'></a> <br> <p align='center'> <a href='http://twitter.com/techmaguk'> <h4>Follow us!<h4> </a> </p> </p> <br> <img src='line.png' width='100%'> <br> <br> <h2>Feature</h2> <br> <a href='#'><h3>Dell Adamo vs Mac Air</h3> <br> <img src='adamomac.png' width='100%' /></a> <p> The new adamo has been touted as an Air killer... We test them both...<a href='#'>read more</a> </p> <br> <img src='line.png' width='100%' /> <br> <br> <a href='#'><h3>Windows 7 revealed</h3> <br> <img src="win7.png" width="100%" /></a> <p> Windows 7 revealed, and we have a play with it!...<a href='#'>read more</a> </p> <br> <img src='line.png' width='100%'> <br> <br> </div> <div class="clear"></div> </div> <div class="clear"></div> </div> </div> <div id="footer" align="center"> <a href='#'> | contact us | </a> <a href='#'> Accessibility | </a> </div> </div> </body> </html> And buy.php <?php if (isset($_COOKIE['username'])) {$username= $_COOKIE['username']; $set = 1 ; $product=$_POST('product'); setcookie('product', $product, time()+3600); } else { $set=0; } ?> <!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>tech!</title> <LINK href="favicon.ico" rel="favicon" /> <link rel="stylesheet" type="text/css" href="style.css" /> <script type="text/javascript" src="js/jquery.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("#zone-bar li em").click(function() { var hidden = $(this).parents("li").children("ul").is(":hidden"); $("#zone-bar>ul>li>ul").hide() $("#zone-bar>ul>li>a").removeClass(); if (hidden) { $(this) .parents("li").children("ul").toggle() .parents("li").children("a").addClass("zoneCur"); } }); }); </script> </head> <body> <div id="page-wrap"> <div id="top-bar"> <a href="index.php"> <img src="images/logo.png" alt="DZone" class="floatleft height="200" width="500" /> </a> <div id="right-side"> <img src="images/usericon.jpg" alt="user icon" /> <?php if ($set==1) { echo "<a href='signedin.php'>$username</a> <a href='cart.php'>Basket</a>"; } else { echo "<a href='login1.php'>login</a> <a href='register1.php'>register</a>"; } ?> <a href="logout.php"> logout </a> <form id="main-search"> <label for="search-field" id="search-field-label">Search</label> <input type="text" tabindex="1" maxlength="255"id="search-field"/> <input type="image" alt="Search" value="Search" src="images/search.png" id="search-button"/> </form> </div> </div> <div id="zone-bar"> <ul> <li> <a href="#"><span> News <em class="opener-news"> <img src="images/zonebar-downarrow.png" alt="dropdown" padding="5px" /> </em> </span></a> <ul class="Newssublist"> <li><a href="#">Gaming</a></li> <li><a href="#">Audio</a></li> <li><a href="#">Visual</a></li <li><a href="#">Travel</a></li> <li><a href="#">Computing</a></li> <li><a href="#">Photography</a></li> <li><a href="#">Software</a></li> <li><a href="#">Outdoor</a></li> </ul> </li> <li> <a href="#"><span> Reviews <em class="opener-reviews"> <img src="images/zonebar-downarrow.png" alt="dropdown" padding= "5px" /> </em> </span></a> <ul class="reviewssublist"> <li><a href="#">Top 10's</a></li> <li><a href="#">Gaming</a></li> <li><a href="#">Audio</a></li> <li><a href="#">Visual</a></li> <li><a href="#">Travel</a></li> <li><a href="#">Computing</a></li> <li><a href="#">Photography</a></li> <li><a href="#">Software</a></li> <li><a href="#">Outdoor</a></li> </ul> </li> <li> <a href="#"><span> Shop <em class="opener-shop"> <img src="images/zonebar-downarrow.png" alt="dropdown" padding = "5px" /> </em> </span></a> <ul class="shopsublist"> <li><a href="#">Subscribe</a></li> <li><a href="#">Back Issues</a></li> <li><a href="#">Merchandise</a></li> </ul> </li> <li> <a href="#"><span> Competitions <em class="opener-competitions"> <img src="images/zonebar-downarrow.png" alt="dropdown" /> </em> </span></a> <ul class="competitionsublist"> <li><a href="#">New Competition</a></li> <li><a href="#">Previous Winners</a></li> </ul> </li> <li> <a href="#"><span> Photos <em class="opener-photos"> <img src="images/zonebar-downarrow.png" alt="dropdown" /> </em> </span></a> <ul class="photosublist"> <li><a href="#">Tech! things</a></li> <li><a href="#">Tech! places</a></li> <li><a href="#">Tech! people</a></li> </ul> </li> <li> <a href="#"><span> Video <em class="opener-video"> <img src="images/zonebar-downarrow.png" alt="dropdown" /> </em> </span></a> <ul class="videosublist"> <li><a href="#">Gaming</a></li> <li><a href="#">Movies</a></li> <li><a href="#">Music</a></li> <li><a href="#">Television</a></li> <li><a href="#">Comics & Animation</a></li> </ul> </li> <li> <a href="#"><span> About Us <em class="opener-aboutus"> <img src="images/zonebar-downarrow.png" alt="dropdown" /> </em> </span></a> <ul class="aboutussublist"> <li><a href="#">What we do</a></li> <li><a href="#">Jobs at tech!</a></li> <li><a href="#">Contact us</a></li> </ul> </li> </div> <div id='main-content'> <div id='feature-content'> <div id='feature-left'> <h1><a href="#">Subscribe</a></h1> <?php $cardid= $_POST['cardid']; $addid= $_POST['addid']; $email= $_POST['email']; $conn=odbc_connect('db09','',''); $sql="INSERT INTO tblOrders (ProductID, username, AddressID, CardID ) VALUES ('$product','$username', '$addid','$cardid')"; if (odbc_exec($conn,$sql)) { echo "thank you for your custom! - a confirmation email has been sent to $email ."; echo " <br> <a href='index.php'>home</a> "; $to= $email; $from= "[email protected]"; $subject= "Tech!"; $message= "Thank you for your purchase, your order will be dispatched soon! "; $headers = "From: " .$from; mail($to, $subject, $message, $headers); } odbc_close($conn); ?> </div> <div id='feature-right'> <div class='feature-mini'> <h2><a href='subscribe.html'>Subscribe</a></h2> <br> <a href='#'><h3>Subscribe to tech! magazine</h3> <img src='images/logo.png' width='100%' /></a> <p> Subscribe! 50% of retail price! That is a saving of £30 per year!...<a href='#'>subcribe</a> </p> <br> <img src='line.png' width='100%'> <br> <br> <p> <a href='twitter.php'><img src='twitter.png' width='100%'></a> <br> <p align='center'> <a href='http://twitter.com/techmaguk'> <h4>Follow us!<h4> </a> </p> </p> <br> <img src='line.png' width='100%'> <br> <br> <h2>Feature</h2> <br> <a href='#'><h3>Dell Adamo vs Mac Air</h3> <br> <img src='adamomac.png' width='100%' /></a> <p> The new adamo has been touted as an Air killer... We test them both...<a href='#'>read more</a> </p> <br> <img src='line.png' width='100%' /> <br> <br> <a href='#'><h3>Windows 7 revealed</h3> <br> <img src="win7.png" width="100%" /></a> <p> Windows 7 revealed, and we have a play with it!...<a href='#'>read more</a> </p> <br> <img src='line.png' width='100%'> <br> <br> </div> <div class="clear"></div> </div> <div class="clear"></div> </div> </div> <div id="footer" align="center"> <a href='#'> | contact us | </a> <a href='#'> Accessibility | </a> </div> </div> </body> </html> As I said previously any help would be massively appreciated Thank you in advance Link to comment https://forums.phpfreaks.com/topic/159631-help/ Share on other sites More sharing options...
Ken2k7 Posted May 25, 2009 Share Posted May 25, 2009 Wow... mind posting just the pertinent codes please? And specify what's not working. Link to comment https://forums.phpfreaks.com/topic/159631-help/#findComment-841968 Share on other sites More sharing options...
dh526 Posted May 25, 2009 Author Share Posted May 25, 2009 Good point... Don't really know what i was thinking there :S Right... On subcribe.php a choice of 2 options to buy. <?php if (isset($_COOKIE['username'])) {$username= $_COOKIE['username']; $set = 1 ;} else { $set=0; } ?> <?php if ($set==1) { echo "<br><br><h2>6 months subscription</h2><br><img src='magazine.png', width='100%'/><br><br><form method='POST' action='basket.php'><table><tr><td> Price : </td> <td> £20 <input type='hidden' name='product' value='1'/></td> </tr><tr><td> Description : </td> <td> 6 issues of tech! magazine delivered to your door </td></tr><tr><td> <input type='submit' value='Buy 6 months subscription Now' value='1'></td></tr></table></form><img src='line1.png' width='100%'><br><br><br><br><h2>12 months subscription </h2><br><img src='magazine.png', width='100%'/><br><br><form method='POST' action='basket.php'><table><tr><td> Price : </td> <td> £30 <input type='hidden' name='product' value='2'/></td></tr><tr><td> Description : </td> <td> 12 issues of tech! magazine delivered to your door </td></tr><tr><td> <input type='submit' value='Buy 12 months subscription Now'></td></tr></table></form><br><img src='line1.png' width='100%'><br><br>"; } else { echo "You need to be signed in to view this page : please <a href='login1.php'>login</a> or <a href='register1.php'>register</a>"; } ?> The basket.php, a simple preview of the order. <?php if (isset($_COOKIE['username'])) {$username= $_COOKIE['username']; $set = 1 ; $product=$_POST('product'); setcookie('product', $product, time()+3600); } else { $set=0; } ?> <?php if ($set==1) { $conn=odbc_connect('db09,'',''); $sqladd="SELECT AddressID, HouseNumber, Street, Town, Postcode FROM tblAddress WHERE username=$username"; $sqlcard="SELECT CardID, type, mynum FROM tblCard WHERE username=$username"; $sqlcust="SELECT Forename, Surname, [Email Address] FROM tblCustomer WHERE username=$username"; $sqlprod="SELECT ProductID, Name, Cost, Description FROM tblProducts WHERE ProductID=$product"; $rsadd=odbc_exec($conn, $sqladd); $rscard=odbc_exec($conn, $sqlcard); $rscust=odbc_exec($conn, $sqlcust); $rsprod=odbc_exec($conn, $sqlprod); if (odbc_fetch_row($rsadd)) { $housenumber=odbc_result($rsadd,"HouseNumber"); $street=odbc_result($rsadd,"Street"); $town=odbc_result($rsadd,"Town"); $postcode=odbc_result($rsadd,"Postcode"); $addid=odbc_result($rsadd,"AddressIDID"); } if (odbc_fetch_row($rscard)) { $type=odbc_result($rscard,"HouseNumber"); $mynum=odbc_result($rscard,"Street"); $cardid=odbc_result($rsadd,"CardID"); } if (odbc_fetch_row($rscust)) { $forename=odbc_result($rscust,"Forename"); $surname=odbc_result($rscust,"Surname"); } if (odbc_fetch_row($rsprod)) { $name=odbc_result($rsadd,"Name"); $cost=odbc_result($rsadd,"Cost"); $description=odbc_result($rsadd,"Description"); $prodid=odbc_result($rsadd,"ProductID"); } echo "<h1>Order details</h1><br><br><form Action='buy.php' Method='POST'> Name: $forename $surname <br> Delivery Address: $housenumber $street, $town, $postcode -- <a href='address.php'>add/edit address details</a><br> <br> card used: $type ( $mynyum ) -- <a href='card.php'>add/edit card details</a> <br> <br> <h3>item bought<h3><br> Name:$name <br> Cost: $cost <br> Description:$description <br><br><input type='hidden' value=$username name='username1'> <input type='hidden' value=$cardid name='cardid'><input type='hidden' value=$prodid name='prodid'><input type='hidden' value=$addid name='addid'> <input type='hidden' value=$email name='email'> <input type='submit' value='confirm order'> </form>"; } else { echo "You need to be signed in to view this page : please <a href='login1.php'>login</a> or <a href='register1.php'>register</a>"; } ?> and on buy.php. <?php if (isset($_COOKIE['username'])) {$username= $_COOKIE['username']; $set = 1 ; $product=$_POST('product'); } else { $set=0; } ?> <?php $cardid= $_POST['cardid']; $addid= $_POST['addid']; $email= $_POST['email']; $conn=odbc_connect('db09','',''); $sql="INSERT INTO tblOrders (ProductID, username, AddressID, CardID ) VALUES ('$product','$username', '$addid','$cardid')"; if (odbc_exec($conn,$sql)) { echo "thank you for your custom! - a confirmation email has been sent to $email ."; echo " <br> <a href='index.php'>home</a> "; $to= $email; $from= "[email protected]"; $subject= "Tech!"; $message= "Thank you for your purchase, your order will be dispatched soon! "; $headers = "From: " .$from; mail($to, $subject, $message, $headers); } odbc_close($conn); ?> Thank you for looking Link to comment https://forums.phpfreaks.com/topic/159631-help/#findComment-841969 Share on other sites More sharing options...
Ken2k7 Posted May 25, 2009 Share Posted May 25, 2009 What's not working? Syntactically, you have an error here $conn=odbc_connect('db09,'',''); You left out the quote after db09. Link to comment https://forums.phpfreaks.com/topic/159631-help/#findComment-841970 Share on other sites More sharing options...
dh526 Posted May 25, 2009 Author Share Posted May 25, 2009 Well spotted And what isn't working... erm, everything, I just get a white screen when I click on one of the 2 subscribe buttons on subscribe.php trying to go to basket.php... Link to comment https://forums.phpfreaks.com/topic/159631-help/#findComment-841971 Share on other sites More sharing options...
dh526 Posted May 26, 2009 Author Share Posted May 26, 2009 Hi, I have worked out that the problem is at the top (the setcookie lines) that makes the screen go white, now I just get the correct layout with no details in it ! Link to comment https://forums.phpfreaks.com/topic/159631-help/#findComment-841980 Share on other sites More sharing options...
Ken2k7 Posted May 26, 2009 Share Posted May 26, 2009 It's always good to post updated code. You should put quotes around string values. Like in username. This is what you have - $sqladd="SELECT AddressID, HouseNumber, Street, Town, Postcode FROM tblAddress WHERE username=$username"; $sqlcard="SELECT CardID, type, mynum FROM tblCard WHERE username=$username"; $sqlcust="SELECT Forename, Surname, [Email Address] FROM tblCustomer WHERE username=$username"; This is what you should have (minus one thing) - $sqladd="SELECT AddressID, HouseNumber, Street, Town, Postcode FROM tblAddress WHERE username='$username'"; $sqlcard="SELECT CardID, type, mynum FROM tblCard WHERE username='$username'"; $sqlcust="SELECT Forename, Surname, [Email Address] FROM tblCustomer WHERE username='$username'"; The "minus one thing" I said before is the in your SELECT clause. What is that? I never used brackets before in SQLs so I may not know what it does. Also, use odbc_error to check for any other error messages. Link to comment https://forums.phpfreaks.com/topic/159631-help/#findComment-841983 Share on other sites More sharing options...
dh526 Posted May 26, 2009 Author Share Posted May 26, 2009 The [ ] brackets are just because the "Email Address" field has a space in it and I ran into problems before with it ... I made the amendments and it still isn't working, and i dont understand why its not reading and info from the tables :S Link to comment https://forums.phpfreaks.com/topic/159631-help/#findComment-841988 Share on other sites More sharing options...
Ken2k7 Posted May 26, 2009 Share Posted May 26, 2009 Try this instead of the brackets - $sqlcust="SELECT Forename, Surname, `Email Address` FROM tblCustomer WHERE username='$username'"; Link to comment https://forums.phpfreaks.com/topic/159631-help/#findComment-842026 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.