Advertisement
giraffeinatutu

SubmitOrder

Aug 28th, 2014
257
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.19 KB | None | 0 0
  1. <?php
  2.         session_start();
  3.         if( !isset( $_SESSION['fname'] ))
  4.     {
  5.     header("location: CR_login.php");
  6.     }
  7.     unset($_SESSION['counter']);
  8.  
  9.  
  10.     // Establish a connection to the database
  11.     $con =  mysqli_connect("localhost", "cairil_php", "phpsql");
  12.    
  13.     // Check if there were any issues connecting to the database
  14.     if ( mysqli_connect_errno() != 0)
  15.     {
  16.        die("An error occurred trying to establish a connection: " .mysqli_connect_error());
  17.     }
  18.    
  19.     // Select the  database to work with.
  20.     $db  =  mysqli_select_db ($con , "cairil_php");
  21.  
  22.     // Specify the query to run
  23.     $sqlString = "INSERT INTO `order` VALUES ('"null"','" . $_POST["CustID"] ."','"null"','"null"','"null"','"null"','1','" . $_POST["Address"] ."','" . $_POST["City"] ."','" . $_POST["State"] ."','" . $_POST["Zip"] ."')";
  24.        
  25.         // Run the query using the connection established earlier and assign the results to a results object.
  26.     $rs = mysqli_query ($con  , $sqlString);
  27.    
  28.        
  29.     // Check if update was successful by checking whether the result returned is True
  30.     if ( !$rs)
  31.     {
  32.         $result =  "Error processing order.  Try again later.".mysqli_error();
  33.     }
  34.     else
  35.     {
  36.         $result =  "Order Placed!";
  37.     }
  38.    
  39.     // Close the connection
  40.     mysqli_close($con);
  41. ?>
  42. <!DOCTYPE html>
  43. <html>
  44.     <head>
  45.         <title> CR_placeOrder </title>
  46.     </head>
  47.     <body bgcolor="#bbccaa">
  48.         <br/>
  49.         <br/>
  50.         <br/>
  51.         <center>
  52.             <h3><?php  echo($result); ?></h3>
  53.             <br/>
  54.            
  55.  
  56.        
  57.        
  58. <br />
  59. <h3>***********************************************************************************************</h3>
  60. <br />
  61. <table>
  62. <tr>
  63. <td><a href=CR_products.php><img title"view products" src="/images/b-products.png" alt="View Product" /></a>
  64.     <a href=CR_cart.php><img title"view cart" src="/images/b-shopping.png" alt="View Cart" /></a>
  65.     <a href=CR_change.php><img title"change pass" src="/images/b-change.png" alt="Change Password"/></a></td></tr>
  66.     <tr></tr>    <tr></tr>
  67.     <tr><td align="center"><a href=CR_welcome.php><img title="home" src="/images/home_button.png" alt="home" width="150" height="50"/></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=CR_logout.php><img title"logout" src="/images/exit_button.jpg" alt="Logout" /></a></td></tr>
  68. </table>    
  69. </center>
  70. </body>
  71. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement