Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- ob_start();
- $host="127.0.0.1"; // Host name
- $username="root"; // Mysql username
- $password=""; // Mysql password
- $db_name="student"; // Database name
- $tbl_name="student_login"; // Table name
- mysql_connect("$host", "$username", "$password")or die("cannot connect");
- mysql_select_db("$db_name")or die("cannot select DB");
- // Define $myusername and $mypassword
- $myusername=$_POST['Username'];
- $mypassword=$_POST['Password'];
- if (isset($_POST['submit'])) {
- if (!$_POST['username'] | !$_POST['password'] ) {
- die('You did not complete all of the required fields');
- }
- if (!get_magic_quotes_gpc()) {
- $_POST['username'] = addslashes($_POST['username']);
- }
- $usercheck = $_POST['username'];
- $check = mysql_query("SELECT username FROM $tbl_name WHERE username = '$usercheck'")
- or die(mysql_error());
- $check2 = mysql_num_rows($check);
- if ($check2 != 0) {
- die('Sorry, the username '.$_POST['username'].' is already in use.');
- }
- $_POST['password'] = md5($_POST['password']);
- if (!get_magic_quotes_gpc()) {
- $_POST['password'] = addslashes($_POST['password']);
- $_POST['username'] = addslashes($_POST['username']);
- }
- $insert = "INSERT INTO 'student_login' (username, password)
- VALUES ('".$_POST['username']."', '".$_POST['password']."')";
- $add_member = mysql_query($insert);
- ?>
- <h1>Registered</h1>
- <p>Thank you, you have registered - you may now login<a href ="checklogin2.php"</a></p>
- <?php
- }
- else
- {
- ?>
- <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
- <table border="0">
- <tr><td>Username:</td><td>
- <input type="text" name="username" maxlength="60">
- </td></tr>
- <tr><td>Password:</td><td>
- <input type="password" name="password" maxlength="10">
- </td></tr>
- <tr><th colspan=2><input type="submit" name="submit" value="Register"></th></tr> </table>
- </form>
- <?php
- }
- ?>
Add Comment
Please, Sign In to add comment