Login Script for PostGreSQL and PHP not working =[
- by MrEnder
Ok I'm quite new at logins what not so bare with me here lol but I gota learn so don't discourage me.
I tried this so far
<?php
$error = "";
$conn = pg_connect("host=localhost dbname=brittains_db user=brittains password=XXXX" );
$sql = "SELECT * FROM logins";
$result = pg_query($conn, $sql);
if($_SERVER["REQUEST_METHOD"] == "GET") {
$userName="";
$password="";
}
else if($_SERVER["REQUEST_METHOD"] == "POST") {
$userName=trim($_POST["userNameLogin"]);
$password=trim($_POST["passwordLogin"]);
if(pg_fetch_result($results, $userName, "userName")==true && pg_fetch_result($results, $password, "userName")==true) {
setcookie("userIDforDV", $userName, time()+43200);
}
else {
$error = "Your username and or password is incorrect";
}
}
$userName = $_COOKIE['userIDforDV'];
if(isset($userName) && $userName!="") {
echo "Welcome " . $userName;
}
echo $error;
?>
<form>
<table>
<tr>
<td class="signupTd">
User Name:
</td>
<td>
<input type="text" name="userNameLogin" value="" size="20" />
</td>
</tr>
<tr>
<td class="signupTd">
Password:
</td>
<td>
<input type="password" name="passwordLogin" value="" size="20" />
</td>
</tr>
<tr>
<td class="signupTd" colspan="2">
<input type="submit" name="submit" value="Submit"/>
</td>
</tr>
</table>
</form>
that was the idea I came up with... but its prolly a really bad idea and it doesn't work... how might I go about this properly? I need really detailed descriptions please.
Thanks a tun
Shelby