Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require 'core.inc.php';
- require 'connect.inc.php';
- if (isset($_POST['username']) and isset($_POST['password'])) {
- $username = $_POST['username'];
- $password = $_POST['password'];
- $pass = password_hash($password, PASSWORD_DEFAULT);
- if (!empty($username) and !empty($pass)) {
- $query = "SELECT `id` FROM `users` WHERE username='".mysql_real_escape_string($username)."' and password='".$pass."'";
- if ($result = mysql_query($query)) {
- $numrows = mysql_num_rows($result);
- if ($numrows == 0) {
- echo 'Failed';
- } else {
- $user_id = mysql_result($result, 0, 'id');
- $_SESSION['user_id']=$user_id;
- header('Location: index.php');
- }
- }
- } else {
- echo 'Enter All Fields';
- }
- }
- ?>
- <?php
- require 'core.inc.php';
- require 'connect.inc.php';
- if(!loggedin()) {
- if(isset($_POST['firstname'],$_POST['username'],$_POST['password'],$_POST['password_again'])) {
- $firstname = $_POST['firstname'];
- $username = $_POST['username'];
- $password = $_POST['password'];
- $password_again = $_POST['password_again'];
- $password_hash = md5($password);
- if(!empty($username) and !empty($password) and !empty($password_again) and !empty($firstname)) {
- if ($password!=$password_again) {
- echo 'Passwords do not match.';
- } else {
- $query = "SELECT `username` FROM `users` WHERE `username`='$username'";
- $query_run = mysql_query($query);
- $numrows = mysql_num_rows($query_run);
- if($numrows == 1) {
- $message = "The Username ".$username." Already Exists.";
- echo "<script type='text/javascript'>alert('$message');</script>";
- } else {
- $query = "INSERT INTO `users` VALUES ('','".mysql_real_escape_string($username)."','".password_hash($password, PASSWORD_DEFAULT)."','".mysql_real_escape_string($firstname)."','0')";
- if($query_run = mysql_query($query)) {
- header('Location: index.php');
- } else {
- die(mysql_error());
- }
- }
- }
- } else {
- echo 'All Fields are Required.';
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement