我无法将数据存储在MySQL数据库中。 url1数据 - >没有转发到u1.php。
我无法解决这个问题。在使用虚拟阀门在u1.php上运行此查询时,它是完美的:
mysql_query("UPDATE admins SET url1 = '1234568' WHERE id = '1'");
当我检查数据库时,它与上述值完美匹配,但是当我尝试表单数据时,url1无效。
<form action="u1.php" method="post" enctype="multipart/form-data">
<label for="file">Select The File:</label>
<input type="file" name="file" id="file">
Enter Ad Url :<input type="text" name="url1" id="url1" placeholder="Please Enter Ad Url" width: 500px;> <br><br>
<input type="submit" name="submit" value="Submit">
</form>
u1.php文件
<?php
mysql_connect("localhost","root","");
mysql_select_db("apphp");
mysql_query("UPDATE admins SET url1 = '$url1' WHERE id = '1'");
$allowedExts = array("gif", "jpeg", "jpg", "png");
$temp = explode(".", $_FILES["file"]["name"]);
$extension = end($temp);
if ((($_FILES["file"]["type"] == "image/gif")
|| ($_FILES["file"]["type"] == "image/jpeg")
|| ($_FILES["file"]["type"] == "image/jpg")
|| ($_FILES["file"]["type"] == "image/pjpeg")
|| ($_FILES["file"]["type"] == "image/x-png")
|| ($_FILES["file"]["type"] == "image/png"))
&& ($_FILES["file"]["size"] < 350000)
&& in_array($extension, $allowedExts))
{
if ($_FILES["file"]["error"] > 0)
{
echo "Error: " . $_FILES["file"]["error"] . "<br>";
}
else
{
echo "Upload: " . $_FILES["file"]["name"] . "<br>";
echo "Type: " . $_FILES["file"]["type"] . "<br>";
echo "Size: " . ($_FILES["file"]["size"] / 1024) . " kB<br>";
move_uploaded_file($_FILES["file"]["tmp_name"], "images/h1.jpg");
echo "Stored in: " . "images/" . $_FILES["file"]["name"];
}
}
else
{
echo "Invalid file";
}
?>
答案 0 :(得分:1)
在查询中使用$url1
之前,您需要设置if (isset($_POST['url1'])) {
$url1 = mysql_real_escape_string($_POST['url1']);
} else {
die ("Ad URL is required.");
}
mysql_query("UPDATE admins SET url1 = '$url1' WHERE id = '1'");
。
{{1}}