Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include 'conn.php';
- if (mysqli_connect_errno()) {
- echo "Failed to connect to MySQL: " . mysqli_connect_error();
- }
- ?>
- <!doctype html>
- <html>
- <head>
- <title>Project Cinccino - Registration Submit</title>
- </head>
- <body>
- <?php
- if(!empty($_POST["username"]) && strlen($_POST["username"]<15)){
- if(ctype_alnum($_POST["username"])===true){
- $username=mysqli_real_escape_string($con,$_POST["username"]);
- if(!empty($_POST["password"]) && $_POST["password"] === $_POST["passwordconf"]){
- $password=mysqli_real_escape_string($con,$_POST["password"]);
- $password=password_hash($password,PASSWORD_DEFAULT);
- $ipaddress=$_SERVER['REMOTE_ADDR'];
- $check=mysqli_query($con,"select * FROM userinfo WHERE username='$username' and ipaddress='$ipaddress'");
- $checkdup=mysqli_num_rows($check);
- if($checkdup>0){die();}else{
- $sql="INSERT INTO userinfo (username, password, ipaddress)
- VALUES ('$username', '$password', '$ipaddress')";
- echo "You have been registered successfully!";
- }
- }else{echo "ERROR: Your username needs to be 15 characters or less and it cannot be left blank!";}
- }else{echo "ERROR: Your username needs to be alphanumeric!";}
- }else{echo "ERROR: Your password doesn't match the confirmation password and it cannot be left blank!";}
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement