Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xcode/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 在JS中为$redirectlocation和$\u POST使用PHP_Javascript_Php_Wordpress - Fatal编程技术网

Javascript 在JS中为$redirectlocation和$\u POST使用PHP

Javascript 在JS中为$redirectlocation和$\u POST使用PHP,javascript,php,wordpress,Javascript,Php,Wordpress,我已经看过了,我的调整不起作用,但是我试过了 我在一个安全端口上有一个cPanel Webmail的自定义登录,希望在自定义登录页面上填充错误消息,而不是重定向到默认端口通用登录页面 以下是我找到的代码,除了我使用Wordpress并遇到headers已经发送的错误之外,这些代码应该可以很好地工作。我试图包含pluggable.php,因为它与我过去为Wordpress管理区编写的插件一起工作,但我无法解决公共前端的错误 Username: <input type="text" name=

我已经看过了,我的调整不起作用,但是我试过了

我在一个安全端口上有一个cPanel Webmail的自定义登录,希望在自定义登录页面上填充错误消息,而不是重定向到默认端口通用登录页面

以下是我找到的代码,除了我使用Wordpress并遇到headers已经发送的错误之外,这些代码应该可以很好地工作。我试图包含pluggable.php,因为它与我过去为Wordpress管理区编写的插件一起工作,但我无法解决公共前端的错误

Username: <input type="text" name="user" value="" size="20" /><br />
Password: <input type="password" name="pass" value="" size="20" /><br />
<div style="display:none">
<input type="text" name="domain" value="emajenweb.webserversystems.com"/>
<select name="port">
  <option selected="selected" value="2096"></option>
</select>    
</div>
<?php
        if($_POST['domain'] && $_POST['user'] && $_POST['pass'] && !($_GET['failed'] == "1")) {
            $port = $_POST['port']; // sets the port number to login to
            // Get the protocol to use for this connection
            switch($port) {
              case '2096': // Secure Webmail
                $protocol = 'https://';
                break;
            }
          // Build the URL
          $redirectlocation = $protocol.$_POST['domain'].':'.$port.'/login/?user='.$_POST['username'].'&pass='.$_POST['pass'].'&failurl='.$_POST['failurl'];
          header ("Location: ".$redirectlocation); // Send URL
        } else {
          $error = 1;
          header ("Location: ".$_POST['failurl']); // Send URL if all neede information is not provided
        }
        ?>
由于标头已经发送错误,我希望将标头位置值更改为javascript,但我失败了

我让表单正常工作,但在自定义登录页面上传播失败消息时没有达到预期效果


已经发送的错误头是一个非常常见的错误。这是由于。。。好标题已发送。在向服务器发送响应时发送头。在您的情况下,它是:

Username: <input type="text" name="user" value="" size="20" /><br />
Password: <input type="password" name="pass" value="" size="20" /><br />
<div style="display:none">
<input type="text" name="domain" value="emajenweb.webserversystems.com"/>
<select name="port">
  <option selected="selected" value="2096"></option>
</select>    
</div>
所以。。。如何解决这个问题?很简单。只需在发送响应之前移动处理脚本:

<?php
        if($_POST['domain'] && $_POST['user'] && $_POST['pass'] && !($_GET['failed'] == "1")) {
            $port = $_POST['port']; // sets the port number to login to
            // Get the protocol to use for this connection
            switch($port) {
              case '2096': // Secure Webmail
                $protocol = 'https://';
                break;
            }
          // Build the URL
          $redirectlocation = $protocol.$_POST['domain'].':'.$port.'/login/?user='.$_POST['username'].'&pass='.$_POST['pass'].'&failurl='.$_POST['failurl'];
          header ("Location: ".$redirectlocation); // Send URL
        } else {
          $error = 1;
          header ("Location: ".$_POST['failurl']); // Send URL if all neede information is not provided
        }
?>
Username: <input type="text" name="user" value="" size="20" /><br />
Password: <input type="password" name="pass" value="" size="20" /><br />
<div style="display:none">
<input type="text" name="domain" value="emajenweb.webserversystems.com"/>
<select name="port">
  <option selected="selected" value="2096"></option>
</select>    
</div>
有关更多信息,请参阅此SO线程:

<?php
        if($_POST['domain'] && $_POST['user'] && $_POST['pass'] && !($_GET['failed'] == "1")) {
            $port = $_POST['port']; // sets the port number to login to
            // Get the protocol to use for this connection
            switch($port) {
              case '2096': // Secure Webmail
                $protocol = 'https://';
                break;
            }
          // Build the URL
          $redirectlocation = $protocol.$_POST['domain'].':'.$port.'/login/?user='.$_POST['username'].'&pass='.$_POST['pass'].'&failurl='.$_POST['failurl'];
          header ("Location: ".$redirectlocation); // Send URL
        } else {
          $error = 1;
          header ("Location: ".$_POST['failurl']); // Send URL if all neede information is not provided
        }
?>
Username: <input type="text" name="user" value="" size="20" /><br />
Password: <input type="password" name="pass" value="" size="20" /><br />
<div style="display:none">
<input type="text" name="domain" value="emajenweb.webserversystems.com"/>
<select name="port">
  <option selected="selected" value="2096"></option>
</select>    
</div>