[RESOLVED] Reading and validating user from SQL database table.
Hello, I've been pulling my hair!!!! :confused: I've done this with a site that's online and works and pretty much copy/pasted that code into this application; and yes I've changed the variable/field names of the involved tables and files. However, it's not working... If you could please look and see if I'm missing something really stupid!
Thank You,
Barrie
Edit: I've echo'ed $techno and it's being passed correctly and is in the 'user' table. I'm running Ubuntu 8.04 / Apache 2.2.8 / PHP 5.2.4
PHP Code:
<?php
session_start();
echo "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">";
echo "<html>";
echo "<head>";
echo "<title>Password Check</title>";
echo "<meta http-equiv=\"content-type\" content=\"text/html; charset=iso-8859-1\" />";
echo "<meta name=\"generator\" content=\"Emacs\"/>";
echo "</head>";
echo "<body>";
/* We have a techno.
*/
$techno = $_POST['techno'];
/* Connect to the database and open the tables
*/
$hostname="xxxxxxxxxx";
$username="xxxxxxxxxx";
$password="xxxxxxxxxx";
$dbname="xxxxxxxxxx";
mysql_connect($hostname, $username, $password) OR DIE ("Unable to connect to database! Please try again later.");
mysql_select_db($dbname);
/* Get the user data
*/
$sql = "SELECT * FROM users WHERE techno = '$techno'";
$result = mysql_query($sql);
while($row = mysql_fetch_row($result)) {
$ndx = $row[0];
$name = $row[1];
$pword = $row[2];
$techno = $row[3];
}
/* Close the database connection
*/
$sql = mysql_close();
/* Check if registered user; i.e. if $name is "" then no user found.
*/
if ($name == "") {
include 'badpass.php';
exit();
}
/* User is valid, save the techno
*/
$_SESSION['techno'] = $techno;
include 'index-go.html';
echo "</body>";
echo "</html>";
exit();
?>