redarrow Posted February 20, 2007 Share Posted February 20, 2007 advance thnk you. Hi there all i need to no if this is correct you can set a session to a varable name and the session will be as strong as a session not using a session varable name set. example. <?php $id=$_POST['id']; $id=$_SESSION['id']=$b['id']; $name=$_POST['name']; $name=$_SESSION['name']=$b['name']; $password=$_POST['password']; $password=$_SESSION['password']=$b['password']; ?> Quote Link to comment Share on other sites More sharing options...
printf Posted February 20, 2007 Share Posted February 20, 2007 As long as you have session_start();, because all your doing is making an assignment $a = $b = $c; <= $a and $b are assignments of $c! If you don't use session_start();, then all the $_SESSION[...] assignment (types) will just be ignored, (issue no warnings)! Quote Link to comment Share on other sites More sharing options...
redarrow Posted February 20, 2007 Author Share Posted February 20, 2007 do you need session_start () on the login page where the login form is i didnt think so but do you. Quote Link to comment Share on other sites More sharing options...
marcus Posted February 20, 2007 Share Posted February 20, 2007 Wherever you're starting your sessions you need session_start(); on the top of your script <?php session_start(); //etcccc ?> Quote Link to comment Share on other sites More sharing options...
redarrow Posted February 20, 2007 Author Share Posted February 20, 2007 how can a session get killed from this page <?php session_start(); $db=mysql_connect("xxxx","xxx","xxx"); mysql_select_db("mat_website",$db); if(($name)||($password)){ echo" <head><head> <title>Dj Phc</title> <body bgcolor='#ff333' vlink='blue' link='blue' alink='blue'> <table align='center'><td align='center'> "; include('header.php'); echo" <br> <h1>DJ PHC BLOG's</h1> </td> </table> <table align='center'><td align='center'> <a href='new_blog.php?id=$id'><font color='yellow'>Add A New Blog</font></a> </td> </table> <br>"; if(!isset($_GET['page'])){ $page = 1; } else { $page = $_GET['page']; } $max_results = 1; $from = (($page * $max_results) - $max_results); $query="select * from blogs order by date_added DESC LIMIT $from, $max_results "; $result=mysql_query($query); while($rec=mysql_fetch_assoc($result)){ $date_result=$rec['date_added']; $date_result=date("d-m-y",$date_result); $rec['blog']==wordwrap($rec['blog'],188,"<br>",0); echo" <table width='300' border='4' bordercolor='black' align='center'> <td align='center'> <font color='yellow'>Title:</font><br> ".$rec['title']." </td> </table> <table width='300' border='4' bordercolor='black' align='center'> <td align='center'> <font color='yellow'>Posted By:</font><br> ".$rec['posted_by']." </td> <td align='center'> <font color='yellow'>Date Added:</font><br> $date_result </td> <td align='center'> <font color='yellow'>View Blog:</font><br> <a href='view_blog.php?cmd=view&date_added=".$rec['date_added']."&id=".$rec['id']."''>Read Full Blog</a> </td> </table> <table align='center' height='150' width='300' border='4' bordercolor='black' align='center'> <td align='left' valign='top'> <font color='yellow'><div align='center'>Blog:</div></font><br>".$rec['blog']." </td> </table>"; ?> <?php $query3="select * from blogs where id='$id' and date_added='".$rec['date_added']."' "; $result3=mysql_query($query3); while($rec2=mysql_fetch_assoc($result3)){ echo" <table align='center' width='300' border='0' bordercolor='black' align='center'> <td align='left'> <a href='delete_blog.php?cmd=delete&date_added=".$rec2['date_added']."&id=".$rec2['id']."'>Delete Blog</a> </td> <td align='center'> <a href='view_blog.php?cmd=view&date_added=".$rec2['date_added']."&id=".$rec2['id']."''>View Full Blog</a> </td> <td align='right'> <a href='edit_blog.php?cmd=edit&date_added=".$rec2['date_added']."&id=".$rec2['id']."'>Edit Blog</a></td> </td> </table>"; } ?> <?php echo" </body> </html> "; $total_results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM blogs"),0); $total_pages = ceil($total_results / $max_results); echo "<table height='100' width='300' align='center'><td align='center'>"; if($page > 1){ $prev = ($page - 1); echo "<div align='center'><a href=\"".$_SERVER['PHP_SELF']."?page=$prev\">Prev</a>"; } for($i = 1; $i <= $total_pages; $i++){ if(($page) == $i){ echo "<font color='yellow'>$i</font> "; } else { echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$i\"></a> "; } } if($page < $total_pages){ $next = ($page + 1); $query2="select count(blog) as number from blogs"; $result2=mysql_query($query2); while($num=mysql_fetch_assoc($result2)){ $counted=$num['number']; echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$next\">Next</a> <br><br> <font color='yellow'>Currently</font> <font color='blue'>$counted</font> <font color='yellow'>Blog's</font></div>"; } } echo"</td></table>"; } }else{ ?> <html> <head> <title>Dj Phc</title> <body bgcolor="#ff333" vlink="blue" link="blue" alink="blue"> <?php $date_now=date("d-m-y"); $time_now=date("h:i:s"); $ip=$_SERVER['REMOTE_ADDR']; ?> <table align="center"><td><font color="yellow">Date([<?php echo $date_now;?>])</font></td><td></td><td></td><td></td><td></td> <td></td><td></td><td></td><td></td><td></td><td><font color="yellow">Time([<?php echo $time_now;?>])</font></td><td><td></td><td></td><td></td><td></td> <td></td><td></td><td></td><td></td><td></td><td><font color="yellow">Ip Logged([<?php echo $ip?>])</font></td></table> <?php include("header.php");?> <p></p> <table align="center" width="600" border="4" bordercolor="black"> <td align="center"> <table width="290" border="4" bordercolor="black"> <td align="center"> <img width="270" height="250" src="images/blog_pic.png"></img> </td> <td> <table width="290" height="250" border="4" bordercolor="black"> <td align="left" valign="top"> <font color="yellow"> Thank you for visiting my blog! <br> <br> Please register a acoount and post your blog. <br> <br> I am currently offering my dj exspirence for all that want to learn to dj please contact me. <br> <br> Please only post blogs that are dj related, All blogs will be checked before going live. <br> <br> Thank you. Dj Phc. </font> </td> </td> </table> </table> </table> <?php include("footer.php");?> </body> </html> <?}?> Quote Link to comment Share on other sites More sharing options...
marcus Posted February 20, 2007 Share Posted February 20, 2007 It dies because you're starting a new session (based on session id), which will clear all the data from their past session. Quote Link to comment Share on other sites More sharing options...
redarrow Posted February 20, 2007 Author Share Posted February 20, 2007 what lines that on lol? Quote Link to comment Share on other sites More sharing options...
tom100 Posted February 20, 2007 Share Posted February 20, 2007 This thread is getting confusing... Any page that sets or reads SESSION variables must have session_start() before any output. If the session is dieing, you most likely did not include the session in the page that created the session or the page that is reading the session. If you want to destroy a session, use session_destroy() Quote Link to comment Share on other sites More sharing options...
marcus Posted February 20, 2007 Share Posted February 20, 2007 Your first line, <?php session_start(); Quote Link to comment Share on other sites More sharing options...
redarrow Posted February 20, 2007 Author Share Posted February 20, 2007 It dies because you're starting a new session (based on session id), which will clear all the data from their past session. you statement does not make scence ok tell me more what can you see whats wrong ok. tom your right but i am at the end of this one project my 60.oooth please help i no all session information but need help. Quote Link to comment Share on other sites More sharing options...
Jessica Posted February 20, 2007 Share Posted February 20, 2007 $id=$_SESSION['id']=$b['id']; This doesn't even make sense. wtf are you trying to do? Quote Link to comment Share on other sites More sharing options...
redarrow Posted February 20, 2007 Author Share Posted February 20, 2007 does make sence $id//varable name =//equal $_SESSION['id']// session id of =$b['id'];==while loop now id becomes session name $id there you go young lady an example <?php $query_blog="select * from blog_register where name='$name' and password='$password' "; $result_blog=mysql_query($query_blog); while($b=mysql_fetch_assoc($result_blog)){ $id=$_POST['id']; $id=$_SESSION['id']=$b['id']; $name=$_POST['name']; $name=$_SESSION['name']=$b['name']; $password=$_POST['password']; $password=$_SESSION['password']=$b['password']; if(mysql_num_rows($result_blog)==1){ header("location: blog.php"); exit; } } ?> Quote Link to comment Share on other sites More sharing options...
tom100 Posted February 20, 2007 Share Posted February 20, 2007 It might make sence, but it doesn't make sense. Please describe the exact problem and what you are trying to accomplish. Try and be as clear as possible. Quote Link to comment Share on other sites More sharing options...
Jessica Posted February 20, 2007 Share Posted February 20, 2007 That's not quite how it works. What you're trying to do still doesn't make any sense. You set $id to $_POST['id'], then immediately overwrite it with the result of $_SESSION['id'] = $b['id'] which will return true. So $id will be true. Quote Link to comment Share on other sites More sharing options...
redarrow Posted February 20, 2007 Author Share Posted February 20, 2007 that correct then on all pages the $id is session of the id try it your see. Quote Link to comment Share on other sites More sharing options...
Jessica Posted February 20, 2007 Share Posted February 20, 2007 you speak english good ok. Quote Link to comment Share on other sites More sharing options...
Greaser9780 Posted February 20, 2007 Share Posted February 20, 2007 Where you said how could sessions be destroyed from this page, I saw no place where they should be. THe problem might lie in the page after that. If you don't have session_start() at the top on that one it will kill it. Quote Link to comment Share on other sites More sharing options...
redarrow Posted February 20, 2007 Author Share Posted February 20, 2007 if i set it by the rules of session's as below, does this code mean that the $varable's for id name and password are now $id $name $password from the session. or will i have to set them to the session example <?php sesion_start(); $name=$_SESSION['name']; ?> <?php session_start(); $query_blog="select * from blog_register where name='$name' and password='$password' "; $result_blog=mysql_query($query_blog); while($b=mysql_fetch_assoc($result_blog)){ $_SESSION['id']=$b['id']; $_SESSION['name']=$b['name']; $_SESSION['password']=$b['password']; if(mysql_num_rows($result_blog)==1){ header("location: blog.php"); exit; } } ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.