Jump to content

session information cheers.


redarrow

Recommended Posts

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'];
?>

Link to comment
Share on other sites

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>

<?}?>

 

Link to comment
Share on other sites

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()

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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;
}
}

?>

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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;
}
}
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.