Notice: Undefined index:
picture in C:\xampp\htdocs\page1.php on line 33
Warning: pathinfo() expects parameter 2 to be long, string given in
C:\xampp\htdocs\page1.php on line 35
Sorry, only JPG, JPEG, PNG & GIF
files are allowed.Sorry, your file was not uploaded. User Logged
in
////session_start();
//if
(!isset($_SESSION['login_user'])) {
//header ("Location:
page2.php");/
//}
//?>
Basic Login
Script
session_start();
$servername =
"localhost";
$username = "root";
$passwor = "";
$dbname
= "form";
$name = $_SESSION['login_user'];
echo $name;
$conn = new PDO("mysql:host=$servername;dbname=form",
$username, $passwor);
$stmt = $conn->prepare("SELECT id,
username, password FROM users where username='$name'");
$result =
$stmt->setFetchMode(PDO::FETCH_ASSOC);
echo "Connected successfully";
$target_dir= "htdocs" ."basketball/";
$target_file =
'$target_dir' .basename($_FILES['picture']['name']); //heres an error
$uploadOk = 1;
$imageFileType=pathinfo('$targetfile','PATHINFO_EXTENSION');//heres an
error
if(isset($_POST["submit"]))
{
$check = getimagesize($_FILES['picture']['tmp_name']);
if($check
!== false) {
echo "File is an image - " . $check["mime"] . ".";
$uploadOk = 1;
}
else {
echo "File is not an
image.";
$uploadOk = 0;
}
}
if($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType
!= "jpeg" && $imageFileType != "gif" )
{
echo "Sorry,
only JPG, JPEG, PNG & GIF files are allowed.";
$uploadOk = 0;
}
if ($uploadOk == 0)
{
echo "Sorry, your
file was not uploaded.";
}
else
{
if
(move_uploaded_file($_FILES['picture']['tmp_name'], $target_file)) {
echo
"The file ". basename( $_FILES["picture"]["name"]). " has been uploaded.";
}
else {
echo "Sorry, there was an error uploading your file.";
}
}
?>
User
Logged in
enctype="multipart/form-data">
value="picture">
if(isset($_POST['logout'])){
//$_SESSION['user_login']
=
'';
//die;
session_destroy();
header("Location:
login.php");}
?>
No comments:
Post a Comment