php - Sessions not ending on all pages -
i'm trying create online sign system. purpose user can create event , members can sign them. i've got log in system i'm using when try log user out doesn't end session stores username on pages. when creating sign sheets new page made, it's on page session becomes stuck , won't change, when log in different user or log out. i'm still new php, works fine apart session. appreciated. sorry essay. page creates sign sheets
<?php session_start(); $sitename = $_post['ename']; $title = $_post['ename']; $sdate = $_post['sdate']; $endate = $_post['endate']; $exdate = $_post['exdate']; $desc = $_post['desc']; $pname = $_post['ename']; $user = $_post['user']; $date = date('y-m-d'); if($exdate >= $date && $sdate <= $endate && $sdate > $exdate && !empty($title)) { $con=mysqli_connect("localhost","emuas","flgdls","emuas_signup"); // check connection if (mysqli_connect_errno()) { echo "failed connect mysql: " . mysqli_connect_error(); } $sql="insert test (eventname, startdate, enddate, expirydate, description, user) values ('$_post[ename]','$_post[sdate]','$_post[endate]','$_post[exdate]','$_post[desc]','$_post[user]')"; if (!mysqli_query($con,$sql)) { die('error: ' . mysqli_error($con)); } $eventid = mysqli_insert_id($con); $file = ' <?php include ("sign_up.php"); ?> '; $fp = fopen("sign_up_sheets/$sitename.php", "w"); fputs($fp, $file); fclose($fp); $stylestphp = '<?php session_start(); ?> <html> <head> <link rel="stylesheet" type="text/css" href="table.css" /> <link rel="icon" href="http://www.emuas.co.uk/colours.ico" type="image/x-icon"> <link rel="shortcut icon" href="http://www.emuas.co.uk/colours.ico" type="image/ico"> </head> <body bgcolor="#eff0f3"> <center> <table style=" margin-top:0px" border="0" cellpadding="0" cellspacing="0" width="980" align="center" > <tr> <td bgcolor="#313e5b"><div class="div6"><img src="images/title.png" alt="emuas online"></div> </td> </tr> <tr> <td bgcolor="#646e7d"><div align="right"><img src="images/banner.png" alt=""></div></td> </tr> </table> <table style="margin:0px" border="0" cellpadding="0" cellspacing="0" width="980" align="center"> <tr> <td style="vertical-align:top" width="200" bgcolor="#ffffff" ><div style="margin-top:30px; margin-right:10px; margin-left:10px; vertical-align:top;"> <?php include("vlinks.php"); ?> </div></td> <td colspan="2" bgcolor="#ffffff" valign="top"> <div style="margin-top:0px; margin-bottom:10px;"> <?php switch($link){ case(\'\'): include("'; $styleenphp = '.php"); break; default: include("$link"); break; } ?> </div></td> </tr> </table> <table style="margin:0px" border="0" cellpadding="0" cellspacing="0" width="980" align="center"> </tr> <tr> <td colspan="2" bgcolor="#ffffff" id="main2" align="center"><div align="center" style="margin:3px"><font size="1" color="black"><br> copyright 2008</font></div> </td> </tr> <tr> <td colspan="2" bgcolor="#ffffff" class="div1"><img src="images/spacer.gif" width="1" height="20" alt=" "></td> </tr> <tr> <td colspan="2" bgcolor="#646e7d"><img src="images/spacer.gif" width="1" height="8" alt=" "></td> </tr> <tr> <td width="50%" valign="top"><div align="left" style="margin-top:10px;"><img src="images/logo_ft.png" alt="royal air force"></div></td> <td width="50%"><div align="right" style="margin-top:4px"><img src="images/crest_ft.png" alt="crest"></div></td> </tr> </table> </center> </body> </html>'; $fps = fopen("sign_up_sheets/$eventid.php", "w"); fputs($fps, $stylestphp); fputs($fps, $sitename); fputs($fps, $styleenphp); fclose($fps); mysqli_close($con); $_session['create'] = true; header ("location: sign_up.php"); } else{ $_session['error'] = true; header ('location: sign_up_creates.php'); } ?>
this included in new page. (sign_up.php)
<?php var_dump($_session); if (isset($_session["username"])){ $url = "http://$_server[http_host]$_server[request_uri]"; $parts = explode("/",$url); $name = explode(".",$parts[5]); $eventid = $name[0]; $con=mysqli_connect("localhost","emuas","*****","emuas_signup"); // check connection if (mysqli_connect_errno()) { echo "failed connect mysql: " . mysqli_connect_error(); } echo "<table class='styletitle'> <tr> <th></br></th> </tr>"; $event = mysqli_query($con,"select * test eventid='$eventid' limit 1"); while($event_row = mysqli_fetch_array($event)) { echo "<tr>"; echo "<th>" . $event_row['eventname'] . "</th>"; echo "</tr> <tr> <td><br /></td> </tr> <tr> <th> created by:</th> </tr> <tr>"; echo "<td>" . $event_row['user'] . "</td>"; echo "</tr> <tr> <td><br /></td> </tr> <tr> <th> start date: </th> <th> end date: </th> <th> expiry date: </th> </tr> <tr>"; echo "<td>" . $event_row['startdate'] . "</td>"; echo "<td>" . $event_row['enddate'] . "</td>"; echo "<td>" . $event_row['expirydate'] . "</td>"; echo "</tr> <tr> <td><br /></td> </tr> </table> <table class='styletitle'> <tr> <th>description</th> </tr> <tr>"; echo "<td>" . $event_row['description'] . "</td>"; } echo "<tr> <td></br></td> </tr> </table>"; echo "<table class='style'> <tr> <th>name</th> <th>comments</th> </tr>"; $sign = mysqli_query($con,"select * sign_up_test eventid='$eventid' order user"); while($row = mysqli_fetch_array($sign)) { echo "<tr>"; echo "<td>" . $row['user'] . "</td>"; echo "<td>" . $row['comments'] . "</td>"; echo "</tr>"; } echo "</table> <p> </p>"; mysqli_close($con); } else { header ('location: http://www.emuas.co.uk/members/sign_up.php'); } ?> <form action="sign_user.php" method="post"> <input type="hidden" name="id" value="<?php echo ($eventid) ?>" /><table> <td> comments: <br /> <input type="text" name="comments"/> <input type="submit" value="sign up"/> </td> </tr> </table> </form>
the value returned form var_dump($_session)
array(1) { ["username"]=> string(5) "admin" }
if log out or log in else remains this
Comments
Post a Comment