if(isset($ _ POST ['submit']))两次不能正常工作 [英] if(isset($_POST['submit'])) twice not working second time

查看:75
本文介绍了if(isset($ _ POST ['submit']))两次不能正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我拉着我的头发。我早些时候做过这个工作。



我的 confirm.php 检查上一页表单中的变量。然后回应它们,以便观众可以确认答案。如果一切看起来都不错,他们可以点击贝宝图像 name =submit,它会再次通过isset并发送 mail()并更新表单动作的URL,然后用一些javascript代码将变量发布到paypal我得到了以前的帮助。



编辑:
我上传更多简化代码:

form.php页面:

 < form action =test.phpmethod =post> 
名称:< input type =textname =namevalue =/>
< input type =submitname =sendvalue =send/>
< / form>

Confirm.php:

 < ;? 
ini_set(display_errors,2);
ERROR_REPORTING(E_ALL);

$ url ='';
if(isset($ _ POST ['send']))
{
$ data = $ _POST ['name'];
} else {
echoSEND is not Set;


$ b $ if(isset($ _ POST ['submit']))
{
$ data = $ _POST ['data'];
$ my_message ='测试数据:< br />< br />儿童名称'。 $ data。';
$ subject ='Mike TEST';
$ headers =From:mrawers@xxxx.com\r\\\
;
$ headers。=回复:mrawers@xxxx.com\r\\\
;
$ headers。=Content-type:text / html\r\\\
;

$ url =https://www.paypal.com/cgi-bin/webscr;

mail(mike.rawers@xxxx.com,$ my_message,$ subject,$ headers);
} else {
echoSUBMIT is not Set;
}
?>
< html>
< head>
< / head>

< body>

< form action =< ;? echo $ url;?>方法= POST >
名称:< ;? echo $ data; ?>< input type =hiddenname =datavalue =< ;? echo $ data;?>/>< br />< br />
< input type =submitvalue =submitname =submit>
< / form>
<?
if($ url!=){
?>
< script language =javascript>
document.forms [0] .submit();
< / script>
<?
} else {echoURL NOT SET;}
?>
< / body>
< / html>


解决方案

$ c $> $ _ POST 作为

  $ _ POST ['Submit_x'] $ _POST ['Submit_y' ] 

这就是为什么你的条件每次都失败。



您正在检查 $ _ POST ['submit'] PHP对变量名称是大小写敏感的。


I am pulling my hair out. I had this working earlier.

My confirm.php checks variables from the previous page's form. Then echos them so the viewer can confirm the answers. If everything looks good they can click the paypal image name="submit" and it goes through the isset again and sends mail() and updates the URL for the form action then post variables to paypal with some javascript code I got help with earlier.

EDIT: I upload more streamline code:

form.php page:

<form action="test.php" method="post">
    Name: <input type="text" name="name" value=""/>
    <input type="submit" name="send" value="send"/>
</form>

Confirm.php:

<?
ini_set("display_errors","2");
ERROR_REPORTING(E_ALL);

$url = '';
    if (isset($_POST['send']))
        {
            $data = $_POST['name'];
        }else{ 
            echo "SEND is not Set";
        }


    if (isset($_POST['submit']))
        {
            $data = $_POST['data'];
            $my_message = ' TEST DATA:<br/><br/>Child Name'. $data .'';
            $subject = 'Mike TEST';
            $headers = "From: mrawers@xxxx.com\r\n";
            $headers .= "Reply-To: mrawers@xxxx.com\r\n";
            $headers .= "Content-type: text/html\r\n";

            $url = "https://www.paypal.com/cgi-bin/webscr";

            mail("mike.rawers@xxxx.com",$my_message,$subject,$headers);
        }else{ 
            echo "SUBMIT is not Set";
        }
?>
<html>
<head>
</head>

<body>

<form action="<? echo $url; ?>" method="post">
    Name:   <? echo $data; ?><input type="hidden" name="data" value="<? echo $data; ?>"/><br/><br/>
<input type="submit" value="submit" name="submit">
</form>
<?
if ($url != "") {
?>
<script language="javascript">
document.forms[0].submit();
</script>
<?
}else{ echo "URL NOT SET";}
?>
</body>
</html>

解决方案

When your form submit it set variables in $_POST as

$_POST['Submit_x']  $_POST['Submit_y']

That's why your condition fails every time.

You are checking with the $_POST['submit'] PHP is the case sensitive in respect of variable names.

这篇关于if(isset($ _ POST ['submit']))两次不能正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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