Advertisement
Guest User

Untitled

a guest
Sep 10th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. <?php
  2. error_reporting(E_ALL);
  3. $con = new mysqli('localhost', 'root', '', 'mydb');
  4. if (mysqli_connect_errno()) {
  5. echo "no connection";
  6. exit();
  7. }
  8.  
  9. if ($_SERVER['REQUEST_METHOD'] === 'POST') {
  10. $username = $_POST['username'];
  11. $email = $_POST['email'];
  12. $password = $_POST['password1'];
  13.  
  14. if(!$sql = $con->prepare("INSERT INTO mytb(username,email,password) VALUES (?,?,?)")){
  15. print_r($con->error); die;
  16. }
  17.  
  18. $sql->bind_param('sss', $username, $email, $password);
  19.  
  20. if($sql->execute()){
  21. echo 'ok';
  22. }
  23. else{
  24. echo 'not ok';
  25. }
  26. header("refresh:2; url=main.php");
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement