PHP的功能已经实现,却总是报错
代码的目的是实现图片上传到指定目录,并且在mysql中记录图片路径。
现在目的已经实现,可是页面总是报错,
报错内容就是第二行:
<!--
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
-->
<?php
if ($_GET['action'] == "save"){ //这行报错:Notice: Undefined index: action in D:\xampp\htdocs\upload.php on line 2
include_once('MYDBconn.php');
include_once('UPclass.php');
$titles=$_POST['title'];
$images=$uploadfile;
if($titles == "")
echo"<Script>window.alert('No title');history.back()</Script>";
$sql="insert into product(title,pic) values('$titles','$images')";
$result=mysql_query($sql,$conn);
echo"<Script>window.alert('congratunations');location.href='upload.php'</Script>";
}
?>
<html>
<head>
<title>images transfer</title>
</head>
<body>
<form method="post" action="?action=save" enctype="multipart/form-data">
<table border=0 cellspacing=0 cellpadding=0 align=center width="100%">
<tr>
<td width=55 height=20 align="center"> </TD>
<td height="16">
<table width="48%" height="93" border="0" cellpadding="0" cellspacing="0">
<tr>
<td>titles:</td>
<td><input name="title" type="text" id="title"></td>
</tr>
<tr>
<td>Images: </td>
<td><label>
<input name="file" type="file" value="view" >
<input type="hidden" name="MAX_FILE_SIZE" value="2000000">
</label></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" value="click me to upload" name="upload"></td>
</tr>
</table>
</td>
</tr>
</table>
</form>
</body>
</html>
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号