I am having some trouble making my php login page, you know, actually login. I have created a database using sql with some login info and I am trying to display the information grabbed once the user logs in.
For example once the user logs in I want it to say: "Welcome back [firstname][lastname] Our records show that your email address is: [email] and you last accessed our system: [date accessed]"
and if the user was not found in the database i want it to say "Login failed please try again"
So how to I get the code to actually login(it supposed to be self referring too...)
I have tried so many things, I have tried:
if ($_SERVER["REQUEST_METHOD"] == "POST") {
if(isset($_POST['submit'])){
$id = $_POST['id'];
$password = $_POST['password'];
$res = pg_query($cser,"select* from users where id='$id'and password='$password'");
$result=pg_fetch_array($res);
if($result)
{
echo "You are login Successfully ";
header("location:functions.php");
}
else
{
echo "failed ";
}
}
}
Ive been watching youtube videos as well but none of them are helpful at all.
<center>
<h2>Please log in</h2>
<p>Enter your login ID and password to connect to this system<br/>
</p>
<form name="Input" method="post" action="<?php echo $_SERVER["PHP_SELF"];?>">
<table border="1" bgcolor="black" cellpadding="10" >
<tr>
<td><strong>Username:</strong></td>
<td><input type="text" name="login" value="" size="20" placeholder="Username"/></td>
</tr>
<tr>
<td><strong>Password:</strong></td>
<td><input type="password" name="pass" value="" size="20" placeholder="**********" /></td>
</tr>
</table>
<table border="0" cellspacing="15" >
<tr>
<td><input type="submit" value = "Login" /></td>
</tr>
</table>
</form>
<p>
Please wait after pressing <strong>Log in</strong>
while we retrieve your records from our database.<br/>
<em>(This may take a few moments)</em>
</p>
<hr/>
</center>
</body>
</html>
This is my actual form