简体   繁体   English

重定向到电子邮件用户站点

[英]Redirecting to email user site

I tried execute this code and I have done something wrong because it's always redirecting me to google:我尝试执行此代码,但我做错了,因为它总是将我重定向到 google:

    <?php

$email = $_POST['email'];
$after_email = explode('@', $email);
$part = $part[1];
if($part == 'aol.com') {
        header("Location: http://aol.com");
} else if($part == 'yahoo.com') {
        header("Location: http://yahoo.com");
} else {
        header("Location: http://google.com");
}
?>

this is my html form这是我的 html 表单

<form action="snd.php">
email: <input type="text" id="email" name="email"><br>
<input type="submit" value="Submit">
</form> 

You called the explode() function on $email .您在$email上调用了explode()函数。 This implies that $after_email is now an array.这意味着$after_email现在是一个数组。 Your mistake was that you were accessing the wrong array variable.你的错误是你访问了错误的数组变量。

Change this line:改变这一行:

$part = $part[1];

to:到:

$part = $after_email[1];

EDIT编辑

Change this line in your form too:在您的表单中也更改此行:

<form action="snd.php">

to:到:

<form action="snd.php" method="post">

You also didn't specify the form method.您也没有指定表单方法。 By default, this is set to $_GET .默认情况下,这设置为$_GET But in your php script, you were calling the $_POST superglobal.但是在您的 php 脚本中,您正在调用$_POST超全局变量。 Change the method to post and you are good to go.将方法更改为post ,您就可以开始了。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 FOSUserBundle中的EmailConfirmationListener不重定向到fos_user_registration_check_email - EmailConfirmationListener in FOSUserBundle not redirecting to fos_user_registration_check_email 想发送带有URL的电子邮件,它正在工作,但是将我重定向到另一个URL,即主机/项目名称/站点/登录 - want to send email with url,it is working but it is redirecting me to another url i.e host/projectname/site/login 重定向站点以使用HTTPS - Redirecting site for HTTPS 网站不断重定向? - Site redirecting constantly? 提交表单后,FOS用户捆绑包未重定向到fos_user_registeration_check_email - FOS User Bundle Not Redirecting to fos_user_registeration_check_email after form submit 表单未重定向或发送电子邮件 - form not redirecting or sending email 当用户不查看站点时发送电子邮件通知的正确方法是什么 - what is a proper way of sending email notification when user is not viewing the site 尝试使用facebook api登录用户,并在php网站中返回电子邮件地址 - Attempting to Log user in with facebook api, and returning email address in a php site 重定向问题-网站仅在移动设备上重定向,而不在台式机上重定向 - Redirecting Issue - Site only redirecting on mobile but not on Desktop PHP:获取服务器的IP地址,用户单击该链接重定向到我的外部站点的链接 - PHP: Get IP address of server where user clicked a link redirecting to my external site
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM