its not working in my webserver how to solve

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Naru
Forum Newbie
Posts: 2
Joined: Tue Jun 21, 2016 4:55 am

its not working in my webserver how to solve

Post by Naru »

All pages working in localhost but its not working in my website . after login its not going to dashboard 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>&nbsp;</h1>
<h1>&nbsp;</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 } ?>
index.php page

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>&nbsp;</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">&nbsp;</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>&nbsp;</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>&nbsp;</p>
      <p>..</p></td>
  </tr>
</table>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><a href="dashboard.php"> </a></p>
<table width="1340" height="69" border="0">
  <tr>
    <td width="330">&nbsp;</td>
    <td width="148"><a href="dashboard.php" class="sa">Enter To Site </a></td>
    <td width="848">&nbsp;</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(); }
?>
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: its not working in my webserver how to solve

Post by Celauran »

Where is it failing? Have you checked the error log?
Post Reply