0

Hi godd morning to everyone.
I have ,
1.index.php
2.signup.php
3.check.php
4.logout.php
5.welcome.php
6.dashboard.php
7.connect.php
Suppose, any user opens other pages except index.php(its default page), I need to show error reporting page and it should redirect to index.php. how ? is it possible?

4
Contributors
5
Replies
31
Views
2 Years
Discussion Span
Last Post by AntonyRayan
0
Index.php
<html>
<head>
<title>Login - FLATY Admin</title>
<link rel="stylesheet" href="assets/bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" href="assets/font-awesome/css/font-awesome.min.css">
<link rel="stylesheet" href="css/flaty.css">
<link rel="stylesheet" href="css/flaty-responsive.css">
<link rel="shortcut icon" href="images/login.png">
<script type="text/javascript">
function loginFunction()
{//alert('kjo8iyh78i');
var email = document.getElementById("email").value;
var password = document.getElementById("password").value;
if(email == "")
{
alert('Enetr valid email');
}
else
if(password == "")
{
alert('Enter Password');
}
}
</script>
</head>
<body class="login-page">
<div class="login-wrapper">
<form id="form-login" action="check.php" method="post">
<h3>Login to your account</h3>
<hr/>
<div class="form-group">
<div class="controls">
<input type="email" id="email" name="email" placeholder="email"class="form-control" />
</div>
</div>
<div class="form-group">
<div class="controls">
<input type="password" id="password" name="password"  placeholder="password"class="form-control" /> </div>
</div>
<div class="form-group">
<div class="controls">
<label class="checkbox">
<input type="checkbox"  name="remember" value="remember" /> Remember me
</label>
</div>
</div>
<div class="form-group">
<div class="controls">
<input type="submit" name="submit" value="Sign In"  class="btn btn-primary form-control" onFocus="loginFunction(); FriendlyErrorType()">
</div>
</div>
<hr/>
<p>
<a href="recover.php">Forgot Password</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<a href="signup.php">Sign Up</a></p>
</form>
</div>
<script src="../../ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="assets/jquery/jquery-2.0.3.min.js"><\/script>')</script>
<script src="assets/bootstrap/js/bootstrap.min.js"></script>
</body>
</html>


signup.php
<?
session_start();
include('connect.php');
?>
<html>
<head>
<title>SignUp - FLATY Admin</title>
<link rel="stylesheet" href="assets/bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" href="assets/font-awesome/css/font-awesome.min.css">
<link rel="stylesheet" href="css/flaty.css">
<link rel="stylesheet" href="css/flaty-responsive.css">
<link rel="shortcut icon" href="images/signup.jpg">
<script>
function signupFunction()
{//alert('kjo8iyh78i');
var email           =  document.getElementById("email").value;
var username        =  document.getElementById("username").value;
var password        =  document.getElementById("password").value;
var repeatpassword  =  document.getElementById("repeatpassword").value;
var image           =  document.getElementById("image").value;
if(email == "")
{
alert('Please enter Email');
}
else
if(username == "")
{
alert('Please enter username');
}
else
if(password == "")
{
alert('Please enter password');
}
else
if(repeatpassword == "")
{
alert('Please enter same password');
}
else 
if(image == "")
{
alert('Please Insert an Image');
}
}
</script>
</head>
<body class="login-page">
<div class="login-wrapper">
<form id="form-register" action="welcome.php" method="post" enctype="multipart/form-data"><!--style="display:none"-->
<h3>Sign up</h3>
<hr/>
<div class="form-group">
<div class="controls">
<input type="email" name="email" id="email"  placeholder="Email" class="form-control" required/><!--onBlur="validate('email', this.value)"-->
</div>
</div>
<div class="form-group">
<div class="controls">
<input type="text"   name="username" id="username"  placeholder="Username" class="form-control" required/>
</div>
</div>
<div class="form-group">
<div class="controls">
<input type="password" name="password" id="password" placeholder="Password" class="form-control" required/> 
</div>
</div>
<div class="form-group">
<div class="controls">
<input type="password" name="repeatpassword" id="repeatpassword" placeholder="Repeat Password" class="form-control" required/>
</div>
</div>
<input type="file"  name="image" id="image" required/>
<div class="form-group">
<div class="controls">
<label class="checkbox">
<input type="checkbox" value="remember" required/> I accept the <a href="#">user aggrement</a>
</label>
</div>
</div>
<div class="form-group">
<div class="controls">
<input type="submit" value="Sign Up" class="btn btn-primary form-control" onClick="signupFunction()"/>
</div>
</div>
<hr/>
<p class="clearfix">
<a href="index.php" class="goto-login pull-left">&larr;Back to login form</a>
</p>
</form>
</div>
<script src="../../ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="assets/jquery/jquery-2.0.3.min.js"><\/script>')</script>
<script src="assets/bootstrap/js/bootstrap.min.js"></script>
</body>
</html>
0

Have a session that sets logged it to '1' when the user logs in.

In EVERY other file check if this session is set to '1' at the very start, otherwise redirect to the login/index page.

0

Also, if you are talking about the real page-not-found (i.e. a user type in the address bar with some other page name), you may need to update your URL ReWriting rules of your server configuration, which is a different issue.

0

Thank you, and Mr iamthwee can you me some examples from my code, where I have to change

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.