重定向无法正常工作! [英] Redirection not working!

查看:90
本文介绍了重定向无法正常工作!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我在其他网站上使用此代码但在我当前的网站上一切正常但登录后只有页面没有重定向。



这里是我的代码


I am using this code in other website working there but in my current website everything working but only page not redirecting after login.

here is my code

<?php

if(isset($_POST["Login"]))
{
if ($_POST["username"]=="" || $_POST["password"]=="")
{
 echo "<script>alert('You need to provide a username and password!')</script>";
}
else
{
$user_name=$_POST["username"];
$password=$_POST["password"];
$q = "SELECT name,status FROM info WHERE email_id='$user_name' AND pass='$password'";
$data=mysql_query($q,$con) or die("Error in Query: " . mysql_error());
$num=mysql_fetch_array($data);
if(!$num)
{
echo "<script>alert('Sorry! E-Mail Id and Password donot match!')</script>";
}
else
{
$uname=$num['name'];
$ustatus=$num['status'];
if($ustatus=='lock')
{
echo "<script>alert('You Are Currently block Contact for more details!')</script>";
}
else
{

$_SESSION["user_name"]= $uname;
$_SESSION["user_email"]=$user_name;
header('Location:http://www.mysite.com/');
}
}

}
}
else
{}


如果我在会话值之后将任何警报消息设置为工作但是只有页面没有重定向到位置,会话中会出现
值。

如果您有任何人对此代码有任何建议请回复。



这里是工作的代码..


value coming in session an if i put any alert msg after session value its working but only page not redirecting to location.
If any of you has any suggestion for this code pls reply.

here is the code that working..

<?php
if(isset($_POST["Submit"]))

{
$user_name=$_POST["username"];
$password=$_POST["password"];
if (!$_POST["username"] || !$_POST["password"])
        {
        die("You need to provide a username and password.");
        }

    // Create query

  $q = "SELECT * FROM info WHERE email_id='".$_POST["username"]."' AND pass='".$_POST["password"]."'";

  // Run query
  $r = mysql_query($q);
  if ( $obj = @mysql_fetch_object($r) )
   {
	$status=$obj->status;
		if($status=='lock')
         {
          echo "<script>alert('You Are Currently block Contact for more details!')</script>";
         }
         else
          {
        $_SESSION["user_name"]= $obj->name;
       $_SESSION["user_email"]=$obj->email_id;
            header("Location:http://www.mysite.com/index.php");
          }
   }
  else
        {

       // Login not successful

      echo "<script>alert('Sorry, could not log you in. Wrong login informatio.')</script>";

	          }


}

else{

}





谢谢



Thanks

推荐答案

_POST [ < span class =code-string>登录]))
{
if
_POST["Login"])) { if (


_POST [ username] == ||
_POST["username"]=="" ||


_POST [ password] ==
{
echo < ; script> alert('您需要提供用户名和密码!')< / script>;
}
其他
{
_POST["password"]=="") { echo "<script>alert('You need to provide a username and password!')</script>"; } else {


这篇关于重定向无法正常工作!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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