Advertisement
Guest User

Untitled

a guest
Aug 4th, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. <?php
  2.  
  3.  
  4. session_start();
  5.  
  6.  
  7. if (isset($_POST['submit'])) {
  8. if (isset($_GET['go'])) {
  9. if (preg_match("^/[A-Za-z]+/", $_POST['name'])) {
  10. $name = $_POST['name'];
  11.  
  12. $host = "localhost";
  13. $user = "root";
  14. $pass = "";
  15. $db = "";
  16.  
  17. mysql_connect($host, $user, $pass);
  18. mysql_select_db($db);
  19.  
  20. $sql = "SELECT * FROM movies WHERE name='$name'";
  21.  
  22. $result = mysql_query($sql);
  23.  
  24. while ($row = mysql_fetch_array($result)) {
  25. $moviename = $row['moviename'];
  26. $id = $row['id'];
  27.  
  28. echo "<a href=\"search.php?id=$id\">" . $moviename . "</a>";
  29.  
  30. }
  31. }
  32. }
  33. else {
  34. echo "Please enter a search query";
  35. }
  36. }
  37.  
  38.  
  39. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement