Advertisement
Guest User

regi.php

a guest
Mar 25th, 2015
379
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.45 KB | None | 0 0
  1. //this is my  register page code
  2. <!doctype html>
  3. <?php
  4. $con=mysqli_connect("localhost","root","","test");
  5. if (mysqli_connect_errno())
  6.   {
  7.   echo "Failed to connect to MySQL: " . mysqli_connect_error();
  8.   }else{
  9.      
  10.   }
  11. if(isset($_POST["submit"])){
  12.  
  13.     if(!empty($_POST['finame']) && !empty($_POST['pass'])  && !empty($_POST['laname'])  && !empty($_POST['uemail'])) {
  14.             $fristname=mysqli_real_escape_string($con,$_POST['finame']);
  15.             $pass=$_POST['pass'];
  16.             $laname=mysqli_real_escape_string($con,$_POST['laname']);
  17.             $email=mysqli_real_escape_string($con,$_POST['uemail']);
  18.             $query=mysqli_query($con,"SELECT * FROM login WHERE email='".$email."'");
  19.             $numrows=mysqli_num_rows($query);
  20.             if($numrows==0)
  21.             {              
  22.                 $addtothedb="INSERT INTO login (firstname,lastname,email,password) VALUES ('". $fristname . "','". $laname ."','" . $email . "','". $pass ."')" ;          
  23.                 $result=mysqli_query($con,$addtothedb);
  24.                 $cur = "USERS/";
  25.                 $gofile=$cur.$email;
  26.                            
  27.                 if($result){
  28.                             if ( mkdir($gofile,0777) ) {
  29.                                 echo "<center>Account Successfully Created.Now you can Login.</center>";
  30.                             } else {
  31.                                     echo " <center> Account Not Successfully Created.But you can Login.</center>" ;
  32.                             }
  33.                      
  34.                                                
  35.                 }
  36.                 else {
  37.                         echo "<center>Failure</center>";
  38.                 }
  39.             }
  40.             else {
  41.                     echo "  That Email already exists! Please try again with another.";    
  42.             }
  43.        
  44.     }
  45.     else {
  46.                 echo "<center>All fields are required!</center>";
  47.     }
  48. }
  49. ?>
  50.  
  51. <html>
  52. <head>
  53. <meta name="viewport" content="width=device-width, initial-scale=1">
  54. <title>Register</title>
  55. </head>
  56. <body>
  57. <div id= "signup">
  58.     <form action="" method="POST" align="center">
  59.     <fieldset>
  60.     <div id="register_form">
  61.     <h3><center>Registration Form</center></h3>
  62.     </div>
  63.         Firstname:<br /> <input id="textdecor" type="text" name="finame" autocomplete="off" size="35"><br /><br />
  64.         Lastname:<br /> <input  id="textdecor" type="text" name="laname" autocomplete="off" size="35"><br /><br />
  65.         Email: <br /><input id="textdecor" type="email" name="uemail" value="" size="35"><br /><br />
  66.         Password:<br /> <input id="textdecor" type="password" name="pass" autocomplete="off" size="35" /><br /><br />
  67.  
  68.         <input id="sumbit_buttom"  type="submit" value="Register" name="submit" />
  69.        
  70.        
  71.         <p><center><a  class="tab-group" href=regis.php">Register</a> | <a href="log.php">Login</a></p>
  72.         </fieldset>
  73.     </form>
  74. </div>
  75. </body>
  76. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement