{
?>
<?php
$sql1 = mysqli_query($sql1,"select * from register where email='$name' AND password='$pass'");
$r = mysqli_fetch_array($sql1);
$id = $r['id'];
echo $_SESSION['id'] = $id;
?>
<script>
**window.location = 'Home.php?id=<?php echo $id?>';**
</script>
<?php
}
?>
我使用window.location而不是header来重定向到URL中包含会话ID的下一页。
这引出了我:
此页面无效
localhost重定向了你太多次了。
尝试清除Cookie。
ERR_TOO_MANY_REDIRECTS
查看索引文件:
的index.php
<?php
require("user_agent.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>:: Online Bus-Ticket Reservation ::</title>
<!--<link rel="stylesheet" href="style.css" />-->
<style>
.table tr td {
border-bottom-width: 1px;
border-right-width: 1px;
border-bottom-style: solid;
border-right-style: outset
border-right-color: darkred;
border-bottom-color: darkred;
}
.table {
border-left-width: 1px;
border-top-width: 1px;
border-left-style: outset;
border-top-style: solid;
border-left-color: darkred;
border-top-color: darkred;
font-size: 16px;
}
a{
background-color:#3366FF;
text-align:center;
text-decoration:none;
font-family:Verdana, Geneva, sans-serif;
color:#FFF;
border:groove;
font-weight:550;
}
</style>
<script language="javascript">
function validate() {
if(document.getElementById('user').value==''){
alert('Please enter Username!');
document.getElementById('username').focus();
return false;
}
if(document.getElementById('pass').value==''){
alert('Please enter Password!');
document.getElementById('pwd').focus();
return false;
}
return true;
}
</script>
</head>
<body topmargin="0" bottommargin="0" bgcolor="#CCFF99">
<div align="center" style="width:807">
<embed src="banner3.swf" quality="high" type="application/x-shockwave-flash" wmode="transparent" width="807" height="150" pluginspage="http://www.macromedia.com/go/getflashplayer" allowScriptAccess="always"></embed>
</div>
<table bgcolor="#FFCCFF" style="margin-top:0" align="center" width="800px" border="1" cellpadding="0" cellspacing="0">
<tr><td height="5px" align="center" bgcolor="#330000" colspan="2">
<h2 style="text-align:center; color:#FFFFFF; font-family:Verdana, Geneva, sans-serif; margin-top:3px">
Welcome To Online Bus-Ticket Reservation</h2></td></tr>
<tr><td bgcolor="#CC6600" align="center" style="color:#FFFFCC; font-size:14px; display:table" id="clock" colspan="2">
<script type="text/javascript">
var lastText = "";
function updateClock() {
var d = new Date();
var s = "";
s += (10 > d.getHours() ? "0" : "") + d.getHours() + ":"
s += (10 > d.getMinutes() ? "0" : "") + d.getMinutes() + ":"
s += (10 > d.getSeconds() ? "0" : "") + d.getSeconds();
if (lastText != s) {
setText("clock", s);
lastText = s;
}
}
function setText(elemName, text) {
var elem = document.getElementById(elemName);
while (elem.childNodes.length > 0)
elem.removeChild(elem.firstChild);
elem.appendChild(document.createTextNode(text));
}
updateClock();
setInterval(updateClock,100);
</script>
<script language="JavaScript" type="text/javascript">
var d=new Date();
var monthname=new Array("January","February","March","April","May","June","July","August","September","October","November","December");
var TODAY =d.getDate() +"- " + monthname[d.getMonth()] + "-" + d.getFullYear();
document.write(TODAY);
</script>
</tr>
<tr><td height="153" colspan="2">
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="800" height="150">
<param name="movie" value="project.swf" />
<param name="quality" value="high" />
<param name="allowFullScreen" value="false" />
<param name="allowScriptAccess" value="always" />
<embed src="project.swf"
quality="high"
type="application/x-shockwave-flash"
width="800"
height="150"
allowFullScreen="false"
pluginspage="http://www.macromedia.com/go/getflashplayer"
allowScriptAccess="always" />
</object>
</td></tr>
<tr><td bgcolor="#CCCCCC" bordercolordark="#FFFFFF" align="left" colspan="2">
<h3 style="font-family:Verdana, Geneva, sans-serif; color: #000; margin-bottom:0px; margin-top:0px">Login Screen</h3></td></tr>
<tr><td width="398">
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="f">
<p style="font-family:Verdana, Geneva, sans-serif" align="center"> </p>
<p style="font-family:Verdana, Geneva, sans-serif" align="center"> Email: <input style="size:auto; width:150px" id="user" type="text" name="user" value="" />
</p>
<p style="font-family:Verdana, Geneva, sans-serif" align="center">Password:
<input type="password" id="pass" name="pass" style="size:auto; width:150px" />
</p>
<center>
<input type="submit" onclick="validate()" value="Login" name="s" style="background-color:maroon; height:20px; color:#FFF; font-weight:50" />
<a href="bus_rev.php" style="cursor:default; font-size:12px; background-color:#900;">New User</a></center>
</form>
<?php
session_start();
require("config.php");
if(isset($_POST['s'])){
$name = $_POST['user'];
$pass = $_POST['pass'];
$sql = mysqli_query($con,"select * from register where email='$name' AND password='$pass'");
if(mysqli_num_rows($sql)==0)
{
?>
<script>
alert("You seem to registered before!!!");
</script>
<?php
}
else
{
?>
<?php
$sql1 = mysqli_query($sql1,"select * from register where email='$name' AND password='$pass'");
$r = mysqli_fetch_array($sql1);
$id = $r['id'];
echo $_SESSION['id'] = $id;
?>
<script>
window.location.href='Home.php?id=$id';
</script>
<?php
}
}
?>
</td><td width="400">
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="400" height="166">
<param name="movie" value="project1.swf" />
<param name="quality" value="high" />
<param name="allowFullScreen" value="false" />
<param name="allowScriptAccess" value="always" />
<embed src="project1.swf"
quality="high"
type="application/x-shockwave-flash"
width="400"
height="166"
allowFullScreen="false"
pluginspage="http://www.macromedia.com/go/getflashplayer"
allowScriptAccess="always" />
</object></td>
</tr>
</table>
<div align="center"><img align="top" width="806" src="images1/footer.jpg" />
</div>
</body>
</html>
Home.php
<?php
session_start();
if(isset($_SESSION['id']))
{
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>:: HOME ::</title>
<script type="text/javascript" src="C:\Users\NARPAT\Desktop\basiccalendar.js"></script>
<link rel="stylesheet" href="style/table.css" />
<link rel="stylesheet" href="style/style.css" />
<style>
a{cursor:default;}
</style>
</head>
<body topmargin="0" bottommargin="0">
<div align="center">
<embed src="banner3.swf" quality="high" type="application/x-shockwave-flash" wmode="transparent" width="807" height="150" pluginspage="http://www.macromedia.com/go/getflashplayer" allowScriptAccess="always"></embed>
</div>
<table bgcolor="#FFFFCC" style="margin-top:0" align="center" width="807" border="1" cellpadding="0" cellspacing="0">
<tr><td colspan="3" bgcolor="#330000" align="center" height="5px">
<h1 style="text-align:center; color:#FFFFFF; font-size:22px; font-family:Verdana, Geneva, sans-serif; margin-top:3px">
Welcome To Online Bus-Ticket Reservation</h1></td></tr>
<tr><td colspan="3" bgcolor="#CC6600" align="center" style="color:#FFFFCC; font-size:14px">
|| <b><?php echo date("D d-M-Y");?></b> ||</td></tr>
<!-- end header -->
<?php
require("config.php");
if(isset($_SESSION['id']))
{
$uid = $_SESSION['id'];
$sql = mysqli_query($con,"select * from register where id = '$uid'");
if(mysqli_num_rows($sql)>0)
{
$r = mysqli_fetch_array($sql);
$name = $r['name'];
}
?>
</td></tr> <tr><td width="200">
<!-- start leftmenu -->
<dl id="browse">
<!-- <dt>
<a href=""></a>
</dt> -->
<span class="simpletext1">Welcome :<b><?php echo $name;?></b></span>
<hr />
<dd style="text-align: left">
<img align="absmiddle" src="images/home.png" width="16" height="16" alt="" /><a href="Home.php?id=<?php echo $uid;?>">Home</a>
</dd>
<dd style="text-align: left">
<img align="absmiddle" src="images/password.png" width="16" height="16" alt="" /><a href="password_update.php?id=<?php echo $uid;?>">Change Password</a>
</dd>
<dd style="text-align: left">
<img align="absmiddle" src="images/profile.png" width="16" height="16" alt="" /><a href="profile.php?id=<?php echo $uid;?>">View Profile</a>
</dd>
<dd style="text-align: left">
<img align="absmiddle" src="images/ticket.png" width="16" height="16" alt="" /><a href="myticket.php?id=<?php echo $uid;?>">My Tickets</a>
</dd>
<dd style="text-align: left">
<img align="absmiddle" src="images/logout.png" width="16" height="16" alt="" /><a href="logout.php">Logout</a>
</dd>
</dl>
<!-- end leftmenu --></td><td width="380">
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="382" height="195">
<param name="movie" value="rstc.swf" />
<param name="quality" value="high" />
<param name="allowFullScreen" value="true" />
<param name="allowScriptAccess" value="always" />
<param name="wmode" value="transparent">
<embed src="rstc.swf"
quality="high"
type="application/x-shockwave-flash"
WMODE="transparent"
width="382"
height="195"
allowFullScreen="true"
pluginspage="http://www.macromedia.com/go/getflashplayer"
allowScriptAccess="always" />
</object>
</td>
<td width="217">
<embed src="rightbar.swf" quality="high" type="application/x-shockwave-flash" wmode="transparent" width="217" height="195" pluginspage="http://www.macromedia.com/go/getflashplayer" allowScriptAccess="always"></embed>
</tr></table>
<table cellpadding="0" cellspacing="0" border="0" class="maintable" align="center"
width="805" valign="middle">
<form method="post">
<tr class="tabtitle">
<td colspan="4">
<table cellspacing="0" cellpadding="0" width="800">
<tr>
<td class="titletext" style="background-color:#990000">
<font size="3px" style="background-color:#C00; color:#FFF">Search For Bus Services </font>
</td>
</tr>
</table>
</td>
<tr>
<td width="20%" class="simpletext">
From Stop :
</td>
<td>
<select class="html-text-box" style="background-color:; font-style:oblique; width:100px; font-family:Verdana; font-weight:bold" name="from">
<option value="0" selected="selected">-Select-</option>
<option value="BARMER">BARMER</option>
<option value="Delhi">Delhi</option>
<option value="Jaipur">Jaipur</option>
<option value="JODHPUR">JODHPUR</option></select>
</td>
<td width="23%" class="simpletext" align="right">
To Stop :
</td>
<td align="left">
<select class="html-text-box" style="font-style:oblique; width:100px; font-family:Verdana; font-weight:bold" name="to">
<option value="0" selected="selected">-Select-</option>
<option value="BARMER" >BARMER</option>
<option value="Delhi">Delhi</option>
<option value="Jaipur">Jaipur</option>
<option value="JODHPUR">JODHPUR</option></select>
</td>
</tr>
<tr>
<td >
Journey Date :
</td>
<td >
<input type="text" style="border:2; padding:2" name="journeyDate" maxlength="10" size="10" value="" id="journeyDate">
</td>
</tr>
<tr>
<td colspan="4" height="45" align="center" valign="middle">
<input type="submit" name="search" value="Search" onclick="return callfrm(document.getElementById('currentdate').value);" class="html-button">
<input type="submit" name="resert" value="Reset" class="html-button">
</td>
</tr>
<tr>
<td colspan="4">
<div class="errormessage" align="center">
</div>
</td>
</tr>
</form>
</table>
<?php
if(isset($_POST['search']))
{
require('config.php');
$from = $_POST['from'];
$to = $_POST['to'];
$query = mysqli_query("select * from bus where from_stop ='$from' AND to_stop ='$to'");
$c = mysqli_stmt_num_rows($query);
if($c>0)
{
?>
<table width="805" height="62" align="center" cellpadding="2" cellspacing="2" class="table" bordercolor="#000000" b>
<tr align="center"><td width="115">Bus Name</td><td width="122">From</td><td width="117">To</td><td width="117">Dept Time</td><td width="119">Arrival Time</td><td width="110">Distance</td><td width="110">Fare</td><td>Available</td><td width="101"> </td></tr>
<?php
while($r1 = mysqli_fetch_array($query))
{
$bus= $r1['id'];
$bus_name = $r1['bus_name'];
$from = $r1['from_stop'];
$to = $r1['to_stop'];
$dept_time = $r1['dept_time'];
$arrival_time = $r1['arrival_time'];
$distance = $r1['distance'];
$fare = $r1['fare'];
$bust = $bus.'bus';
$query1 = mysqli_query("SELECT * from $bust where status='Available'");
$c = mysqli_num_rows($query1);
?>
<tr align="center"><td><?php echo $bus_name;?></td><td><?php echo $from;?></td><td><?php echo $to;?></td><td><?php echo $dept_time;?></td><td><?php echo $arrival_time;?></td><td nowrap="nowrap"><?php echo $distance;?></td><td><?php echo $fare; ?></td><td><?php echo $c;?></td><td><a href="res.php?id=<?php echo $uid;?>&bus=<?php echo $bus;?>">Book</a>
</td></tr></table>
<?php
}
}
}
?>
<table class="table" align="center" cellpadding="0" cellspacing="0" width="805">
<tr><td height="124"><marquee onmouseover="this.stop();" onmouseout="this.start();" draggable="auto" bgcolor="#663333" loop="-1" dropzone="move" direction="left" behavior="alternate" scrollamount="2" scrolldelay="1">
<img border="1" height="130" width="150" src="images/B1.jpg" />
<img height="130" width="150" src="images/B2.jpg" />
<img height="130" width="150" src="images/B3.jpg" />
<img height="130" width="150" src="images/B4.jpg" />
<img height="130" width="150" src="images/B5.jpg" />
<img height="130" width="150" src="images/B6.jpg" />
<img height="130" width="150" src="images/7.png" />
<img height="130" width="150" src="images/v (1).jpg" />
<img height="130" width="150" src="images/v (2).jpg" />
<img height="130" width="150" src="images/v (3).jpg" />
<img height="130" width="150" src="images/v (4).jpg" />
<img height="130" width="150" src="images/v (5).jpg" />
<img height="130" width="150" src="images/v (6).jpg" />
<img border="1" height="130" width="150" src="images/v (7).jpg" />
</marquee></td>
<div style="position:absolute; float:right; visibility:hidden">
<script type="text/javascript">
var todaydate=new Date()
var curmonth=todaydate.getMonth()+1 //get current month (1-12)
var curyear=todaydate.getFullYear() //get current year
document.write(buildCal(curmonth ,curyear, "main", "month", "daysofweek", "days", 1));
</script>
<form>
<select onChange="updatecalendar(this.options)">
<script type="text/javascript">
var themonths=['January','February','March','April','May','June',
'July','August','September','October','November','December']
var todaydate=new Date()
var curmonth=todaydate.getMonth()+1 //get current month (1-12)
var curyear=todaydate.getFullYear() //get current year
function updatecalendar(theselection){
var themonth=parseInt(theselection[theselection.selectedIndex].value)+1
var calendarstr=buildCal(themonth, curyear, "main", "month", "daysofweek", "days", 0)
if (document.getElementById)
document.getElementById("calendarspace").innerHTML=calendarstr
}
document.write('<option value="'+(curmonth-1)+'" selected="yes">Current Month</option>')
for (i=0; i<12; i++) //display option for 12 months of the year
document.write('<option value="'+i+'">'+themonths[i]+' '+curyear+'</option>')
</script>
</select>
<div id="calendarspace">
<script>
//write out current month's calendar to start
document.write(buildCal(curmonth, curyear, "main", "month", "daysofweek", "days", 0))
</script>
</div>
</form>
<script type="text/javascript">
var todaydate=new Date()
var curmonth=todaydate.getMonth()+1 //get current month (1-12)
var curyear=todaydate.getFullYear() //get current year
</script>
</div>
</tr>
</table>
<div align="center"><img align="top" width="805" src="images1/footer.jpg" />
</div>
<?php
}
else
{
header("Location:indexm.php");
}
}
else
{
header("Location:Home.php?id=$uid");
}
?>
</body>
</html>
Index.php使用config.php文件中的sql函数来获取数据库连接。
答案 0 :(得分:0)
首先在index.php
第二次重新检查home.php中的以下代码,导致home.php
一次又一次地重定向。
header("Location:Home.php?id=$uid");