Jump to content

Archived

This topic is now archived and is closed to further replies.

aenigma

Login Page

Recommended Posts

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--] <?
$db_host = "localhost";
$db_username = "aenigma_josh";
$db_password = "strg388";
$db_name = "aenigma_joshs";

if ( isset( $_POST["Submit"] ) ) {
if ( !$link = mysql_connect($db_host, $db_username, $db_password)) {
die( "Unable to connect to MySQL Server." );
}

if ( !$dbselect = mysql_select_db($db_name, $link)) {
die( "Unable to select MySQL database." );
}

if ( isset( $_POST["username"] ) ) {
$username = $_POST["username"];
}
else {
die( "You did not enter a username." );
}

if ( isset( $_POST["password"] ) ) {
$password = $_POST["password"];
}
else {
die( "You did not enter a password." );
}

$query = "SELECT * FROM users WHERE username = '". mysql_real_escape_string($username) ."' AND password = '". md5($password) ."' LIMIT 1";

if ( !$result = mysql_query($query, $link)) {
die( "Unable to run SQL query." );
}


if ( mysql_num_rows( $result ) != 1 ) {
die( "Invalid username or password" );
}
else {
$userinfo = mysql_fetch_array( $result );
}

mysql_free_result( $result );
$day = date('d', time());
$month = date('m', time());
$year = date('Y', time());
$hour = date('H', time());
$min = date('i', time());
$sec = date('s', time());
$uid1 = md5(uniqid(rand(), true));
$uid2 = md5(uniqid(rand(), true));
$uid3 = md5(uniqid(rand(), true));
$sessionid = "'". $uid2 . $yeah . $sec ."'-'". day . $hour . $uid3 ."'-'". $min . $uid1 . $month ."'";
$sname = session_name("$sessionid");
session_start($sname);
$_session['username'] = $userinfo[username];
$_session['displayname'] = $userinfo[displayname];
$_session['email'] = $userinfo[email];
$next = "index.php?page=news";
Header('Location: $next');
}

?>[/quote]

Says "Unable to Run SQL Query" ANy ideas? lol.

Share this post


Link to post
Share on other sites
Try changing this...

[code]

if ( !$result = mysql_query($query, $link)) {
die( "Unable to run SQL query." );
}
[/code]

To this...
[code]
if (!($result = mysql_query($query, $link)))
{
die( "Unable to run SQL query." );
}
[/code]

If that does not work then also try this...
[code]
if (!($result = mysql_query($query)))
{
die( "Unable to run SQL query." );
}
[/code]

Take a look there and then let us know.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.