Jump to content

Login Page


aenigma

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.
Link to comment
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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.