Advertisement
Guest User

Untitled

a guest
Dec 6th, 2016
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.09 KB | None | 0 0
  1. CREATE TABLE `registration`.`users` ( `id` INT NOT NULL AUTO_INCREMENT , `name` VARCHAR(100) NOT NULL , `username` VARCHAR(100) NOT NULL , `email` VARCHAR(100) NOT NULL , `university` VARCHAR(100) NOT NULL , `password` VARCHAR(100) NOT NULL , PRIMARY KEY (`id`)) ENGINE = MyISAM;
  2.  
  3. <?php
  4. session_start();
  5.  
  6. if (isset($_POST['submit']))
  7. {
  8. $name = ($_POST['student_name']);
  9. $username = ($_POST['student_username']);
  10. $email = ($_POST['student_email']);
  11. $university = ($_POST['student_university']);
  12. $password = ($_POST['student_password']);
  13. $password2 = ($_POST['student_password2']);
  14.  
  15. $servername = "localhost";
  16. $dbusername = "root";
  17. $dbpassword = "";
  18. $dbname = "registration";
  19.  
  20.  
  21. // Create connection
  22. $conn = new mysqli($servername, $dbusername, $dbpassword, $dbname);
  23.  
  24. // Check connection
  25. if ($conn->connect_error)
  26. {
  27. die("Connection to database failed: " . $conn->connect_error);
  28. }
  29. echo "Connected successfully to database";
  30. $conn->close();
  31.  
  32. if ($name=='')
  33. { //validation of name incase empty
  34. echo "<script>alert('Please enter your Name!')</script>";
  35. exit();
  36. }
  37. if ($username=='')
  38. {
  39. echo "<script>alert('Please enter a username!')</script>";
  40. exit();
  41. }
  42. //validation of username incase there is an existing username in the database
  43. $check_username = "select * from users where username='$username'";
  44. $result = mysql_query("SELECT * FROM users where username='$username'");
  45. $conn = new mysqli($servername, $dbusername, $dbpassword, $dbname);
  46. $run = mysql_query($check_username);
  47. if(mysql_num_rows($run)>0)
  48. {
  49. echo "<script>alert('Username $username has already been chosen, please choose another Username. ')</script>";
  50. exit();
  51. }
  52.  
  53.  
  54. if ($email=='')
  55. {
  56. //validation of email
  57. echo "<script>alert('Please enter your email!')</script>";
  58. exit();
  59. }
  60. if ($university=='')
  61. {
  62. //validation of university
  63. echo "<script>alert('Please enter your University!')</script>";
  64. exit();
  65. }
  66. if ($password=='')
  67. {
  68. //validation of passwword
  69. echo "<script>alert('Please enter your password!')</script>";
  70. exit();
  71. }
  72.  
  73.  
  74. if ($password==$password2)
  75. {
  76. //confirmation of password
  77. $password = md5($password);
  78. //inserting data from form into database
  79. $sql = "INSERT INTO users (name, username, email, university, password)
  80. VALUES ('$name', '$username', '$email', '$university', '$password')";
  81.  
  82. if ($conn->query($sql)=== true){
  83. echo " your values have been inserted in the database";
  84. }else {
  85. echo "failed to insert values in database";
  86. }
  87. $conn->close();
  88.  
  89. $_SESSION['message'] = "You are now logged in ";
  90. $_SESSION['username'] = $username;
  91. //redirect user to this page after they have registered
  92. header("location:infotainment.php");
  93. }
  94. else
  95. {
  96. //if the two passwords do not match
  97. $_SESSION['message'] = "The two passwords do not match";
  98. }
  99. }
  100. }
  101. ?>
  102. <!DOCTYPE html>
  103. <html lang="en">
  104. <head>
  105. <meta charset="UTF-8">
  106.  
  107. <meta name="keywords" content="Benin republic,campus connect benin republic, English schools in Benin republic,isst benin,hnaub,houdegbe north american university,hnaub students, Nigerian students in Benin, News in Benin republic, cfa exchange rate">
  108.  
  109. <meta name="description" content="A platform for Nigerian scholars in Benin republic to interact, get news, sports, entertainment, and know what is happening around them">
  110.  
  111. <title>Schoract || Registration</title>
  112.  
  113. <link rel="stylesheet" type="text/css" href="mainstyle.css">
  114.  
  115. <link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
  116.  
  117. </head>
  118.  
  119. <body>
  120.  
  121. <header>
  122. <div id="header">
  123. <h1><a href="index.php" title="schoract benin">
  124. <img class="logo" src="images/schoract.png" alt="schoract benin">
  125. </a></h1>
  126. </div>
  127. </header>
  128.  
  129. <div id="wrapper">
  130. <div id="banner">
  131.  
  132. </div>
  133.  
  134. <div id="navigation">
  135. <ul id="nav">
  136. <li><a href="index.php">Home</a></li>
  137. <li><a href="infotainment.php">Infotainment</a></li>
  138. <li><a href="universities.php">Universities</a></li>
  139. <li><b>About</b></li>
  140. <li><a href="contact.php">Contact</a></li>
  141. </ul>
  142. </div>
  143.  
  144. <div id="content">
  145. <h2 class="registrationheader" align="center"> Sign up here to upload your music, videos, everyday stories, etc</h2>
  146. <form method="post" action="register.php">
  147. <table>
  148. <tr>
  149. <td class="registrationheader">Name:</td>
  150. <td><input type="text" name="student_name" class="textinput" placeholder="your full name please"></td>
  151. </tr>
  152. <tr>
  153. <td class="registrationheader">Username:</td>
  154. <td><input type="text" name="student_username" class="textinput" placeholder="example amanda234"></td>
  155. </tr>
  156. <tr>
  157. <td class="registrationheader">Email:</td>
  158. <td><input type="email" name="student_email" class="textinput" placeholder="example amanda@gmail.com"></td>
  159. </tr>
  160. <tr>
  161. <td class="registrationheader">University:</td>
  162. <td><input type="text" name="student_university" class="textinput" placeholder="example ISST BENIN"></td>
  163. </tr>
  164. <tr>
  165. <td class="registrationheader">Password:</td>
  166. <td><input type="password" name="student_password" class="textinput" placeholder="example 781227"></td>
  167. </tr>
  168. <tr>
  169. <td class="registrationheader">Confirm Password:</td>
  170. <td><input type="password" name="student_password2" class="textinput" placeholder="example 781227"></td>
  171. </tr>
  172.  
  173. <tr>
  174. <td><input type="submit" name="submit" value="Sign up"></td>
  175. </tr>
  176.  
  177.  
  178. </table>
  179. <h3 class="registrationheader"><a href="index.php">Already registered? Login here</a></h3>
  180. </form>
  181.  
  182. </div>
  183.  
  184. <div id="sidebar">
  185. <div class="quote">
  186. </div>
  187. </div>
  188.  
  189.  
  190. </div>
  191.  
  192. <footer>
  193. <center>
  194. Copyright schoract team | <a href="privacy_policy.html">Privacy Policy</a> | <a href="terms_of_use.html">Terms of use</a> | <a href="contact.php">Contact us</a> | <a href="about.php">About us</a>
  195.  
  196. </center>
  197. </footer>
  198.  
  199. </body>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement