I have create file index.php for uploading image and after uploaded it will be stored in database and also displayed in home page. Now it works fine.
Now i added more fields like firstname,lastname and other user required fields.
Now it displays problem uploading image.
May i know, what is the exact way to fix it?
Any help would be appreciated.
Thank you!!.
This is index.php:
<html>
<head>
<title>upload images to database</title>
</head>
<body>
<h1>Register Form</h1>
<form action="index.php" method = "POST" enctype = "multipart/form-data">
Upload Photo:<input type= "file" name= "image"><br />
<input type= "submit" value= "upload">
</form>
<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
//connect to database
mysql_connect("localhost","root","") or die(mysql_error());
mysql_select_db("image") or die(mysql_error());
$file = '';
$file= $_FILES['image'] ['tmp_name'];
if(!isset($file))
{
echo "please select an image";
}
else
{
$image = mysql_real_escape_string(file_get_contents($_FILES['image']['tmp_name']));
$image_name = mysql_real_escape_string($_FILES['image']['name']);
$image_size = getimagesize($_FILES['image']['tmp_name']);
if($image_size ==FALSE)
{
echo "That's not an image";
}
else
{
if(!$insert = mysql_query("INSERT INTO upload VALUES('','$image_name','$image')"))
{
echo "Problem uploading image";
}
else{
$lastid = mysql_insert_id();
echo "Image upload.<p/>Your Image</p><img src=get.php?id=$lastid>";
}
}
}
}
?>
</body>
</html>
This code works fine when upload image, but when i add, These lines of code, i got problem uploading image
First Name: <input type = "text" name= "fname"><br />
Last Name:<input type = "text" name= "lname"><br />
Password :<input type = "text" name = "password"><br />
Retype-password: <input type = "text" name = "rpassword"><br />
Email:<input type = "text" name = "email"><br />
Phone Num: <input type = "text" name = "phone"><br />
Address: <input type ="text" name = "address"><br />
Can anyone help me, still what code need to add?