I'm using Linux Debian
trying to make Login & Registration System With php
on control page
index.php:
<?php
include("connect.php");
global $tf_handle;
$error = "";
if (isset($_POST['submit']))
{
$firstName = $_POST['fname'];
$lastName = $_POST['lname'];
$email = $_POST['email'];
$password = $_POST['password'];
$passwordConfirm = $_POST['passwordConfirm'];
$image = $_FILES['image']['name'];
$tmp_image = $_FILES['image']['tmp_name'];
$imageSize = $_FILES['image']['size'];
if($image == "")
{
$error = "Please Upload Image ";
}
else
{
$insertQuery = "INSERT INTO users (firstName,lastName,email,password,image)
VALUES ('$firstName','$lastName','$email','$password','$image')";
if(mysqli_query($tf_handle,$insertQuery))
{
if(move_uploaded_file($tmp_image,"images/$image"))
{
$error = "You're successfully registered";
}
else
{
$error = "Image isn't Uploaded";
}
}
}
}
?>
<!doctype html>
<html>
<head>
<title>Registration Page</title>
<link rel="stylesheet" href="css/styles.css" />
</head>
<body>
<div id="error"><?php echo $error;?></div>
<div id="wrapper">
<div id="formDiv">
<form method="POST" action="index.php" enctype="multipart/form-data">
<label>First Name:</label><br/>
<input type="text" name="fname" required /><br/><br/>
<label>Last Name:</label><br/>
<input type="text" name="lname" required /><br/><br/>
<label>Email:</label><br/>
<input type="text" name="email" required /><br/><br/>
<label>Password:</label><br/>
<input type="password" name="password" required /><br/><br/>
<label>Re-enter Password:</label><br/>
<input type="password" name="passwordConfirm" required /><br/><br/>
<label>Image:</label><br/>
<input type="file" name="image" required /><br/><br/>
<input type="submit" name="submit" value="Registration" />
</form>
</div>
</div>
</body>
</html>
While running the script
The Query Works Fine and it inserts information into Database
the problem it doesn't move the image to (images) Folder
move_uploaded_file($tmp_image,"images/$image");
do i use it in wrong way ??
Result:
Warning: move_uploaded_file(images/snapshot46.png): failed to open stream: Permission denied in /var/www/html/LoginRegistrationSystem/index.php on line 51