ShiwaniGoel

login register php

Jul 11th, 2016
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.69 KB | None | 0 0
  1. <?php
  2. if (!empty($_POST['login-submit']))
  3. {
  4. $user=$_POST['user'];
  5. $pass=$_POST['pass'];
  6. $servername="localhost";
  7. $username="root";
  8.  
  9. //create connection
  10. $conn=new mysqli($servername,$username,"","projectdb");
  11. //check connection
  12. if($conn->connect_error)
  13. {
  14. die("failed".$conn->connect_error);
  15. }
  16.  
  17. $sql="SELECT user FROM users where (name='".$user."' OR email='".$user."') and password='".$pass."')"; // pro$
  18.  
  19. if($conn->query($sql)===TRUE)
  20. {
  21. echo "<html><h1>Welcome!</h1></html>";
  22. }
  23. else
  24. {
  25. echo "<html> <body> <h1>Hi!<h1></body></html>";
  26. }
  27. $conn->close();
  28. }
  29. if (!empty($_POST['register-submit']))
  30. {
  31. //insert in table;sms on phn-otp;mail on id,pass confirm pass same
  32. echo "Thank you!<br>";
  33. $fname=$_POST["fname"];
  34. $lname=$_POST["lname"];
  35. $email=$_POST["email"];
  36. $user=$_POST["user"];
  37. $pass=$_POST["pass"];
  38. $cpass=$_POST["cpass"];
  39. $phn=$_POST["phn"];
  40. if($pass!=$cpass)
  41. {
  42. echo("Password not same.");
  43. }
  44.  
  45. //sms OTP
  46.  
  47. //echo $name."<br>".$branch."<br>".$sex."<br>".$course."<br>".$contact."<br>".$emailid."<br>";
  48. $servername="localhost";
  49. $username="root";
  50.  
  51. //create connection
  52. $conn=new mysqli($servername,$username,"","projectdb");
  53. //check connection
  54. if($conn->connect_error)
  55. {
  56. die("failed".$conn->connect_error);
  57. }
  58. //create database
  59. $sql="INSERT INTO users VALUES('".$fname."','".$lname."','".$email."','".$user."','".$pass."','".$phn."')"; //)",'".$_POST["column"]."')";
  60. if($conn->query($sql)===TRUE)
  61. {
  62. echo "You are successfully registered.<br><br>!";
  63. }
  64. else
  65. {
  66. echo "Some failure occured.";
  67. }
  68. $conn->close();
  69. }
Add Comment
Please, Sign In to add comment