Advertisement
steven00o

insert user dot php

Mar 22nd, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.87 KB | None | 0 0
  1. <html>
  2. <body>
  3. <h1>User Creation</h1>
  4. <?php
  5. session_start();
  6. if($_SESSION['login'] !="OK")
  7. {
  8. header('Location:login.php');
  9. exit();
  10. }
  11.  
  12. $new_user = $_POST["new_username"];
  13. $new_pass = $_POST["new_password"];
  14.  
  15. if($new_user!=""&&$new_pass!="")
  16. {
  17.  
  18. $host = "localhost";
  19. $admin_user ="username";
  20. $admin_pass ="user_password";
  21. $db="database_name";
  22.  
  23. $conn = @mysql_connect($host,$admin_user,$admin_pass) or die ("Sorry - unable to connect to
  24. MYSQL database.");
  25. $rs = @mysql_select_db($db,$conn) or die ("error");
  26. $sql = "INSERT INTO table_name (username, password) VALUES ('$new_user', '$new_pass')";
  27. mysql_query($sql,$conn) or die ("User creation failed.");
  28. echo"<p>User created successfully.</p>";
  29. echo"<p>Return to <a href='protected.php'>application</a> or <a href='login.php'>log
  30. out</a></p>";
  31.  
  32. }
  33. else
  34.   header('Location: create_user.php');
  35.  
  36. ?>
  37. </body>
  38. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement