Jump to content

login confirm problems


chris_rulez001

Recommended Posts

hi im making a forum hosting service and i am having trouble with logging in. its not actually logging me in, its just showing a blank screen. what i would like to have the code do is to select the current forum name and then select the users and then login. but its not doing it and i would like to know how i would be able to do this?

 

heres my code:

 

<?php
session_start();
$username = $_POST['username'];
$password = $_POST['password'];

$host="fdb1.awardspace.com"; // Host name
$username="*"; // Mysql username
$password="****************"; // Mysql password
$db_name="********"; // Database name
$tbl_name1="*****"; // Table name

// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");

$sql_user_check = "SELECT * FROM **users WHERE username='$username'";
$result_name_check = mysql_query($sql_user_check) OR DIE(mysql_error());
$usersfound = mysql_num_rows($result_name_check);

if ($usersfound < 1) {
    $error = "Username $username not found.";

}

else {
    $sql_pass_get = "SELECT * FROM ***users WHERE username='$username'";
    $user_info = mysql_fetch_array(mysql_query($sql_pass_get));
    $pass = $user_info['password'];
    if ($pass != $password) {
        $error = "Invalid password.  Try again.";
} else {
        $_SESSION['userid'] = $user_info['id'];
        $_SESSION['forumname'] = $user_info['forumname'];
        $_SESSION['username'] = $user_info['username'];
        $_SESSION['password'] = $user_info['password'];
        $_SESSION['email'] = $user_info['email'];
        $_SESSION['question'] = $user_info['question'];
        $_SESSION['answer'] = $user_info['answer'];
        $_SESSION['age'] = $user_info['age'];
        $_SESSION['gender'] = $user_info['gender'];
        $_SESSION['ip'] = $user_info['ip'];
    }
if (!isset($_SESSION['username'])) {
    if ($error) {
        echo $error;
        include("login.php");
    } 
else {
        include("index.php");
    }
} else {
    echo "<html>
<head>
<title>Logged In Successfully</title>
<SCRIPT LANGUAGE='JavaScript'>
<!-- Begin
redirTime = '5000';
redirURL = 'http://*********.awardspace.co.uk/support/index.php';
function redirTimer() { self.setTimeout('self.location.href = redirURL;',redirTime); }
// End -->
</script>
</head>

<body onLoad='redirTimer()'>
You are logged in successfully, please wait to be redirected to the homepage.
</body>
</html>";
} 
}
?>

 

heres my database structure:

 

 id   	tinyint(255)  	   	   	No   	   	auto_increment   	    
 forumname  	varchar(255) 	latin1_swedish_ci 	  	No  	  	  	
 display  	varchar(255) 	latin1_swedish_ci 	  	No  	  	  	
 username  	varchar(255) 	latin1_swedish_ci 	  	No  	  	  	
 password  	varchar(255) 	latin1_swedish_ci 	  	No  	  	  	
 email  	varchar(255) 	latin1_swedish_ci 	  	No  	  	  	
 age  	varchar(255) 	latin1_swedish_ci 	  	No  	  	  	
 gender  	varchar(255) 	latin1_swedish_ci 	  	No  	  	  	
 question  	varchar(255) 	latin1_swedish_ci 	  	No  	  	  	
 answer  	varchar(255) 	latin1_swedish_ci 	  	No  	  	  	
 ip  	varchar(255) 	latin1_swedish_ci 	  	No  	  	  	

 

is my request misleading? if yes i can try and explain it better for you.

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.