我写
<?
header("Location:http://example.com");
?>
Run Code Online (Sandbox Code Playgroud)
但没有发生重定向.如何重定向?
但是我没有权限编辑php.ini所以在php.ini中启用了safe_mode
我正在制作一个网站,根据不同的场景进行大量的PHP重定向..就像这样......
header("Location: somesite.com/redirectedpage.php");
Run Code Online (Sandbox Code Playgroud)
出于证券的考虑,我只是想彻底了解重定向的工作原理.我的问题是,在此标头调用之后PHP是否继续执行?
例如......回声是否仍然在这段代码中执行?
function Redirect($URL)
{
header("Location: " . $URL);
}
Redirect("http://somesite.com/redirectedpage.php");
echo("Code still executed");
Run Code Online (Sandbox Code Playgroud)
如果是这样......我会将Redirect功能更改为此...使回显不执行但仍然重定向?
function Redirect($URL)
{
header("Location: " . $URL);
exit(1);
}
Redirect("http://somesite.com/redirectedpage.php");
echo("Code still executed");
Run Code Online (Sandbox Code Playgroud)
出于证券的考虑,我只是想彻底了解重定向的工作原理.
我需要在php中创建一个身份验证脚本.我已经创建了一个login.php页面,用户可以在其中输入他的unsername /密码,并根据数据库进行检查.如果unsername/password是正确的,则应将用户与$ _SERVER ['username']变量一起转发到members.php页面.
PHP中用于访问另一个网页的命令是什么,在这种情况下是members.php?
在伪代码中,我看到它是这样的:
if ( unsername/password are OK ) { $_SERVER['username'] = $username; goto(members.php); }
Run Code Online (Sandbox Code Playgroud)
谢谢!
我使用mobiledetect将移动用户重定向到特定页面.但是,当我写这篇文章时,我收到致命错误redirect().任何人都可以让我知道我错过了哪里和什么?
require_once 'Mobile_Detect.php';
$detect = new Mobile_Detect;
$deviceType = ($detect->isMobile() ? ($detect->isTablet() ? 'tablet' : 'phone') : 'computer');
$scriptVersion = $detect->getScriptVersion();
if ($detect->isMobile())
redirect('iammobile.php');
else
echo '<h1>I am Desktop</h1>';
Run Code Online (Sandbox Code Playgroud) 在Express中,我可以使用response.redirect(“”)重定向到其他URL。同样,如何在Connect模块中重定向?我已经尝试了以下代码,但无法正常工作。
response.setHeader('Content-Type', 'text/plain');
response.end('<p>302. Redirecting to <a href="' + url+ '">' + url+ '</a></p>');
Run Code Online (Sandbox Code Playgroud) 我正在创建一个电子邮件系统,所以我做了这个小小的测试花絮,它有效.....有点?
<html>
<head><title>EMail Test</title></head>
<body>
<input type="text" name="email">
EMail (required)
<br><br>
<textarea name="comment" rows="5" cols="40"></textarea> what's your problem?
<br><br>
<form method="POST" action=''>
<input type="submit" name="button1" value="Submit">
</form>
<?php
if (isset($_POST['button1'])) {
$msg=$_POST['email']." asks: ".$_POST['comment'];
echo $msg;
$email=$_POST['email'];
$SupportNinga="Typhoone01@gmail.com";
$mail=mail($SupportNinga,"Question from ".$email,$msg);
echo "Emailing...";
if($mail) {
echo"E-mail sent sucessfully";
}
}
?>
</body>
</html>Run Code Online (Sandbox Code Playgroud)
这被放入在线主机,似乎没有用.
它发送了电子邮件,但它只是说"问题来自:".我可以说它没有正确读取$ _POST.
帮助是appriciated.:P