gpt4 book ai didi

php - 在mysql中存储页面id

转载 作者:行者123 更新时间:2023-11-29 13:29:58 24 4
gpt4 key购买 nike

我有这个 php 代码。

<?php
if (isset($_POST['name'], $_POST['post'])) {
$cast = $_POST['cast'];
$name = $_POST['name'];
$email = $_POST['email'];
$post = nl2br ($_POST['post']);
$ipaddress = $_POST['ipaddress'];

if (empty($name) or empty($post)) {
$error = 'All Fields Are Required!';
}else{
$query = $pdo->prepare('INSERT INTO comments (cast, name, email, post, ipaddress) VALUES(?, ?, ?, ?, ?)');
$query->bindValue(1, $cast);
$query->bindValue(2, $name);
$query->bindValue(3, $email);
$query->bindValue(4, $post);
$query->bindValue(5, $ipaddress);

$query->execute();
?>

还有这个表格。

<?php if (isset($error)) { ?>
<small style="color:#aa0000;"><?php echo $error; ?></small><br /><br />
<?php } ?>

<form action="episode.php?id=<?php echo $data['cast_id']; ?>" method="post" autocomplete="off" enctype="multipart/form-data">
<input type="text" name="name" placeholder="Name" /> / <input type="text" name="email" placeholder="Email" /><small style="color:#aa0000;">*</small><br /><br />
<textarea rows="10" cols="50" name="post" placeholder="Comment"></textarea><br /><br />
<input type="submit" value="Add Comment" />
<br /><br />
<small style="color:#aa0000;">* <b>Email will not be displayed publicly</b></small><br />
</form>

每个页面的 url 都会显示:example.php?id=1,每次转换都有一个单独的 id。

如何让我的表单添加 url 中的 id 以显示在上面的强制转换字段中?

请帮忙。

谢谢。

最佳答案

只需使用 $_GET['id'] 而不是您的 $data

<form action="episode.php?id=<?php echo $_GET['id']; ?>"

关于php - 在mysql中存储页面id,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19611548/

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