$ _POST变量问题 [英] $_POST variable problem

查看:60
本文介绍了$ _POST变量问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何添加一个变量,我将分配给我从表单中提取的$ _POST

变量列表?


我的表单通过$ q的值。这很好。我想做的是运行

一个if / else就可以了,并根据选择的内容分配一个新变量,如


if($ q = =红色){

$ q =" tp" ;; //将$ q更改为此值

$ sub =" ak" ;; //将此值附加到$ sub变量

} else {

$ q = $ q; //不要改变$ q的价值

$ sub ="" ;; //保留$ sub empty

}


然后将$ q和$ sub添加到mysql_query中进行插入。


mysql_query(" INSERT INTO`table` VALUES(\" \",\" $ q \",\" $ sub \",\ " $ comments

- $ name \",\" $ email \",\" $ today \",\" \" ))或死(mysql_error());


我可以让它添加$ q没有问题,但它没有认识到

$ sub不是原始$ _POST变量的一部分。有什么建议吗?

解决方案

_POST

从表单中提取的变量?


我的表单传递


q的值。这很好。我想要做的是运行

一个if / else就可以了,并根据选择的内容分配一个新变量,如


if(

q ==" red"){


How would I add a variable that I will assign to a list of $_POST
variables that I extract from a form?

My form passes a value for $q. That works fine. What I want to do is run
an if/else on it and assign a new variable based on what was chosen such as

if ($q == "red") {
$q = "tp"; //change $q to this value
$sub = "ak"; //attach this value to the $sub variable
} else {
$q = $q; //don''t change the value of $q
$sub = ""; //Leave $sub empty
}

Then both the $q and $sub will get added to a mysql_query for insertion.

mysql_query("INSERT INTO `table` VALUES(\"\",\"$q\",\"$sub\",\"$comments
- $name\",\"$email\",\"$today\",\"\" )") or die(mysql_error());

I can get it to add the $q with no problem but it isn''t recognizing the
$sub that wasn''t part of the original $_POST variables. Any suggestions?

解决方案

_POST
variables that I extract from a form?

My form passes a value for


q. That works fine. What I want to do is run
an if/else on it and assign a new variable based on what was chosen such as

if (


q == "red") {


这篇关于$ _POST变量问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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