Advertisement
Guest User

Untitled

a guest
Jul 26th, 2016
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.85 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <?php
  3.  
  4. include ('db.php');
  5.  
  6. /*
  7. $servername = "localhost";
  8. $username = "root";
  9. $password = "";
  10. $dbname = "loginform";
  11.  
  12.  
  13. $conn = new mysqli($servername, $username, $password, $dbname);
  14.  
  15. if ($conn->connect_error) {
  16. die("Connection failed: " . $conn->connect_error);
  17. }
  18.  
  19.  
  20. if(isset($_POST['login'])){
  21. $username = $_POST['name'];
  22. $pass = $_POST['password'];
  23.  
  24.  
  25. $sql = "SELECT * FROM users WHERE name ='$username' AND password ='$pass' ";
  26.  
  27. $result = $conn->query($sql);
  28.  
  29.  
  30.  
  31. if ($result->num_rows > 0) {
  32. session_start();
  33. include('connection.php');
  34. $firstname=$_POST['firstname'];
  35. $lastname=$_POST['lastname'];
  36. $adress=$_POST['adress'];
  37. $username=$_POST['username'];
  38. $password=$_POST['password'];
  39. $tel=$_POST['tel'];
  40.  
  41. mysqli_query ("INSERT INTO member (firstname, lastname, adress, username,"
  42. . " password, tel) VALUES ('$firstname', '$lastname', '$adress', "
  43. . "'$username', '$password', '$tel')");
  44.  
  45. header ("location: index.php");
  46. mysqli_close($conn);
  47. }
  48. */
  49.  
  50.  
  51.  
  52. if(isset($_POST['submit'])){
  53.  
  54.  
  55. $lastname = $_POST['lastname'];
  56. $firstname = $_POST['firstname'];
  57. $adress=$_POST['adress'];
  58. $tel=$_POST['tel'];
  59. $username=$_POST['username'];
  60. $password=$_POST['password'];
  61. $email=$_POST['email'];
  62.  
  63.  
  64. $columns='';
  65. $values='';
  66.  
  67. foreach ($_POST as $key=>$value){
  68. $columns.=$key.',';
  69. $columns = trim(',',$columns);
  70.  
  71. }
  72.  
  73.  
  74. $sql = "INSERT INTO register ($columns) VALUES ($values)";
  75.  
  76.  
  77. if ($conn->query($sql) === TRUE) {
  78. echo "New record created successfully";
  79. } else {
  80. echo "Error: " . $sql . "<br>" . $conn->error;
  81. }
  82.  
  83. }
  84.  
  85.  
  86.  
  87.  
  88.  
  89. ?>
  90. <html>
  91. <head>
  92. <link rel="stylesheet" type="text/css" href="style.css">
  93. <meta charset="UTF-8">
  94. <title></title>
  95. </head>
  96. <body>
  97.  
  98. <div class="container">
  99. <form method="POST" action="">
  100. <label for="fname"> First Name: </label> <br/>
  101. <input type="text" id="fname" name="firstname"> <br/>
  102. <label for="lname"> Last Name: </label> <br/>
  103. <input type="text" id="lname" name="lastname"> <br/>
  104. <label for="adress"> Adress: </label><br/>
  105. <input type="text" id="adress" name="adress"> <br/>
  106. <label for="username"> Username: </label><br/>
  107. <input type="text" id="username" name="username"> <br/>
  108. <label for="pass"> Password: </label> <br/>
  109. <input type="password" id="pass" name="password"> <br/>
  110. <label for="tel"> Tel: </label><br/>
  111. <input type="tel" id="tel" name="tel"> <br/>
  112. <label for="email"> Email: </label><br/>
  113. <input type="email" id="email" name="email"> <br/>
  114. <input type="submit" name="submit" value="Submit">
  115.  
  116. </form>
  117. </div>
  118. </body>
  119. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement