its not working in my webserver how to solve
Posted: Wed Jun 22, 2016 12:27 am
All pages working in localhost but its not working in my website . after login its not going to dashboard page
my login page
index.php page
dashboard page
Auth. page
my login page
Code: Select all
<?php
require('db.php');
session_start();
// If form submitted, insert values into the database.
if (isset($_POST['username'])){
$username = $_POST['username'];
$password = $_POST['password'];
$username = stripslashes($username);
$username = mysql_real_escape_string($username);
$password = stripslashes($password);
$password = mysql_real_escape_string($password);
//Checking is user existing in the database or not
$query = "SELECT * FROM `users` WHERE username='$username' and password='".md5($password)."'";
$result = mysql_query($query) or die(mysql_error());
$rows = mysql_num_rows($result);
if($rows==1){
$_SESSION['username'] = $username;
header("Location: data/dashboard.php"); // Redirect user to index.php
}else{
echo "<div class='form'><h3>Username/password is incorrect.</h3><br/>Click here to <a href='login.php'>Login</a></div>";
}
}else{
?>
<div class="form">
<h1><img src="images/logo.jpg" width="875" height="134" alt="logo"></h1>
<h1> </h1>
<h1> </h1>
<h1>Log In</h1>
<form action="" method="post" name="login">
<input type="text" name="username" placeholder="Username" required />
<input type="password" name="password" placeholder="Password" required />
<input name="submit" type="submit" value="Login" />
</form>
<p>Not registered yet? <a href='registration.php'>Register Here</a></p>
</div>
<?php } ?>Code: Select all
<?php include("auth.php"); //include auth.php file on all secure pages ?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Welcome Home</title>
<link rel="stylesheet" href="css/style.css" />
</head>
<body>
<p><img src="images/logo.jpg" width="875" height="134" alt="logo"></p>
<p> </p>
<table width="993" border="0">
<tr>
<td width="566">Welcome :- -<?php echo $_SESSION['username']; ?> !</td>
<td width="132"><table width="126" border="0">
<tr>
<td width="23" height="20"> </td>
<td width="93"><span class="l"><a href="logout.php"> Logou</a></span><a href="logout.php">t</a></td>
</tr>
</table></td>
</tr>
</table>
<p> </p>
<div class="form">
<table width="698" border="0">
<tr>
<td width="528"><span class="net">Netfork Technologies Material Records...</span></td>
<td width="160"><p> </p>
<p>..</p></td>
</tr>
</table>
<p> </p>
<p> </p>
<p><a href="dashboard.php"> </a></p>
<table width="1340" height="69" border="0">
<tr>
<td width="330"> </td>
<td width="148"><a href="dashboard.php" class="sa">Enter To Site </a></td>
<td width="848"> </td>
</tr>
</table>
</div>
</body>
</html>dashboard page
Code: Select all
<?php
require('db.php');
include("auth.php"); //include auth.php file on all secure pages ?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Dashboard - View Records</title>
<link rel="stylesheet" href="css/style.css" />
</head>
<body>
<div class="form">
<p><img src="images/logo.jpg" width="875" height="134" alt="logo">
<p>
<p>
<p>
<p>
<h1>Welcome to NetforkTechnologies ...</h1>
<p>
<p>
<table width="679" height="415" border="0">
<tr>
<td width="98"><a href="index.php">Home</a></td>
<td width="215"><a href="insert.php">Insert New Record</a></td>
<td width="199"><a href="view.php">View Records</a></td>
<td width="149"><a href="logout.php">Logout</a></td>
</tr>
</table>
</div>
</body>
</html>Auth. page
Code: Select all
<?php
session_start();
if(!isset($_SESSION["username"])){
header("Location: login.php");
exit(); }
?>