如果(使用isset($ _ POST ['提交']))不工作 [英] if(isset($_POST['submit'])) not working

查看:780
本文介绍了如果(使用isset($ _ POST ['提交']))不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道有这样的情况在这一点,但是我想尽方法,但它并没有为我工作。

I know there are cases on this, however I tried their method, but it didn't work for me.

这里是code为使用isset:我尝试过把这一声明< HEAD> 标记,并在<身体GT; 标记,但并不认为这就不一样了。 这code驻留在同一个PHP文件的提交按钮。

Here is the code for isset: I tried placing this statement before <head> tag and within <body> tag but don't think it made a difference. This code resides in the same php file as the the submit button.

<?php if(isset($_POST['action'])) {
    echo "testing";
    exit();
}?>

这里是形式和放大器;表单中的提交按钮

<form name="createCaseForm" method = "post" action = "<?php echo url_mgt::getActionURL(); ?>" id="case-form" novalidate="novalidate">
    ...
    <td colspan="1"><button style="float:right;" name="action" type="submit" value="create_case_submit">Submit</button></td>
    ...
</form>

我不知道,如果使用&LT;按钮&GT; 而不是&LT;输入&GT; 会有所作为。我也做,如果(计数($ _ POST)> 0),并没有奏效。我不知道我在做什么错。当我运行的文件,它不会回声测试,而是直奔下一个页面。我的道歉,如果这只是一件小事,但我想张贴在论坛上的方法,但没有一个似乎工作。

I'm not sure if using <button> instead <input> of would make a difference. I also did if(count($_POST) > 0) and it didn't work. I'm not sure what I'm doing wrong. When I run the file, it doesn't echo "testing", but instead went straight to the next page. My apologies if it's just a minor matter, but I tried methods posted in forums, but none seems to work.

我试着这样做:

if(isset($_POST['action']) == 0) {
  echo "Testing";
} else {
    echo "Testing2";
}

据测试显示正在加载页面时,但是当我提交按钮点击,我希望看到testing2正在打印。我是正确地说,点击提交按钮后,页面不会重新加载两次?因此,有没有办法来检查是否提交按钮被贴?

It displays testing when the page is being loaded, however when i click on the submit button, I was hoping to see testing2 being printed. Am i right to say that after clicking the submit button, the page would not reload twice? So there is no way to check if the submit button is being posted?

推荐答案

您需要一个名为表单域动作

You need a form field named action

<input type="text" name="action"/>

此外,确保 url_mgt :: getActionURL()正在输出正确的URL提交

Also, make sure that url_mgt::getActionURL() is outputting the correct URL to submit to

这篇关于如果(使用isset($ _ POST ['提交']))不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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