Advertisement
Guest User

cds.php

a guest
Apr 8th, 2013
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 2.69 KB | None | 0 0
  1. <html>
  2. <head>
  3. <link rel="icon"
  4.      type="image/x-icon"
  5.      href="img/favicon.ico">
  6. <title>Cart</title>
  7. <style>
  8.     body {
  9.         background-image: url(img/bg.jpg);
  10.         background-attachment: fixed;
  11.         font-family: sans-serif; color: White;
  12.         }
  13.     table {
  14.         background: rgba(255,255,255,0.4);
  15.         }
  16.     a { color: white; }
  17.     a:visited { color: white; }
  18.     a:hover { color: #CCCCCC; }
  19.     a:focus { outline: white; }
  20.     hr {
  21.         width: 100%;
  22.         }
  23. </style>
  24. </head>
  25. <body>
  26. <?php
  27.     $dbhost = 'localhost';
  28.     $dbuser = 'root';
  29.     $conn = mysql_connect($dbhost, $dbuser);
  30.     mysql_select_db("userlogin");
  31.     if(! $conn )
  32.         {
  33.             die('Could not connect: ' . mysql_error());
  34.         }
  35.     //this gets the current logged-in user
  36.                     $query  = "SELECT * FROM `currentsession`";
  37.                     $result = mysql_query($query);
  38.                         while($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
  39.                             $userN = $row['curUsr'];
  40.                             $userM = $row['money'];
  41.                            
  42.                 }
  43.     echo "Currently logged-in as <b>",$userN,"</b> and your money is <img src=img/peso.png width=20 height=20 /><b>",$userM,"</b>";
  44.     echo "<div align=center><hr /></div>";
  45.     if(@$_REQUEST['prdname']!="")
  46.     {
  47.         $comp=mysql_real_escape_string($_REQUEST['comp']);
  48.         $prdname=mysql_real_escape_string($_REQUEST['prdname']);
  49.         $quant=mysql_real_escape_string($_REQUEST['quant']);
  50.         $prc=mysql_real_escape_string($_REQUEST['prc']);
  51.         if($quant=="")$quant="NULL";
  52.         mysql_query("INSERT INTO cart (comp,prdname,quant,prc) VALUES('$comp','$prdname',$quant,$prc);");
  53.     }
  54.     if(@$_REQUEST['action']=="del")
  55.     {
  56.         mysql_query("DELETE FROM cart WHERE id=".round($_REQUEST['id']));
  57.     }
  58.     echo "<div align = center><font size='+12'>CART</font></div>";
  59.     echo "<div align=center><hr /></div>";
  60.     echo "<div align = 'center'><table border = '0'>";
  61.     echo "<th border=1>Product Name</th><th>Compatible Board</th><th>Quantity</th><th>Price</th><th>Delete</th>";
  62.     $usrCnt = 0;
  63.     $query="SELECT id,comp,prdname,quant,prc FROM cart ORDER BY comp";
  64.     $result=mysql_query($query,$conn);
  65.     while( $row = mysql_fetch_array($result, MYSQL_ASSOC))
  66.     {
  67.         echo "<tr><td align = center>{$row['prdname']}</td>".
  68.              "<td align = center>{$row['comp']}</td>".
  69.              "<td align = center>{$row['quant']}</td>".
  70.              "<td align = center>{$row['prc']}</td>".
  71.              "<td align = center><a href=cds.php?action=del&id=".$row['id']."><span class=red>DELETE</span></a></td></tr>";
  72.         $usrCnt++;
  73.     }
  74.     echo "<tr valign=bottom>";
  75.     echo "<td bgcolor=#fb7922 colspan=7><img src=img/blank.gif width=1 height=8></td>";
  76.     echo "</tr>";
  77.     echo "<tr><td><a href=productpage.php>GO BACK</a></td> <td colspan=3></td> <td align=right><a href=logoutLogic.php>LOG-OUT</a></td></tr>";
  78.     echo "</table></div><br />";
  79.     mysql_close($conn);
  80. ?>
  81. </body>
  82. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement