如何将数据发布到同一页面 [英] How to post data to the same page

查看:79
本文介绍了如何将数据发布到同一页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗯..我回来了另一个简单的问题,但我不确定这个词是什么,所以我不能谷歌。我认为它可能与$ _SERVER [SELF]


有关我所追求的是一个将数据插入mysql数据库的表单。我想要的是该页面显示html,然后用户输入数据,按提交,如果有任何错误,请保留在该页面上并以红色显示错误。我认为我有错误,但发生的事情是,当我按提交时,我被带到另一页。这是我的简单脚本:

展开 | 选择 | Wrap | 行号

解决方案

_SERVER [SELF]

我所追求的是一个将数据插入mysql数据库的表单。我想要的是该页面显示html,然后用户输入数据,按提交,如果有任何错误,请保留在该页面上并以红色显示错误。我认为我有错误,但发生的事情是,当我按提交时,我被带到另一页。这是我的简单脚本:

展开 | 选择 | Wrap | 行号


Heya,fjm。

< blockquote class =post_quotes>
我试图将两个脚本合并为一个,但是sql是immediatley将新记录插入数据库*而不是等待按下提交按钮。



为了防止你的SQL被执行,你需要将它包含在一个条件中,检查是否


_POST有效:

展开 | 选择 | Wrap | 行号


Well.. I''m back with another simple question but I''m not sure what the term is so I can''t google it. I think it may have to do with $_SERVER[SELF]

What I am after is a form that will insert data into a mysql database. What I want is for that page to display the html, the user would then enter the data, press submit and if there are any errors, remain on that page and show the errors in red. I think I have the errors down but what is happening is that when I press submit, I am being taken to a different page. Here are my simple scripts:

Expand|Select|Wrap|Line Numbers

解决方案

_SERVER[SELF]

What I am after is a form that will insert data into a mysql database. What I want is for that page to display the html, the user would then enter the data, press submit and if there are any errors, remain on that page and show the errors in red. I think I have the errors down but what is happening is that when I press submit, I am being taken to a different page. Here are my simple scripts:

Expand|Select|Wrap|Line Numbers


Heya, fjm.

I have tried to combine both scripts into one but the sql is immediatley inserting a new record into the database *instead* of waiting until the submit button is pressed.

To prevent your SQL from getting executed, you''ll want to enclose it in a conditional that checks to see if


_POST is valid:

Expand|Select|Wrap|Line Numbers


这篇关于如何将数据发布到同一页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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