Guest User

Untitled

a guest
Jan 12th, 2019
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. adduser_process.php not adding information to MySQL table
  2. <form name="adduser_form" action="process/adduser_process.php" method="post">
  3. Username:<input id="username" type="test" name="username" />
  4. Email:<input id="email" type="text" name="email" />
  5. Password:<input id="password" type="password" name="password" />
  6. <input id="add_usr" type="button" value="Add User" onclick="formhash(this.form, this.form.password);" />
  7. </form>
  8.  
  9. function formhash(form, password) {
  10. var p = document.createElement("input");
  11. form.appendChild(p);
  12. p.name = "p";
  13. p.type = "hidden";
  14. p.value = hex_sha512(password.value);
  15. password.value = "";
  16. form.submit();
  17. }
  18.  
  19. include '../includes/lgn_connect.php';
  20. include '../includes/functions.php';
  21. sec_session_start();
  22.  
  23. $password = $_POST['p'];
  24.  
  25. $random_salt = hash('sha512', uniqid(mt_rand(1, mt_getrandmax()), true));
  26.  
  27. $password = hash('sha512', $password.$random_salt);
  28.  
  29. if($insert_stmt = $mysqli->prepare("INSERT INTO users (username, email, password, salt) VALUES (?, ?, ?, ?)")) {
  30. $insert_stmt->bind_param('ssss', $username, $email, $password, $random_salt);
  31.  
  32. $insert_stmt->execute();
  33. }
  34.  
  35. <input id="username" type="test" name="username" /> //should be
  36. <input id="username" type="text" name="username" />
  37.  
  38. if($insert_stmt = $mysqli->prepare("INSERT INTO users (username, email, password, salt) VALUES (?, ?, ?, ?)")) //should be
  39.  
  40. if(($insert_stmt = $mysqli->prepare("INSERT INTO users (username, email, password, salt) VALUES (?, ?, ?, ?)")))
  41.  
  42. session_start();
Add Comment
Please, Sign In to add comment