Advertisement
Guest User

Untitled

a guest
Feb 14th, 2019
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.38 KB | None | 0 0
  1. <?php
  2. session_start();
  3. $host="127.0.0.1";
  4. $user="root";
  5.  
  6. $username="";
  7. $email="";
  8. $password="";
  9. $errors=array();
  10.  
  11. $db="demo";
  12. $con=mysqli_connect('127.0.0.1','root','');
  13. mysqli_select_db($con,  $db);
  14.  
  15.  
  16. if(isset($_POST['register'])){
  17.     $username=$_POST['username'];
  18.     $name=$_POST['name'];
  19.     $surname=$_POST['surname'];
  20.     $password1=$_POST['password1'];
  21.     $password2=$_POST['password2'];
  22.    
  23.    
  24.     if(empty($username)){
  25.         array_push($errors,"Username is required");  
  26.     }
  27.     if(empty($name)){
  28.         array_push($errors,"Name is required");
  29.     }
  30.     if(empty($surname)){
  31.         array_push($errors,"Surname is required");
  32.     }
  33.     if(empty($password1)){
  34.         array_push($errors,"Password is required");  
  35.     }
  36.     if(empty($password2)){
  37.         array_push($errors,"Confirm the first password");
  38.     }
  39.      if($password1 != password2){
  40.         array_push($errors,"The two password do not match");  
  41.     }
  42.    
  43.      if(count($errors)==0){
  44.         //$password=md5(password1)
  45.         $sql="INSERT INTO loginform(user,pass,name,surname) VALUES ('$username','$password1','$name','$surname')";
  46.          
  47.         mysqli_query($db,$sql);
  48.     }
  49.    
  50. }
  51.  
  52.  
  53. ?>
  54.  
  55.  
  56. <html>
  57.     <head>
  58.         <title>Registration</title>
  59.         <link rel="stylesheet" type="text/css" href="style.css">
  60.     </head>
  61.     <body>
  62.     <form method="POST" action="register.php" id="myForm">
  63.             <h1>REGISTRAZIONE</h1>
  64.             <?php include('errors.php'); ?>
  65.             <div>
  66.                 <input placeholder="Username" name="username" type="text" id="username" required="">
  67.             </div>
  68.             <div>
  69.                 <input placeholder="Name" name="name" type="text" id="name" required="">
  70.             </div>
  71.             <div>
  72.                 <input placeholder="Surname" name="surname" type="text" id="surname" required="">
  73.             </div>
  74.             <div>
  75.                 <input placeholder="Password" name="password1" type="password" id="password1" required="">
  76.             </div>
  77.             <div>
  78.                 <input placeholder="Confirm Password" name="password2" type="password" id="password2" required="">
  79.             </div>
  80.             <div>
  81.                 <button type="submit" name="submit" value="button" id="btn" onclick="">REGISTRATI</button>
  82.             </div>
  83.            
  84.         </form>
  85.     </body>
  86.    
  87. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement