Share Pastebin
Guest
Public paste!

Untitled

By: a guest | Feb 9th, 2010 | Syntax: PHP | Size: 4.31 KB | Hits: 14 | Expires: Never
Copy text to clipboard
  1. <?
  2.  
  3. $host                                   =       "localhost"; // Host name
  4. $username                               =       "ptanner_cmx"; // Mysql username
  5. $password                               =       "ORgANic1@3"; // Mysql password
  6. $db_name                                =       "ptanner_cmx"; // Database name
  7. $tbl_name                               =       "cart_customers"; // Table name
  8. $tbl_name2                              =       "cart_invoice"; // Table name
  9.  
  10. // Connect to server and select databse.
  11. mysql_connect("$host", "$username", "$password")or die("cannot connect");
  12. mysql_select_db("$db_name")or die("cannot select DB");
  13.  
  14. include_once("classes/DB.class.php");
  15. include_once("functions/mbstrings.php");
  16.  
  17. ?>
  18.  
  19. <html>
  20. <head>
  21.  
  22. <style type="text/css">
  23.         #search-box{
  24.                 background-color: #f7f7f7;
  25.                 border: 1px solid #cccccc;
  26.         }
  27.         #text1{
  28.                 font-size: 8pt;
  29.                 color: #000;
  30.         }
  31. </style>
  32.  
  33. </head>
  34. <body>
  35.  
  36. <table width="100%" cellpadding="0" cellspacing="0" border="0">
  37.         <tr><td class="nav"><a href="index.php?section=home">Home</a>&nbsp;&gt;&nbsp;<a href="index.php?section=manage_blogs">Manage Blogs</a></td></tr>       
  38.         <tr><td>&nbsp;</td></tr>
  39.         <tr><td id="text1">
  40.  
  41.         <?php
  42.  
  43.         if ($_POST['delete']){
  44.                 $sql = "delete FROM cart_customers WHERE
  45.                         prikey = '". $_POST['prikey'] . "'
  46.                         AND billto_firstname = '". $_POST['billto_firstname'] . "'
  47.                         AND billto_lastname = '". $_POST['billto_lastname'] . "'
  48.                         AND username = '". $_POST['username'] . "'
  49.                         AND password = '". $_POST['password'] . "'";
  50.                 $GLOBALS["DB"]->execute($sql); 
  51.                 echo "Item Delete<br>";
  52.                 }
  53.  
  54.         $sql_query = "SELECT prikey,billto_firstname,billto_lastname,billto_phone,username,password FROM cart_customers";
  55.        
  56.         if ($_GET['prikey'])
  57.                 $sql_query .= " WHERE prikey = '" . $_GET['prikey']."'";
  58.        
  59.         if ($_GET["billto_firstname"])
  60.                 $sql_query .= " WHERE billto_firstname like '%". $_GET["billto_firstname"] . "%'";
  61.  
  62.         if ($_GET["billto_lastname"])
  63.                 $sql_query .= " WHERE billto_lastname like '%". $_GET["billto_lastname"] . "%'";
  64.  
  65.         if ($_GET["billto_phone"])
  66.                 $sql_query .= " WHERE billto_phone like '%". $_GET["billto_phone"] . "%'";
  67.  
  68.         if ($_GET["username"])
  69.                 $sql_query .= " WHERE username like '%". $_GET["username"] . "%'";     
  70.  
  71.         if ($_GET["password"])
  72.                 $sql_query .= " WHERE password like '%". $_GET["password"] . "%'";
  73.  
  74.         $result = $GLOBALS["DB"]->result($sql_query);
  75.        
  76.         echo "
  77.  
  78.         <table>
  79.                 <tr>
  80.                         <td class'text1'>OPTIONS</td>
  81.                         <td>PRIKEY</td>
  82.                         <td>FIRST NAME</td>
  83.                         <td>LAST NAME</TD>
  84.                         <td>PHONE</td>
  85.                         <td>USERNAME</td>
  86.                         <td>PASSWORD</td>
  87.                         <td>ACTION</td>
  88.                 </tr>";
  89.  
  90.         echo "
  91.         <form method='get'>
  92.  
  93.                 <tr>
  94.                         <td>
  95.                                 <select name=type>
  96.                                         <option value='0'>ALL</option>
  97.                                         <option value='prikey'>Prikey</option>
  98.                                         <option value='billto_firstname'>First Name</option>
  99.                                         <option value='billto_lastname'>Last Name</option>
  100.                                         <option value='billto_phone'>Phone</option>
  101.                                         <option value='username'>Username</option>
  102.                                         <option value='password'>Password</option>
  103.                                 </select>
  104.                         </td>
  105.                         <td><input type=text name='prikey'></td>
  106.                         <td><input type=text name='billto_firstname'></td>
  107.                         <td><input type=text name='billto_lastname'></td>
  108.                         <td><input type=text name='billto_phone'></td>
  109.                         <td><input type=text name='username'></td>
  110.                         <td><input type=text name='password'></td>
  111.  
  112.                         </td>
  113.                         <td>&nbsp;</td>
  114.  
  115.                         <td>
  116.                                 <input type=submit name=submit value=Filter></form>
  117.                         </td>
  118.                 </tr>
  119.         ";
  120.  
  121.         foreach($result as $res){
  122.                 echo "
  123.  
  124.                 <tr>
  125.                         <td></td>
  126.                         <td class'text1'>".$res["prikey"] . "</td>
  127.                         <td class'text1'>" . $res["billto_firstname"]. "</td>
  128.                         <td class'text1'>" . $res["billto_lastname"]. "</td>
  129.                         <td class'text1'>" . $res["billto_phone"]. "</td>
  130.                         <td class'text1'>" . $res["username"] . "</td>
  131.                         <td class'text1'>" . $res["password"]. "</td>
  132.  
  133.                         <td><form method=post>
  134.                                 <input type=hidden name=delete value=1>
  135.                                 <input type=hidden name=prikey value=\"" . $res["prikey"]. "\">
  136.                                 <input type=hidden name=billto_firstname value=\"" . $res["billto_firstname"]. "\">
  137.                                 <input type=hidden name=billto_lastname value=\"" . $res["billto_lastname"]. "\">
  138.                                 <input type=hidden name=billto_phone value=\"" . $res["billto_phone"]. "\">
  139.                                 <input type=hidden name=username value=\"" . $res["username"]. "\">
  140.                                 <input type=hidden name=password value=\"" . $res["password"]. "\">
  141.                                 <input type=submit name=submit value=\"Delete\">
  142.                         </form></td>
  143.                 </tr>
  144.  
  145.                 ";
  146.         }//foreach
  147.         echo "</table>";
  148.  
  149. ?>
  150. </td></tr></table>
  151.  
  152. </body>
  153. </html>