Redirect in PHP
Moderator: General Moderators
- chrys
- Forum Contributor
- Posts: 118
- Joined: Tue Oct 04, 2005 9:41 am
- Location: West Roxbury, MA (Boston)
nickman013 wrote:You need to specify the full URL for $url.
For example
videos.php would be somthing like http://www.mysite.com/videos.php.
Not necessarily true
-
Dark_AngeL
- Forum Commoner
- Posts: 39
- Joined: Tue Feb 21, 2006 5:16 am
- nickman013
- Forum Regular
- Posts: 764
- Joined: Sun Aug 14, 2005 12:02 am
- Location: Long Island, New York
Put this at the very top of your page, in between PHP tags.
Code: Select all
error_reporting('E_ALL');-
Dark_AngeL
- Forum Commoner
- Posts: 39
- Joined: Tue Feb 21, 2006 5:16 am
latest code
feyd | Please use
This is the check_login.php Code!
feyd | Please use
Code: Select all
andCode: Select all
tags where appropriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]Code: Select all
<?php
error_reporting('E_ALL');
if(isset($_POST['submit']) && $_POST['submit'] == 'Submit') //if form has been submitted
{
$url = "http://localhost/Warehouse_Services_Operations_System/main.php";
$denied = "";
$name = $_POST['name'];
$pass = $_POST['pass'];
if ($name == "Heba" && $pass == "123")
{
header('Location: '.$url.''); /* Redirect browser */
exit;
}
else {
$denied = "Sorry. You are not authorized to access this page<br>Go <a href='index.php' onclick='history.go(-1);return false'> Back </a>";
}
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>SYS</title>
.
.
.
.
...
.
.
.
.
.
.
<body>
<?php
if(!empty($denied))
{
echo $denied;
}
?>
.
.
...
.
.
.
.
.
.
.
</body>
</html>feyd | Please use
Code: Select all
andCode: Select all
tags where appropriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]Re: latest code
What you've posted doesn't have a form to submit (so we cant test), and doesn't have an error.Dark_AngeL wrote:This is the check_login.php Code!
-
Dark_AngeL
- Forum Commoner
- Posts: 39
- Joined: Tue Feb 21, 2006 5:16 am
This is the index.php the page which has the form in
Code: Select all
<form name="login" method="post" action="check_login.php"?>
<div align="center">
<div align="center">
<table width="232" border="2" cellspacing="3" bordercolor="#000000" bgcolor="#FFFFFF">
<tr>
<td width="64"><div align="center" class="style19 style21">
<div align="left"><span class="style22">Username:</span></div>
</div></td>
<td width="120" colspan="2"><div align="center" class="style24">
<div align="left">
<input type="text" name="name" size="20">
</div>
</div></td>
</tr>
<tr>
<td><div align="center" class="style24">
<div align="left"><span class="style22">Password:</span></div>
</div></td>
<td colspan="2"><div align="center" class="style24">
<div align="left">
<input type="password" name="pass" size="20">
</div>
</div></td>
</tr>
</table>
<table width="200" border="0" cellspacing="6">
<tr>
<td><div align="center">
<input name="btnletmein" type="submit" value="Let me in!" id="send" onclick="return checkForm()">
</div></td>
</tr>
</table>
</div>
</div>
</form>Your if statement is never triggered:
Remove that, and everything seems to work fine in my test.
Code: Select all
if(isset($_POST['submit']) && $_POST['submit'] == 'Submit') //if form has been submitted- nickman013
- Forum Regular
- Posts: 764
- Joined: Sun Aug 14, 2005 12:02 am
- Location: Long Island, New York
-
Dark_AngeL
- Forum Commoner
- Posts: 39
- Joined: Tue Feb 21, 2006 5:16 am