重定向无法正常工作!

编程入门 行业动态 更新时间:2024-10-24 14:27:17
本文介绍了重定向无法正常工作!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

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:www.mysite/'); } } } } 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:www.mysite/index.php"); } } else { // Login not successful echo "<script>alert('Sorry, could not log you in. Wrong login informatio.')</script>"; } } else{ }

谢谢

Thanks

推荐答案

_POST [ 登录])) { 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 {

更多推荐

重定向无法正常工作!

本文发布于:2023-10-12 17:23:20,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1485374.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:无法正常   重定向   工作

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!