在屏幕上上传任何图像之前在屏幕上显示无效的错误消息 index.php
<html><body>
<form action="index.php" method="POST" enctype="multipart/form-data">
<table align="center" cellspacing="0" cellpadding="6" bgcolor="#CCCCCC" border="1" bordercolor="#000000">
<tr>
<td >Firstname:</td><td><input type="text" name="fname" /></td></tr><br/><br/><br/>
<tr>
<td >Regsternumber:</td><td><input type="text" name="regno"/></td></tr><br/>
<tr>
<td>Uploadphoto:</td><td><input type="file" name="image" /></td></tr>
</table>
<br><br><br>
<center>
<input type="submit" /></center>
</form>
</form>
<form action ="table.php" method="post">
search :<select name="search">
<option>Please select
</option>
<?php
mysql_connect("localhost","root","")or die(mysql_error());
mysql_select_db("databaseimage") or die(mysql_error());
$query ="select reg FROM store";
$result=mysql_query($query);
while($nt=mysql_fetch_array($result)){
echo "<option value=".$nt['reg'].">".$nt['reg']."</option>";
}
?>
</select>
<input type="submit" name="submit">
</form>
<?php
//connect to database
mysql_connect("localhost","root","")or die(mysql_error());
mysql_select_db("databaseimage") or die(mysql_error());
$name=$_POST['fname'];
$regno=$_POST['regno'];
//file properties
$file =$_FILES['image']['tmp_name'];
if(!isset($file))
{
echo "Please select an Image";
}
else
{
$image =addslashes(file_get_contents ($_FILES['image']['tmp_name'] ) );
$image_name =addslashes($_FILES['image']['name']);
$image_size =getimagesize($_FILES['image']['tmp_name']);
}
if($image_size==FALSE)
{
echo "Not a Valid Image";
}
else
{
$order = "INSERT INTO store(name,image,fname,reg)VALUES('$image_name','$image','$name','$regno')";
if (!mysql_query($order)) { // Error handling
echo "<script>alert('Duplicate data entered');</script>";
}
}
?>
</body>
</html>
在上传任何图像“不是有效图像”之前在屏幕上显示无效错误消息请帮助我如何纠正此错误消息。