Its kinda what I meant, but instead I want the user to STAY on the same page, while the login bit changes. Anyway, I found a way using i-frames using window.parent.ahref or something like that. Thanks for your awnsers. Although I do still have 1 problem. As I have been editing the script, on the login page, a 0 now pops up in a table that was previously blank, that is filled with the result of the registration, ie. the errors. Here is my source code :- 🙂
<?php
require_once('common.php');
$error = '0';
if (isset($_POST['submitBtn'])){
// Get user input
$username = isset($_POST['username']) ? $_POST['username'] : '';
$password = isset($_POST['password']) ? $_POST['password'] : '';
// Try to login the user
$error = loginUser($username,$password);
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>CRAP TV</title>
<style type="text/css">
<!--
.style1 {color: #FFFFFF}
body {
background-color: #000000;
}
.style2 {color: #000000}
-->
</style>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /></head>
<body link="#FFFFFF">
<?php if ($error != '') {?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="loginform">
<table width="300" align="center">
<tr><td><span class="style1">Username:</span></td>
<td> <input class="text" name="username" type="text" /></td></tr>
<tr><td><span class="style1">Password:</span></td>
<td> <input class="text" name="password" type="password" /></td></tr>
<tr><td colspan="2" align="center"><input class="text" type="submit" name="submitBtn" value="Login" /></td></tr>
<div align="center"><a href="register.php">Register</a>
</div>
</table>
</form>
<?php
}
?>
<?php
if (isset($_POST['submitBtn'])){
?>
<?php
}
?>
<div id="result">
<table width="100%" align="center">
<tr><td class="style1"><div align="center"><span class="style2"><br/>
<?php
if ($error == '') {
echo "Welcome $username! <br/>You are logged in!<br/><br/>";
echo '<a href="main.php">Click here to enter!</a>';
}
else echo $error;
?>
</span><br/>
<br/>
<br/>
</div></td></tr></table>
</body>
</html>