Jump to content

dh526

Members
  • Posts

    39
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

dh526's Achievements

Member

Member (2/5)

0

Reputation

  1. The values of $cardid etc are from some tables and they are all echoed out correctly and do return a number... (or email address) <form method='POST' action='buy.php'> <input type='hidden' value=$cardid name='cardid' /> <input type='hidden' value=$addid name='addid' /> <input type='hidden' value=$email name='email' /> <input type='hidden' value=$prodid name='prodid' /> <input type='submit' value='confirm order' > </form> Then on the next page I want to insert these values into a table. So I have done this : $conn=odbc_connect('db09','',''); $sql="INSERT INTO tblOrders (ProductID, username, AddressID, CardID ) VALUES ($product,'$username', $addid, $cardid)"; but it doesn't work. I get a [Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement error. What is wrong ?? can anyone help?? thank you in advance
  2. It does execute twice and its fine I was being a plonker and had value=1/> so it thought the / was part of the value. Annoying error Thanks guys
  3. Actually the error goes like this : /[Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression 'ProductID=1/. What syntax am I missing????
  4. Arrrggg, had it working for a moment, and now its gone :S was to do with the value='1' instead of =1 :S amateurish error Anyway, now I am getting this error ... : [Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression 'ProductID='. at the moment my query looks like this: $sqlprod="SELECT ProductID, myname, Cost, Description FROM tblProducts WHERE ProductID=$product"; however if I change it to ='$product' I get a type mismatch... Arrrgggg I.HATE.MICROSOFT.
  5. 'db09' is set up as a DSN and that works fine on many other forms... I think the issue is with passing the $product (either 1 or 2) to the tblProducts table. This does however return 1 (as there is 1 record) with the best_num_rows() function mind, so surely I can search with the value sent from the other page ($product) and search tblProducts. I think i have an error in these bits...: $product = $_POST['product']; echo "product : "; echo $product; $sqlprod="SELECT ProductID, myname, Cost, Description FROM tblProducts WHERE ProductID=$product"; $rsprod=odbc_exec($conn, $sqlprod); if (odbc_fetch_row($rsprod)) { $prodid=odbc_result($rsprod,"ProductID"); $myname=odbc_result($rsprod,"myname"); $cost=odbc_result($rsprod,"Cost"); $description=odbc_result($rsprod,"Description"); echo $myname; echo $cost; echo $description; echo $prodid; } when i echo out the variables I get nothing
  6. You are right, and yes it should, but It has no effect on the output... i still get the "[Microsoft][ODBC Microsoft Access Driver]Invalid use of null pointer " output from "echo odbc_errormsg($conn);" and I don't know why..?? Does anyone know why that error is occuring? Thanks for looking
  7. Can anyone help with this?? I don't really know what the null pointer error means an even google isn't that much help !! arrggg :S any help would be much appreciated
  8. Hi everyone and thank you for looking This is the error message I get when sending information between the 2 pages below. [Microsoft][ODBC Microsoft Access Driver]Invalid use of null pointer I also pass the variable across and it gives the output of product: 1 so this works properly :S basket.php which sends either 0 or 1 to basket.php. $_username is stored in a cookie. <?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'></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>"; } ?> This is basket.php which should display the product that has been bought. <?php $conn=odbc_pconnect('db09','',''); // -------------- TEST $sql2="SELECT ProductID, myname, Cost, Description FROM tblProducts WHERE ProductID='$product'"; $rs3=odbc_exec($conn, $sq2); $rs1=odbc_num_rows($rs); function best_odbc_num_rows($r1) { ob_start(); // block printing table with results (int)$number=odbc_result_all($r1); ob_clean(); // block printing table with results return $number; } $rs4=best_odbc_num_rows($rs3); echo $rs4; // end of test if (odbc_error()) { echo odbc_errormsg($conn); } $product = $_POST['product']; echo "product : "; echo $product; $sqladd="SELECT AddressID, HouseNumber, Street, Town, Postcode FROM tblAddress WHERE username='$username'"; $sqlcard="SELECT cardid, username, myname, type, mynum, exp, sec FROM tblCard WHERE username='$username'"; $sqlcust="SELECT username, Password, Surname, Forename, DOB, [Email Address] FROM tblCustomer WHERE username='$username'"; $sqlprod="SELECT ProductID, myname, 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($rscard)) { $cardid=odbc_result($rsadd,"cardid"); $type=odbc_result($rscard,"type"); $mynum=odbc_result($rscard,"mynum"); } 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,"AddressID"); } if (odbc_fetch_row($rscust)) { $forename=odbc_result($rscust,"Forename"); $surname=odbc_result($rscust,"Surname"); } if (odbc_fetch_row($rsprod)) { $name=odbc_result($rsprod,"myname"); $cost=odbc_result($rsprod,"Cost"); $description=odbc_result($rsprod,"Description"); $prodid=odbc_result($rsprod,"ProductID"); } if ($set==1) { 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 ( $mynum ) -- <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=$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>"; } ?>
  9. dh526

    Help!

    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
  10. dh526

    Help!

    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 !
  11. dh526

    Help!

    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...
  12. dh526

    Help!

    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= "purchases@tech.com"; $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
  13. dh526

    Help!

    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= "purchases@tech.com"; $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
  14. Hi everyone I have a problem (of which I seem to have lots ...) involving odbc_num_rows(). What I want to do is look up tblCard and see if there is any records with the username equal to that of $username stored in a cookie. Then if there is records show a table to edit those details, if not show a table to add some details. The problem I have is how to do the if statement... my 1st thought was to do if (odbc_num_rows($rs) > 0) then Show table edit card else show add card table. I dont really know if i've missed a step or am using odbc_num_rows incorrectly :S here is my code : <?php $conn=odbc_connect('db09','',''); $sql="SELECT username FROM tblCard WHERE username='$username'"; $rs=odbc_exec($conn, $sql); if ((odbc_num_rows($sql) > 0)) { echo "<H1> add a card! $username </h1><br><div><a href='address.php'>| Add/Edit Address Details | </a> <a href='card.php'> Add/Edit Card Details |</a> <a href='signedin.php'> Edit My Details |</a><br><br><br><a href='card.php'> Add card |</a> <a href='editcard.php'>Edit card</a><br><br><p> --Please note - All fields must be entered-- </p><br><br><form action='addcard.php' method='POST' onsubmit='return validate(this);'><table border = 0><tr><td>Name :</td> <td> <input type='text' name='cname' /></td></tr><tr><td>Number: </td> <td> <input type='text' name='num' /></td></tr><tr><td>Type: </td> <td> <input type='text' name='type' /> </td></tr><tr><td>Expiry date: </td> <td> <input type='text' name='ex' /> </td> <td>Please enter in the form of LL99 9LL</td></tr><tr><td>security code: </td> <td> <input type='text' name='sec' /> </td> <td>3 digits on signature strip</td></tr><tr><td></td></tr><tr><td> <input type='submit' value='Add card'></td> <td> </td></tr></form></table>"; } else { echo "<h1>Edit your Card details, $username</a></h1><br><div><a href='editcard.php'>| Add/Edit Card Details | </a> <a href='card.php'> Add/Edit Card Details |</a> <a href='signedin.php'> Edit My Details |</a><br><br><br><a href='card.php'> Add Card |</a> <a href='editaddress.php'>Edit Address</a><br><br><p>--Please note - All fields must be entered : if you wish to change one line of your address, please enter the full addresss again--</p><br><br><form action='editcard1.php' method='POST' onsubmit='return validate(this);'><table border = 0><tr><td>Name :</td> <td> <input type='text' name='cname' /></td></tr><tr><td>Number: </td> <td> <input type='text' name='num' /></td></tr><tr><td>Type: </td> <td> <input type='text' name='type' /> </td> </tr><tr><td>Expirydate: </td> <td> <input type='text' name='ex' /> </td> <td>Please enter in the form of LL99 9LL</td></tr><tr><td>security code: </td> <td> <input type='text' name='sec' /> </td> <td>3 digits on signature strip</td></tr><tr><td></td></tr><tr><td> <input type='submit' value='Edit card'></td> <td> </td></tr></form></table>"; } ?> Any help would be much appreciated thank you in advance
×
×
  • 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.