【问题标题】:Form submit (POST) to php page gives blank page unless I refresh表单提交(POST)到php页面会给出空白页面,除非我刷新
【发布时间】:2013-11-20 21:36:54
【问题描述】:

我有一个带有 2 个文本字段和一个按钮的简单登录页面。当我按“提交”时,URL 更改为 php 页面,但我什么也看不到。我不知道如何解决它,所以我希望有人能帮助我。

我的 HTML 页面:

<!DOCTYPE html>
<html>
    <head>
        <title>Login</title>
                <link rel="stylesheet" href="style2.css" />
        <meta content="text/html;charset=utf-8" http-equiv="Content-Type">
        <meta content="utf-8" http-equiv="encoding">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.css" />
        <link rel="stylesheet" href="themes/customtheme.css" />
        <script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
        <script src="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.js"></script>
    </head>
    <body>
        <div data-role="page">
            <div data-role="header">
                <a class="ui-btn-left" href="index.html" data-icon="back">Back</a>
                <h1><span>Login</span></h1>
                <a class="ui-btn-right" href="#" data-icon="info">i & &euro;</a>
            </div>
            <div data-role="content" data-position="relative">
                <div class="loginform">
                    <form id="loginForm" action="login.php" method="POST">
                        <span>Email adress:</span>
                        <input type="text" name="email" id="email"></input>
                        <span>Password:</span>
                        <input type="password" name="password" id="password"></input>
                        <input type="submit" value="Login" />
                    </form>
                </div>
            </div>
            <div data-role="footer" data-position="fixed"></div>
        </div>
    </body>
</html>

还有我的 login.php:

<?php session_start();
    error_reporting(E_ALL);
    ini_set('display_errors',TRUE);
    ini_set('display_startup_errors',TRUE); 
    echo ("Test");
?>

我什至没有看到“测试”或任何错误...

【问题讨论】:

  • session_start() 之前添加一个回声。如果您甚至没有看到这一点,那么在您的脚本到达其余代码之前,有些东西正在杀死您的脚本。 ini_set/reporting 更改应该在 php.ini 级别进行,因此它们在脚本尝试启动时生效。启动后尝试更改它们是没有意义的,如果它是一个启动错误杀死东西。
  • 在删除 echo 之前的 3 行之后尝试 echoing "test 并逐行添加,看看是哪一行导致了问题。如果仍然无法正常工作,则意味着其他原因导致脚本根本不跑。
  • 我测试了你的代码,它与你在&lt;head&gt;&lt;/head&gt; 中的 jQuery 有关,因为当我删除所有这些时,它会回显test
  • 我在 session_start 之前放置并回显,我什至没有看到...

标签: php html jquery-mobile form-submit


【解决方案1】:

其实不是 php 的问题。假设您使用的是 JQuery 移动版。禁用 data-ajax 可能会有所帮助。

<script type="text/javascript">
$(document).bind("mobileinit", function () {
    $.mobile.ajaxEnabled = false;
});
</script>

在您的 html 页面上使用此代码。

【讨论】:

  • 之前
  • 我在头部和身体上都进行了测试,但没有成功。 @Joetjah see my comment
  • 刚刚看到你的键盘文件,做得很好:) +1 @Md.Al-Amin
  • @Fred-ii- 您也非常感谢您的时间和精力!我真的很感激!
  • 不客气,很高兴找到了解决方案,这很重要,干杯。 @Joetjah
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-05-25
  • 1970-01-01
相关资源
最近更新 更多