Jump to content

[SOLVED] sessions


ngreenwood6

Recommended Posts

I am in need of some help with sessions. I have 3 files:

 

index.php (the form):

<table border="1">
<form name="session" method="post" action="session.php">
<tr>
<td>Username
<td>:
<td><input name="username" type="text">
</tr>
<tr>
<td>Email
<td>:
<td><input name="email" type="text">
</tr>
<tr>
<td>
<td>
<td><input name="submit" type="submit" value="submit">
</form>
</table>

 

sessions.php (registering the session variable):

<?php
session_start();

$myusername = $_POST['username'];

$_SESSION['username'] = $myusername;
$_SESSION['email'] = $_POST['email'];



echo "Go to <a href='test.php'>Test</a>";

?>

 

test.php (showing the variable):

<?php
session_start();


echo $myusername;

?>

 

Whenever I submit the form it goes to the sessions page. Then i go to the test page where it should display the username that was submitted but it isn't showing anything. I am trying to get it so that I can set variables (ex. $myusername) in the page so that it is easier to call at another time. If anyone can tell me why this isnt showing the username that would be great.

Link to comment
https://forums.phpfreaks.com/topic/118655-solved-sessions/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.