Advertisement
Guest User

Untitled

a guest
May 27th, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. [-0-(mohan@Linuxbox) /var/www/html/php]$cat sql.php
  2. <?php
  3.  
  4. $host="localhost";
  5. $user="root";
  6. $pass="";
  7. $db="peoples_choice";
  8.  
  9.  
  10. $mysql=new mysqli($host,$user,$pass,$db) or die ('you\'re dead');
  11.  
  12. if(!empty($_POST['submit'])){
  13. $username=$_POST['name'];
  14. $query= "Insert into users values('','$username')";
  15.  
  16. if($updateDb=$mysql->query($query) or die($mysql->error)){
  17. echo "Congrats!";
  18. }}
  19.  
  20. $result=$mysql->query("Select * from users") or die ($mysql->error);
  21.  
  22. if ($result){
  23.  
  24. while($row=$result->fetch_object()){
  25. $name[]=$row->name;}}
  26.  
  27. echo "<ui>";
  28. foreach ($name as $n){
  29. echo "<li>$n</li>\n";}
  30.  
  31. echo "</ui>";
  32. ?>
  33.  
  34. <form method="post" action="">
  35. <label for="name">Name</label>
  36. <input type=text name="name"/>
  37. <input type=submit name="submit" value="submit"/>
  38. </form>
  39.  
  40.  
  41.  
  42.  
  43.  
  44. [-0-(mohan@Linuxbox) /var/www/html/php]$php sql.php
  45. <ui><li>test1</li>
  46. <li>mohan</li>
  47. <li>teet</li>
  48. <li>boss</li>
  49. <li>some girl</li>
  50. <li>some guy</li>
  51. <li>kumar</li>
  52. <li>welcome</li>
  53. <li>cool</li>
  54. <li>what</li>
  55. <li>waste</li>
  56. </ui>
  57. <form method="post" action="">
  58. <label for="name">Name</label>
  59. <input type=text name="name"/>
  60. <input type=submit name="submit" value="submit"/>
  61. </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement