Advertisement
Guest User

Untitled

a guest
May 30th, 2018
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.34 KB | None | 0 0
  1. <?php
  2. //if nothing entered in the form, the user is redirected back to the form
  3.  
  4. if(empty($_GET['fname'])){
  5. header ("Location: http://gfkvardar.com/kirkata.php");
  6. exit;
  7. }
  8. ?>
  9.  
  10. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  11. <head>
  12. <title>Search Results</title>
  13. <style type="text/css">
  14. body, h2, tr { text-align: center }
  15. </style>
  16. </head>
  17. <body>
  18. <?php
  19. $servername = "localhost";
  20. $username = "putlocke_gfkuser";
  21. $password = "kire123";
  22. $dbname = "putlocke_gfkdb";
  23. // Create connection
  24. $conn = new mysqli($servername, $username, $password, $dbname);
  25. // Check connection
  26. if ($conn->connect_error) {
  27. die("Connection failed: " . $conn->connect_error);
  28. }
  29. //if the user is here the field is not empty
  30. $fname = mysqlclean($_GET['fname'], 50, $connection);
  31.  
  32. //Constructing the sql query
  33. $query = "SELECT * FROM student WHERE firstname like '%$fname%'";
  34.  
  35. //Runing the query through the connection
  36. if (!($result = @ mysql_query ($query, $connection)))
  37. dberror();
  38.  
  39. //Displaying the Results
  40. $rowsFound = @ mysql_num_rows($result);
  41. if ($rowsFound > 0){
  42. echo "<h2>Students with first name: $fname</h2>";
  43. displayResults($result);
  44. }
  45. //Nothing matched
  46. else
  47. echo "<h2>No students with first name: {$_GET['fname']}</h2>";
  48. ?>
  49. <br/><a href="http://gfkvardar.com/kirkata.php"><< Back to Search</a>
  50. </body>
  51. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement