PHP School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become a PHP Expert!

Join 309,234 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 2,771 people online right now. Registration is fast and FREE... Join Now!




Login script

 

Login script

sOwL

6 Jan, 2008 - 09:21 AM
Post #1

New D.I.C Head
*

Joined: 18 Nov, 2007
Posts: 28



Thanked: 1 times
My Contributions
hello, im not 100% sure that this is the right place to post, but anyway sry if it isnt. My problem is that...erm alrite i got a login script in my website. Works fine for all browsers exept internet explorer. I know some times ie strangely ends sessions before they even start, so my code is fixed on that part. So actually now it works for ie too, but only for the original link, and since i got a www.domain.com masked link, it wont work. Ok to be more clear, the "original link" is the actual link of our server (a free one) but the "www.domain.com" like link is the link we paid, and it masks the url adress and forwards to the original link. . . so using that masked url ruins the login script only on ie for some reason, while browsing the original link will work for all browsers, including ie.
Im posting my php code bellow (i will post the php include files if u need to see them actually):
CODE

<?php
require_once('db.php');
include('functions.php');

    if(isset($_POST['Login']))
    {
        if($_POST['username']!='' && $_POST['password']!='')
        {
            //Use the input username and password and check against 'users' table
            $query = mysql_query('SELECT ID, Username, Active FROM users WHERE Username = "'.mysql_real_escape_string($_POST['username']).'" AND Password = "'.mysql_real_escape_string(md5($_POST['password'])).'"');
            
            if(mysql_num_rows($query) == 1)
            {
                $row = mysql_fetch_assoc($query);
                if($row['Active'] == 1)
                {
                    session_start();
                    $_SESSION['user_id'] = $row['ID'];
                    $_SESSION['logged_in'] = TRUE;
                                          session_write_close();
                    header("Location: members.php");
                            
                }
                else {
                    $error = 'Your membership was not activated. Please open the email that we sent and click on the activation link';
                }
            }
            else {        
                $error = 'Login failed !';        
    }
        }
        else {
            $error = 'Please use both your username and password to access your account';
        }
    }
?>

and this for the login form:
CODE

<?php if(isset($error)){ echo $error;}?>
         <form action="<?=$_SERVER['PHP_SELF']?>" method="post">
    <input type="text" id="username" name="username" size="17" value="" />
    <input type="password" id="password" name="password" size="17" value="" />
    <input type="submit" name="Login" value="Login" />
?>

any help rly appreciated

User is offlineProfile CardPM
+Quote Post

 
Reply to this topicStart new topic
Replies(1 - 1)

spullen

RE: Login Script

6 Jan, 2008 - 10:33 AM
Post #2

D.I.C Regular
Group Icon

Joined: 22 Mar, 2007
Posts: 356



Thanked: 9 times
Dream Kudos: 100
My Contributions
I think this is your problem session_write_close()
Look at what it says on php.net http://us2.php.net/manual/en/function.sess...write-close.php
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/26/09 08:56AM

Live PHP Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

PHP Tutorials

Reference Sheets

PHP Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month