470,849 Members | 1,133 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,849 developers. It's quick & easy.

SESSIONS

Hi all,

I'm trying to get the hang of Sessions using this little test program
shown below. However, the first page starts up a couple of session
variables (if they have not been started already), and invites the
user to enter a name. The second page then takes this name, adds it
to an array, and invotes the user to go back to the original page
(where hopefully his name has been added).

Any comments appreciated, Thanks

Andy
//sessionTest1.php
<?php
session_start();
header("Cache-control: private");
header("Cache-Control: no-store, no-cache, must-revalidate");
error_reporting(E_ALL);
ini_set('display_errors', '1');

?>
<html>
<body>
<form action ="sessionTest2.php" method = "post">
<p>Enter your name:</p>
<input type = 'text' name = 'textEntry'/>
<input type = 'submit' value='submit'/>
</form>

<?php

$condition=isset($names);
if(!$condition)
{
$names = array();
$i = 0;
$_SESSION['i'] = $i;
$_SESSION['names'] = $names;
}
else
{
$names = $_SESSION['names'];

for($i=0; $i<count($names); $i++)
{
echo "$names[$i]";
}

}

?>

</body>
</html>

-------------------------------------------------------------------------

//sessionTest2.php
<?php
session_start();
header("Cache-control: private");
header("Cache-Control: no-store, no-cache, must-revalidate");
?>

<html>
<body>
<form action = 'sessionTest.php' method = 'post'>
<input type = 'submit' value = 'back'/>
<?php

$names = $_SESSION['names'];
$count = $_SESSION['count'];
$lastName = $_POST['textEntry'];
$names[$count] = '$lastName';

$_SESSION['names'] = $names;
$tester = $_SESSION['names'];
echo $tester[0];
//header("Location: sessionTest.php?output=$foo");


?>
</form>
</body>
</html>
Jul 17 '05 #1
6 1775
I noticed that Message-ID:
<b2**************************@posting.google.com > from Andy contained
the following:
Any comments appreciated, Thanks


The weather is changeable isn't it?

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #2
Andy wrote:
(snip)
-------------------------------------------------------------------------

//sessionTest2.php
<?php
session_start();
header("Cache-control: private");
header("Cache-Control: no-store, no-cache, must-revalidate");


You missed the all important error reporting here, in sessionTest2.php

error_reporting(E_ALL);
ini_set('display_errors', '1');

--
USENET would be a better place if everybody read: : mail address :
http://www.catb.org/~esr/faqs/smart-questions.html : is valid for :
http://www.netmeister.org/news/learn2quote2.html : "text/plain" :
http://www.expita.com/nomime.html : to 10K bytes :
Jul 17 '05 #3
LOL

"Geoff Berrow" <bl******@ckdog.co.uk> wrote in message
news:69********************************@4ax.com...
I noticed that Message-ID:
<b2**************************@posting.google.com > from Andy contained
the following:
Any comments appreciated, Thanks


The weather is changeable isn't it?

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/

Jul 17 '05 #4
Geoff Berrow <bl******@ckdog.co.uk> wrote in message news:<69********************************@4ax.com>. ..
I noticed that Message-ID:
<b2**************************@posting.google.com > from Andy contained
the following:
Any comments appreciated, Thanks


The weather is changeable isn't it?


Thanks geoff.
Jul 17 '05 #5
I noticed that Message-ID:
<b2**************************@posting.google.com > from Andy contained
the following:
>Any comments appreciated, Thanks


The weather is changeable isn't it?


Thanks geoff.


No problem. :-)

Since you didn't actually ask a question, it was as good as any...

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #6
> No problem. :-)

Since you didn't actually ask a question, it was as good as any...


Fair comment...

Anyway, I live in Glasgow where the weather isn't changeable at all.
It always bloody rains ;-)

I'll try to make more appropriate postings in future.

Andy
Jul 17 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by The Plankmeister | last post: by
13 posts views Thread by jing_li | last post: by
3 posts views Thread by Maxime Ducharme | last post: by
3 posts views Thread by Will Woodhull | last post: by
12 posts views Thread by D. Shane Fowlkes | last post: by
6 posts views Thread by Daniel Walzenbach | last post: by
22 posts views Thread by magic_hat60622 | last post: by
Atli
2 posts views Thread by Atli | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.