Click here to Skip to main content
15,890,506 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
<!DOCTYPE html>
<html>
<head>
	<title>	</title>
</head>
<body>
	
<div class="login">


	<h1> Sign Up</h1>
	<?php

	$con=mysqli_connect("localhost","root","","arduous");

if (isset($_POST['submit'])) {



$email=$_POST['email'];
	if(empty($_POST['email'])){
		$error_msg['email']='Required!';

	}else{

		 if(!preg_match("/^[_\.0-9a-zA-Z-]+@([0-9a-zA-Z][0-9a-zA-Z-]+\.)+[a-zA-Z]{2,6}$/i", $_POST["email"])) {
      $error_msg['email'] = "Invalid email ";
        }
	}
	if(empty($_POST['pass'])){
		$error_msg['pass']='Required!';

	}else{

		
		if (strlen($_POST["pass"]) <= '8'|| !preg_match("#[0-9]+#",$_POST["pass"])||!preg_match("#[A-Z]+#",$_POST["pass"])||!preg_match("#[a-z]+#",$_POST["pass"])) 
            $error_msg['pass'] = "Your password Must Contain At Least 8 Characters,1 Number,1 Capital Letter and 1 Lowercase Letter!";
           
	}
	$password=$_POST['pass'];
	$conpass=$_POST['conpass'];
	if(empty($_POST['conpass'])){
		$error_msg['conpass']='Required!';

	}else{
		if($password!=$conpass){
					$error_msg['conpass']='passwords do not match!';

		}
	}
if(empty($_POST['file'])){
		$error_msg['file']='Required!';

	
	}
	if(!isset($error_msg['email'])&&!isset($error_msg['password'])&&!isset($error_msg['file'])&&!isset($error_msg['conpassword']))

{
	$select="select * from addemployee where email='$email'";
	$cv=mysqli_query($con,$select);
	$cg=mysqli_fetch_assoc($cv);
	if($cg=1){
  $name=$_FILES['file']['name'];
$source=$_FILES['file']['tmp_name'];
  $destination='../uploads/'.rand(0,100).time().$name;
  move_uploaded_file($source, $destination);
		$insert="insert into addemployee (pass,conpass, photo) values('".$_POST['pass']."','".$_POST['conpass']."','$destination') where email='$email'";
	}else{
		echo "you have not been registered yet plzz contact company";
	}
}


}

	?>

    <form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>" method="post" enctype="multipart/form.data">
    <input class="input" type="text" name="email" placeholder="Email"  >
     <span style="color: red; font-size: 15px; font-weight: 200;">  <?php if (isset($error_msg['email'])) {echo $error_msg['email'];}?></span><br>
        <input class="input" type="password" name="pass" placeholder="Password" >
         <span style="color: red; font-size: 15px; font-weight: 200;">  <?php if (isset($error_msg['pass'])) {echo $error_msg['pass'];}?></span><br>
        <input class="input" type="password" name="conpass" placeholder="Confirm Password" >
         <span style="color: red; font-size: 15px; font-weight: 200;">  <?php if (isset($error_msg['conpass'])) {echo $error_msg['conpass'];}?></span><br>

        <input type="file" name="file" id="file">
         <span style="color: red; font-size: 15px; font-weight: 200;">  <?php if (isset($error_msg['file'])) {echo $error_msg['file'];}?></span><br>
      
        <input type="submit" name="submit" class="btn" value="Sign Up">


    </form>
</div>
<style type="text/css">

body { 
width: 100%;
height:100%;

background:linear-gradient(-45deg,  #670d10 0%,#092756 100%);
}

.input { 
width: 300px;
margin-bottom: 10px; 
background: rgba(0,0,0,0.3);
border: none;
outline: none;
padding: 10px;
font-size: 13px;
font-family:sans-serif;
color: #fff;
text-shadow: 1px 1px 1px rgba(0,0,0,0.3);
border: 1px solid black;
border-radius: 4px;
box-shadow: inset 0 -5px 45px rgba(100,100,100,0.2),
                  0 1px 1px rgba(255,255,255,0.2);

}
.input:focus {
 box-shadow: inset 0 -5px 45px rgba(100,100,100,0.4),
  0 1px 1px rgba(255,255,255,0.2);
   }
   
	.btn { 
	
		  width: 300px;
	      padding-top: 10px;
	      padding-bottom:10px;
	      border: none;
	      outline: none;
	      margin-left: 11px;
	     

	   
	      font-size: 14px;
	      font-family:sans-serif;
	      
	     
	      text-align: center;
	     text-shadow: 0 1px 1px rgba(255, 255, 255, 0.75);
	     
	     
	     border-radius: 4px; 
	     box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05); 
	       cursor: pointer;


	        /*background-color: #6eb6de;*/
 background-image: linear-gradient(180deg, #6eb6de 10%, #4a77d4 70%);

 color: white;
 
  border: 1px solid #3762bc; 
  text-shadow: 1px 1px 1px rgba(0,0,0,0.4);
	  }

	.btn:hover{
		background:#6eb6de85;
		text-decoration: underline;
		cursor: pointer;
	}




.login { 
	position:absolute;
	top: 25%;
	left:40%;
 

width:300px;
height:300px;
}
.login h1 { 
    
    color: #fff;
 	text-shadow: 0 0 10px rgba(0,0,0,0.3);
 	letter-spacing:1px; 
 	text-align:center;
 	font-family:sans-serif;
 	




 	 }
 	 #file{
 	 	width: 300px;
margin-bottom: 10px; 
background: rgba(0,0,0,0.3);
border: none;
outline: none;
padding: 10px;
font-size: 13px;
font-family:sans-serif;
color: grey;
text-shadow: 1px 1px 1px rgba(0,0,0,0.3);
border: 1px solid black;
border-radius: 4px;
box-shadow: inset 0 -5px 45px rgba(100,100,100,0.2),
                  0 1px 1px rgba(255,255,255,0.2);
 	 }
 	 #file:before
 	 {
 	 	content: "Upload Image";
 	 	  padding: 4px;
       background-image: linear-gradient(180deg, #6eb6de 10%, #4a77d4 70%);
 	position: absolute;
 	border-radius: 2px;
 	font-size: 12px;
 	color:white;
 	 }
 	 #file:hover
 	 {
        cursor: pointer;
 	 }

</style>




</body>
</html>


What I have tried:

i have tried to recheck every single syntax error but could'nt find one
 $name=$_FILES['file']['name'];
$source=$_FILES['file']['tmp_name'];
  $destination='../uploads/'.rand(0,100).time().$name;
  move_uploaded_file($source, $destination);
this is the problem area
Posted
Updated 10-Jan-21 20:45pm
v2
Comments
Sandeep Mewara 11-Jan-21 3:18am    
Debug and see where the error is being raised. Address that.
Richard Deeming 12-Jan-21 11:35am    
Your code is vulnerable to SQL Injection[^]. NEVER use string concatenation to build a SQL query. ALWAYS use a parameterized query.

PHP: SQL Injection - Manual[^]
Richard Deeming 12-Jan-21 11:36am    
You are also storing passwords in plain text. Don't do that.
Secure Password Authentication Explained Simply[^]
Salted Password Hashing - Doing it Right[^]

PHP even has built-in functions to help you do the right thing:
PHP: password_hash[^]
PHP: password_verify[^]
Richard Deeming 12-Jan-21 11:37am    
And there's no need to store the $conpass value, since you've already validated that it is identical to the $pass field.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900