Advertisement
Guest User

Untitled

a guest
Nov 23rd, 2014
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.03 KB | None | 0 0
  1. <?php
  2.   session_start();
  3.   $host  = $_SERVER['HTTP_HOST'];
  4.   $uri   = rtrim(dirname($_SERVER['PHP_SELF']), '/\\');
  5.  
  6.   $Ice = $_POST["Ice"];  
  7.  
  8.  
  9. //Constructing the query out of the received data
  10.  
  11.   $query = "SELECT Name
  12.            FROM Drinks D
  13.            WHERE D.Ice === '$Ice'
  14.  
  15. //connecting to the mysql
  16.  
  17.  $con = mysql_connect("localhost","root","tackle") or die('Unable to connect to mysql' . mysql_error());
  18.  
  19. //connecting to the database  
  20.  mysql_select_db("LastDefender") or die("Unable to connect to the database" . mysql_error());
  21.  
  22. //running the query
  23. $returnValue = mysql_query($query, $con);  
  24.  
  25. //closing the connection to the database
  26. mysql_close($con);
  27.  
  28. $_SESSION['data'] = "";
  29. if(!$returnValue){
  30.   die('Could not get data: ' . mysql_error());
  31. }else{
  32.   $row = mysql_fetch_assoc($returnValue);
  33.   $_SESSION['data'] =
  34.   "<table>
  35.      <tr><td>Name</td>    
  36.      </tr>
  37.      <tr><td>" . $Ice   . "</td>
  38.      </tr>
  39.    </table>";
  40.   header("Location: http://".$host. "/Result.php");    
  41. }
  42. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement