gpt4 book ai didi

php - 为什么我的 'if (isset) does not interact with mysql'

转载 作者:行者123 更新时间:2023-11-29 03:51:22 25 4
gpt4 key购买 nike

为什么我的'if if (isset($_POST['submit'])) 不与 mysql 交互'请告诉我,我哪里出错了,我已经检查过这个一千次并检查了互联网......这是很多代码,但我想我已经监督了一些东西。我为自己做了评论,所以我不会忘记像“;”这样愚蠢的东西。
提前致谢

http://appsolute.vacau.com/cms

<html>
<head>
<title>Milan CMS</title>
</head>

<body>
<?php
mysql_connect("mysql15.000webhost.com", "a96443****tjiran", "ev****89") or die(mysql_error()); //opening database
mysql_select_db("a9644326_app") or die(mysql_error());
$result = mysql_query("select * from milan") or die(mysql_error()); //get msql database into $result
$content = mysql_fetch_array ($result); // make $content represent current entry
?>

<form action="<?php echo $PHP_SELF;?>" method="post" name="trainingen">
<h3>Trainingen:</h3><p><textarea name="nametrainingen" rows="10" cols="60"><?php echo $content['value']; ?></textarea></p>
<input type="submit" value="Verzenden"><input type="reset" value="Veld leeg maken">
</form>

<?php
if (isset($_POST['submit']))
{ //test if submit button is clicked
mysql_query("DELETE FROM milan WHERE tag='trainingen'") or die(mysql_error()); //delete old entry
$input = $_POST['nametrainingen']; //set $input as current entry
mysql_query("INSERT INTO milan (tag, value) VALUES ('trainingen', '$input')") or die(mysql_error()); //set tag, value as trainingen and $input(current entry)
$result = mysql_query("select * from milan") or die(mysql_error()); //reset $result to new database
$content = mysql_fetch_array ($result); //make $content represent new entry
$myFile = "trainingen.json";
$fh = fopen($myFile, 'w') or die("can't open file");
fwrite($fh, json_encode($content));
fclose($fh);
}
?>
<p>
</body>
</html>

最佳答案

$_POST 是一个 super 全局数组,它包含与表单一起提交的所有表单元素的关联数组。您没有使用 name="submit" 的输入,因此您的 isset() 失败。

关于php - 为什么我的 'if (isset) does not interact with mysql',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12035487/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com