如何在php中将隐藏的输入id从表单插入数据库? [英] How do i insert hidden input id from a form to database in php?

查看:80
本文介绍了如何在php中将隐藏的输入id从表单插入数据库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

我在 post.php 页面上有一个表格。当我提交时,它只插入评论而不是帖子的ID。


这是我在 post.php 页面中的表格。

Hello ,
I have a form in post.php page . When i submit that , its inserting only the comments not the id of the post .

This is my form in post.php page .

展开 | 选择 | Wrap | 行号

推荐答案

在post.php中,输出表单,然后连接到数据库?这是没有意义的。在输出数据之前,需要连接到数据库以获取数据。现在你没有输出任何东西,然后连接到数据库。
In your post.php, you are outputting your form, then connecting to the database? That makes no sense. You need to connect to the database to get the data before you can output it. Right now you''re outputting nothing and then connecting to the database.


@Rabbit
func.php 与表格无关。在我的home.php有帖子。因此,当我点击帖子的标题时,它会执行 func.php 并在post.php中显示帖子详细信息。


不要 post.php 代码大,我已经制作了一个包含php代码的单独文件,用于选择要在 post.php 中显示的帖子的ID 页面并作为 func.php 包含在 post.php 中。这就是它。


表格用于为特别显示的帖子输入评论。所以我问我没有在我的评论表中插入pid和id。所有pid值均为0。

知道了吗?

如果是这样我该如何纠正?
@Rabbit
func.php is not related to form . In my home.php there are posts . So when i click on the title of post , it executes func.php and displays the post details in post.php .

Not to make post.php code big , i have made a separate file containing php code for selecting the id of post to display in post.php page and included in post.php as func.php . Thats it .

Form is used to enter comments for that particularly displayed post . So i asked that i am not getting pid and id inserted in my comment table . All the pid values are 0 .
Got it ?
If so how do i correct it ?


你忘了回复你的变量。


这篇关于如何在php中将隐藏的输入id从表单插入数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆