Hello, I've just started learning PHP, please forgive any stupid mistakes. I've encountered a problem trying to use form post data and session variables together. When I attempt process data from a form in a form using session variables and carry on the session in another page, the page I carry the session over to loads extremely slowly. When I don't use a form, to submit data, everything loads quickly. I'm not sure if this has to do with my server or my code. It's driving me nuts trying to figure out why. Any help would be much appreciated. Thanks in advance. 🙂
// ------------------HTML with form (login.html)------------------
<html>
<head>
<title>Sign In</title>
</head>
<body>
<h1>Sign In</h1>
<form action="login.php" method="POST">
<table>
<tr>
<td>Username
</td>
<td><input type="text" name="username" id="username" size="25">
</td>
</tr>
<tr>
<td>Password
</td>
<td><input type="password" name="password" id="password" size="25">
</td>
</tr>
<tr>
<td colspan="2"><input type="submit" name="submit" value="Submit"></td>
</tr>
</table>
</form>
</body>
</html>
// ------------------First PHP Session Page (login.php)------------------
<?php
session_start();
echo "Starting session " . session_id() . ".<br>\n";
session_register('username');
$SESSION['name'] = $POST['username'];
echo "<p>Welcome, ". $_SESSION['name'] . "</p>\n";
echo "<a href='logout.php'>Logout</a><br>\n";
?>
// ------------------First PHP Session Page (login.php)------------------
<?php
session_start();
setcookie(session_name(),"");
echo "Goodbye, " . $_SESSION['name']. "<br>\n";
echo "Ending session ". session_id() . ".<br>\n";
?>