PHP Log in w/ Session - Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more
Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more
Go Back   Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more > Webmaster Tech > Programming > PHP Development

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 04-30-2011, 04:08 AM   #1 (permalink)
Junior Member
 
Join Date: Apr 2011
Posts: 12
Exclamation PHP Log in w/ Session

i have user_account table
-uid
-username
-password

under thesis (database) in wamp

my problem is.. i got the code then i can connect to the database but my code in matching the username and password the error is always invalid...

PLEASE HELP ME !
yokorobi12 is offline   Reply With Quote
Sponsored Links
Old 04-30-2011, 04:12 AM   #2 (permalink)
Junior Member
 
Join Date: Apr 2011
Posts: 12
Default Re: PHP Log in w/ Session

this is the php file... (ignore the spaces)

http : // www . 4shared . com / file/ gk-_vSY8/ LOG_ IN_ with_ Session . html ?
yokorobi12 is offline   Reply With Quote
Old 04-30-2011, 04:15 AM   #3 (permalink)
Junior Member
 
Join Date: Apr 2011
Posts: 12
Default Re: PHP Log in w/ Session

config.php


<?php

$con = mysql_connect("localhost","root","");

if(!$con){
die('could not connect:'.mysql_error());
}

mysql_select_db("thesis",$con);

?>

.................................................. .................................................. ...........

LoginAdmin.php

<?php
$login_form = <<<EOD
<form name="login" id="login" method="GET" action="CheckLogin.php">
<p><label for="username">Please Enter Username: </label><input type="text" size="30" name="username" id="username" /></p>
<p><label for="password">Please Enter Password: </label><input type="password" size="30" name="password" id="password" /></p>
<p><input type="submit" name="submit" id="submit" value="Submit"/> <input type="Reset" name="reset" id="reset" value="reset"/></p>
</form>
EOD;
$msg = $_GET['msg']; //GET the message
if($msg!='') echo '<p>'.$msg.'</p>'; //If message is set echo it
echo $login_form;
?>

.................................................. .................................................. ...........


CheckLogin.php

// And i feel this is my problem !!!

<?php

include "config.php";

$username = strtolower($_POST["username"]);
$password = $_POST["password"];

if ($username !="" && $password !=""){

//select username and password from database
$sql="SELECT * FROM user_account WHERE username='$username' and password='$password'";
$query = mysql_query($sql);
$row = mysql_fetch_array($query);
$ctr = mysql_num_rows($query);

if($ctr > 0)
{

ob_start();
$_SESSION['username'];
$_SESSION['password'];
session_register("username");
session_register("password");
header("location:AdminCategory.php");

}
else
{
echo '<script language="javascript">alert(\'Account does not exists.\');window.location =\'LoginAdmin.php\';</script>';
}
ob_end_flush();

}
else{
echo '<script language="javascript">alert(\'invalid username or password.\');window.location =\'LoginAdmin.php\';</script>';

}

?>


please reply ! thanks in advance !!!
yokorobi12 is offline   Reply With Quote
Old 04-30-2011, 05:50 AM   #4 (permalink)
Regular User
 
Join Date: Apr 2011
Posts: 115
Default Re: PHP Log in w/ Session

Chk this link.
Post ur query there
chunnilal is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Sponsors

» Links

» Affiliates
Web Hosting
Online Backup Reviews
Marketing Find
Merchant Select
SiteMap Builder
Host Compare

» Links

» Sports Network
Paintball Forum
Football Forum
Hockey Forum
Golf Forum
Boxing Forum
Lacrosse Forum
Baseball Forum
SnowBoarding Forum
Soccer Forum
MMA Forum


All times are GMT -4. The time now is 04:43 PM.


Powered by vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.2
Webmaster Forums
Web Hosting | Chicago Web Hosting | Web Hosting