Advertisement
Guest User

Untitled

a guest
Feb 8th, 2016
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.64 KB | None | 0 0
  1. <form action"signup.php" method="post">
  2. username:<input type="text" name="n"><br />
  3. password:<input type="password" name="p"><br />
  4. id :<input type="text" name="id"><br />
  5. <input type="submit">
  6. </form>
  7.  
  8.  
  9. <?php
  10. $conn = mysql_connect("localhost", "root", "");
  11. $db = mysql_select_db("myth", $conn);
  12. ?>
  13.  
  14. <?php
  15. $user = $_POST['n'];
  16. $pass = $_POST['p'];
  17. $id = $_POST['id'];
  18. $sql = "INSERT into phplogin values(" . $id . ",'" . $user . "','" . $pass . "')";
  19. $query = mysql_query();
  20.  
  21. if(!$query)
  22. echo "failed ".mysql_error();
  23. else
  24. echo "successful";
  25. ?>
  26.  
  27. while ($row=mysql_fetch_row($result)) {
  28. // here, you have your rows
  29. }
  30.  
  31. <?php
  32. // create connection
  33. $mysqli = new mysqli("localhost", "my_user", "my_password", "world");
  34.  
  35. // check connection
  36. if ($mysqli->connect_errno) {
  37. printf("Connect failed: %sn", $mysqli->connect_error);
  38. exit();
  39. }
  40.  
  41. $user = $_POST['n'];
  42. $pass = $_POST['p'];
  43. $id = $_POST['id'];
  44.  
  45. $sql = "INSERT into phplogin values('$id','$user','$pass')";
  46. if($mysqli->query($query)) {
  47. printf("New Record has id %d.n", $mysqli->insert_id);
  48. } else {
  49. printf("Failed ".$mysqli->error);
  50. }
  51.  
  52. // close connection
  53. mysqli_close($link);
  54.  
  55. ?>
  56.  
  57. <?php
  58. $conn = mysqli_connect("localhost","root","","myth")or die("connection to database problem");
  59.  
  60. $user = $_POST['n'];
  61. $pass = $_POST['p'];
  62. $id = $_POST['id'];
  63. $sql = "INSERT INTO phplogin VALUES (".$id.",'".$user."','".$pass."')";
  64. $query = mysqli_query($conn, $sql)or die("query error");
  65.  
  66. if(false===$query)
  67. echo "<br/>".mysqli_error($conn)."<br/><br/><br/>";
  68. else
  69. echo "<br/>done ";
  70. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement