Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
our session is not working
Old 03-29-2010, 11:18 AM our session is not working
Skilled Talker

Posts: 59
Name: elenabush
Trades: 0
Hi All,
I'm beginner in php/mysql, I have created a login page where session is not working, please solve my problems, your suggestion would be appreciated.

Quote:
<?php
ob_start();
session_start();
$con=mysql_connect("localhost","root","");
$db=mysql_select_db("ram1");

if(!empty($_SESSION['user_name']))
{
header("Location: index.php"); exit;
}

if(isset($_POST['submit']))
{
$user=$_POST['username'];
$pass=$_POST['password'];
$password=$pass;
$sql=mysql_query("select * from admin where user_name='".$user."' and user_pass='".$pass."'");
if(mysql_num_rows($sql)>0)
{
$data=mysql_fetch_array($sql);
$_SESSION['user_id']=$data['admin_id'];
header("Location: index.php"); exit;
}
else{
$msg="login with username and password";
}
}
?>

<body>
<form action="" method="post">
<table border="1" cellpadding="0" cellspacing="0" align="center">
<tr>
<th>Username:</th><th><input type="text" name="username"/></th>
</tr>
<tr>
<th>Password:</th><th><input type="text" name="password"/></th>
</tr>
<tr>
<th><input type="submit" name="submit"/></th></tr>
</table>
</form></body>
__________________

Please login or register to view this content. Registration is FREE
#
Please login or register to view this content. Registration is FREE
#
Please login or register to view this content. Registration is FREE
elena1234 is offline
Reply With Quote
View Public Profile Visit elena1234's homepage!
 
 
Register now for full access!
Old 03-29-2010, 11:31 AM Re: our session is not working
lynxus's Avatar
Awesomeo-Maximo

Posts: 1,618
Location: UK
Trades: 1
Try putting session_start(); above obj_start(); ?

What errors do you get in /var/log/httpd/error ( or where ever you have your httpd error log )
__________________

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE


lynxus is offline
Reply With Quote
View Public Profile Visit lynxus's homepage!
 
Old 03-30-2010, 01:15 AM Re: our session is not working
Skilled Talker

Posts: 59
Name: elenabush
Trades: 0
I have try as you told us, our code is not showing any error, but session is not create for users.

Quote:
Originally Posted by lynxus View Post
Try putting session_start(); above obj_start(); ?

What errors do you get in /var/log/httpd/error ( or where ever you have your httpd error log )
__________________

Please login or register to view this content. Registration is FREE
#
Please login or register to view this content. Registration is FREE
#
Please login or register to view this content. Registration is FREE
elena1234 is offline
Reply With Quote
View Public Profile Visit elena1234's homepage!
 
Old 03-30-2010, 04:14 AM Re: our session is not working
Experienced Talker

Posts: 41
Name: Adam B
Trades: 0
So what exactly does happen?

Try changing:

PHP Code:
$msg="login with username and password"
To:

PHP Code:
echo "login with username and password"
If that message is displayed then I imagine the problem lies with your query. Failing that ensure you have error reporting enabled, add this to the top of your code:

PHP Code:
error_reporting(E_ALL);
ini_set('display_errors'1); 
adam89 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to our session is not working
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.32327 seconds with 12 queries