Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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;
- <?php
- session_start();
- if (isset($_POST['submit']))
- {
- $name = ($_POST['student_name']);
- $username = ($_POST['student_username']);
- $email = ($_POST['student_email']);
- $university = ($_POST['student_university']);
- $password = ($_POST['student_password']);
- $password2 = ($_POST['student_password2']);
- $servername = "localhost";
- $dbusername = "root";
- $dbpassword = "";
- $dbname = "registration";
- // Create connection
- $conn = new mysqli($servername, $dbusername, $dbpassword, $dbname);
- // Check connection
- if ($conn->connect_error)
- {
- die("Connection to database failed: " . $conn->connect_error);
- }
- echo "Connected successfully to database";
- $conn->close();
- if ($name=='')
- { //validation of name incase empty
- echo "<script>alert('Please enter your Name!')</script>";
- exit();
- }
- if ($username=='')
- {
- echo "<script>alert('Please enter a username!')</script>";
- exit();
- }
- //validation of username incase there is an existing username in the database
- $check_username = "select * from users where username='$username'";
- $result = mysql_query("SELECT * FROM users where username='$username'");
- $conn = new mysqli($servername, $dbusername, $dbpassword, $dbname);
- $run = mysql_query($check_username);
- if(mysql_num_rows($run)>0)
- {
- echo "<script>alert('Username $username has already been chosen, please choose another Username. ')</script>";
- exit();
- }
- if ($email=='')
- {
- //validation of email
- echo "<script>alert('Please enter your email!')</script>";
- exit();
- }
- if ($university=='')
- {
- //validation of university
- echo "<script>alert('Please enter your University!')</script>";
- exit();
- }
- if ($password=='')
- {
- //validation of passwword
- echo "<script>alert('Please enter your password!')</script>";
- exit();
- }
- if ($password==$password2)
- {
- //confirmation of password
- $password = md5($password);
- //inserting data from form into database
- $sql = "INSERT INTO users (name, username, email, university, password)
- VALUES ('$name', '$username', '$email', '$university', '$password')";
- if ($conn->query($sql)=== true){
- echo " your values have been inserted in the database";
- }else {
- echo "failed to insert values in database";
- }
- $conn->close();
- $_SESSION['message'] = "You are now logged in ";
- $_SESSION['username'] = $username;
- //redirect user to this page after they have registered
- header("location:infotainment.php");
- }
- else
- {
- //if the two passwords do not match
- $_SESSION['message'] = "The two passwords do not match";
- }
- }
- }
- ?>
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <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">
- <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">
- <title>Schoract || Registration</title>
- <link rel="stylesheet" type="text/css" href="mainstyle.css">
- <link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
- </head>
- <body>
- <header>
- <div id="header">
- <h1><a href="index.php" title="schoract benin">
- <img class="logo" src="images/schoract.png" alt="schoract benin">
- </a></h1>
- </div>
- </header>
- <div id="wrapper">
- <div id="banner">
- </div>
- <div id="navigation">
- <ul id="nav">
- <li><a href="index.php">Home</a></li>
- <li><a href="infotainment.php">Infotainment</a></li>
- <li><a href="universities.php">Universities</a></li>
- <li><b>About</b></li>
- <li><a href="contact.php">Contact</a></li>
- </ul>
- </div>
- <div id="content">
- <h2 class="registrationheader" align="center"> Sign up here to upload your music, videos, everyday stories, etc</h2>
- <form method="post" action="register.php">
- <table>
- <tr>
- <td class="registrationheader">Name:</td>
- <td><input type="text" name="student_name" class="textinput" placeholder="your full name please"></td>
- </tr>
- <tr>
- <td class="registrationheader">Username:</td>
- <td><input type="text" name="student_username" class="textinput" placeholder="example amanda234"></td>
- </tr>
- <tr>
- <td class="registrationheader">Email:</td>
- <td><input type="email" name="student_email" class="textinput" placeholder="example amanda@gmail.com"></td>
- </tr>
- <tr>
- <td class="registrationheader">University:</td>
- <td><input type="text" name="student_university" class="textinput" placeholder="example ISST BENIN"></td>
- </tr>
- <tr>
- <td class="registrationheader">Password:</td>
- <td><input type="password" name="student_password" class="textinput" placeholder="example 781227"></td>
- </tr>
- <tr>
- <td class="registrationheader">Confirm Password:</td>
- <td><input type="password" name="student_password2" class="textinput" placeholder="example 781227"></td>
- </tr>
- <tr>
- <td><input type="submit" name="submit" value="Sign up"></td>
- </tr>
- </table>
- <h3 class="registrationheader"><a href="index.php">Already registered? Login here</a></h3>
- </form>
- </div>
- <div id="sidebar">
- <div class="quote">
- </div>
- </div>
- </div>
- <footer>
- <center>
- 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>
- </center>
- </footer>
- </body>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement