我想把图片上传到数据库中但是却导致有没有图片时也可以上传上去,怎么修改啊?谢谢!
<html><body><?phpif(isset($_POST['submit'])){$st=$_POST['st'];$output_form=false;if(!...
<html>
<body>
<?php
if(isset($_POST['submit']))
{
$st=$_POST['st'];
$output_form=false;
if(!empty($st))
$output_form=false;
else{
$dbc=mysqli_connect("localhost","root","luYI90King90","aliendatabase")
or die('ERROR !');
$st=$_FILES['st']['name'];
$query="INSERT INTO aa (st) ".
"VALUES('$st')";
mysqli_query($dbc,$query);
mysqli_close($dbc); }
}
else {$output_form=true;}
if($output_form)
{
?>
<form enctype="multipart/form-data" action="<?php echo $_SERVER['PHP_SELF'];
?>" method="post">
<label for="st">Your Photo:</label>
<input type="file" id="st" name="st" >
<br>
<input type="submit" value="submit" name="submit" >
</form>
<?php } ?>
</body>
</html> 展开
<body>
<?php
if(isset($_POST['submit']))
{
$st=$_POST['st'];
$output_form=false;
if(!empty($st))
$output_form=false;
else{
$dbc=mysqli_connect("localhost","root","luYI90King90","aliendatabase")
or die('ERROR !');
$st=$_FILES['st']['name'];
$query="INSERT INTO aa (st) ".
"VALUES('$st')";
mysqli_query($dbc,$query);
mysqli_close($dbc); }
}
else {$output_form=true;}
if($output_form)
{
?>
<form enctype="multipart/form-data" action="<?php echo $_SERVER['PHP_SELF'];
?>" method="post">
<label for="st">Your Photo:</label>
<input type="file" id="st" name="st" >
<br>
<input type="submit" value="submit" name="submit" >
</form>
<?php } ?>
</body>
</html> 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询