Advertisement
Guest User

Untitled

a guest
Oct 10th, 2015
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. <?php
  2. mysql_connect("localhost","root","") or die('db connection failed');
  3. mysql_select_db("cenima") or die('db connection failed');
  4. $output='';
  5. //collect
  6. if(isset($_POST['search'])){
  7. $search=$_POST['search'];
  8. $Search= preg_replace("#[^0-9a-z]#i","",$search);
  9. $query=mysql_query("SELECT * FROM users WHERE FIRSTNAME IS LIKE '%$search%' or lastname is LIKE '%$search%'") or die("could not search");
  10. $count=mysql_num_rows($query);
  11. if($count==0){
  12. $output = 'there was no search result';
  13. }else{
  14. while($row=mysql_fetch_array($query)){
  15. $emil=$row['email'];
  16. $uname=$row['user_name'];
  17. $id=$row['ic'];
  18. $output = '$email.$uname';
  19. }
  20. }
  21. }
  22. ?>
  23.  
  24.  
  25. <html>
  26. <head>
  27. <style>
  28. </style>
  29. <body>
  30. <form action="index.php" method="post">
  31. <input type="text" placeholder="please write somthing here" name="search">
  32. <input type="submit" value=">>" />
  33. </form>
  34.  
  35. <?php print("$output"); ?>
  36. </body>
  37. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement