My header redirect is not working on the live server

My header redirect is not working on the live server but its work on my localhost,but using the script it redirected to the desired page

This is is my code

<?php

	include('config.php');
	session_start();
	if(isset($_POST['login']))
	{
		$user=$_POST['uname'];
		$pass=$_POST['pwd'];
		$log=" select * from user where UserName='$user' AND Password='$pass' ";
		$in=mysql_query($log,$con) or die(mysql_error());
		$res=mysql_num_rows($in);
		if($res==1)
		{
			$_SESSION['id']=mysql_result($res,0);
			header('Location:dashboard.php');
			//echo "<script type='text/javascript'>location.href = 'dashboard.php';</script>";
		}
		else
		{
			echo  "<script>alert('Invalid Login')</script>" ;
		}
	}
?>	
<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="utf-8">
	<title>RESTAURANT</title>

	<!-- Google Fonts -->
	<link href='https://fonts.googleapis.com/css?family=Roboto+Slab:400,100,300,700|Lato:400,100,300,700,900' rel='stylesheet' type='text/css'>

	<link rel="stylesheet" href="css/animate.css">
	<!-- Custom Stylesheet -->
	<link rel="stylesheet" href="css/style.css">

	<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
</head>
<body>
	<div class="container">

		<div class="login-box animated fadeInUp">
			<div class="box-header">
				<h2>Log In</h2>
			</div>
			<form action="" method="post">
			<label for="username">Username</label>
			<br/>
			<input name="uname" type="text" id="username" >
			<br/>
			<label for="password">Password</label>
			<br/>
			<input name="pwd" type="password" id="password">
			<br/>
			<button name="login" type="submit">Log In</button>
			<br/>
			</form>
			<!--<a href="#"><p class="small">Forgot your password?</p></a>-->
		</div>
	</div>
</body>

Are you getting any error messages?

no not any error messages

that sounds like you have output buffering active in your php.ini.

How far does it get on your live server? Does it run the old-style MySQL calls without any trouble and then just not do the redirect?

not do the redirect

how to solve that problem

disable output buffering on your (local) server.

ok i will try that :slight_smile:

After turn of output buffering still its not working???

then check the error logs on your live server.

does it still work locally?

yeah its still working in locally

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.