Ok so I have put together a login parse, a connections code with an index page and configured phpadmin with a database with a user but I can’t seem to login to the site when I’m testing it, I get the invalid login. here is the code I use, I also use dreamweaver.
I JUST WANT TO SAY THAT I FIGURED THIS OUT, SO NO NEED TO POST TO THIS.
index.php
[php]<?php
if (!isset($_SESSION[‘uid’])) {
echo "
Username:
Password <input type=‘password’ name=password’ />
<input type=‘submit’ name=‘submit’ value=Log In’ />
";
} else {
echo “
You are logged in as “.$_SESSION[‘username’].” • Logout”;
}
?>[/php]
Connections.php
[php]<?php
$host = “localhost”;
$username =“root”;
$password = “”;
$db = “forum”;
mysql_connect($host, $username, $password) or die(mysql_error());
mysql_select_db($db);
?>[/php]
login_parse.php
[php]<?php
session_start();
include_once(“connect.php”);
if (isset($_POST[‘username’])) {
$username = $_POST[‘username’];
$password = $_POST[‘password’];
$sql = “SELECT * FROM users WHERE username=’”.$username."’ AND password=’".$password."’ LIMIT 1";
$res = mysql_query($sql) or die(mysqle_error());
if (mysql_num_rows($res) == 1) {
$row = mysql_fetch_assoc($res);
$_SESSION[‘uid’] = $row[‘id’];
$_SESSION[‘username’] = $row[‘username’];
header(“Location: index.php”);
exit();
} else {
echo “Invalid login information. Please return to the previous page.”;
exit();
}
}
?>[/php]