[SOLVED] ID when logging in
Posted: Fri Feb 19, 2010 7:35 am
I've made a log in code and I've now altered it to refresh you back to the index. So that you're shown as logged in.
Problem I'm having is with displaying the users ID. If I use $_SESSION['id'] it throws up a fuss saying its not recognised 'Undefined index: id'
If I use $_POST['txtid'], I dont get an error until after logging in and refreshing back to the index, saying the same thing 'Undefined index: txtid'. They're only notices but is there a way so that I don't get a notice
even notices mean untidy coding.
Thanks,
Aravona
Problem I'm having is with displaying the users ID. If I use $_SESSION['id'] it throws up a fuss saying its not recognised 'Undefined index: id'
If I use $_POST['txtid'], I dont get an error until after logging in and refreshing back to the index, saying the same thing 'Undefined index: txtid'. They're only notices but is there a way so that I don't get a notice
Code: Select all
<?php
session_start();
include("validate.php");
include("connection.php");
if ($_SESSION['id'] != "") {
echo "you are now logged in as ".$_SESSION['id'];
echo "<form action='logout.php' method='post'><input name='Logout' type='Submit' value='Logout' /></form>";
}
else{
// show login box
?>
<html>
<head>
<title>Home Page</title>
<head>
<body>
<form name="frmLogin" action="login.php" method="post">
Username :
<input name="txtid" type="text" />
<br/><br>
Password :
<input name="txtpwd" type="password" />
<input type="submit" value="Login" name="btnlogin" />
</form>
</body>
</html>
<?php
}
?>Aravona