www.webdeveloper.com
Recent Articles
  • Finding Slow Running Queries in ASE 15
  • A More Advanced Pie Chart for Analysis Services Data
  • Adobe AIR Programming Unleashed: Working with Windows
  • Performance Testing SQL Server 2008's Change Data Capture Functionality
  • The ABC's of PHP: Introduction to PHP
  • How to Migrate from BasicFiles to SecureFiles Storage
  • Why the Twitter Haters Are Wrong
  • User Personalization with PHP: Beginning the Application
  • Whats in an Oracle Schema?
  • Lighting Enhancement in Photoshop
  •  

    Go Back   WebDeveloper.com > Server-Side Development > PHP

    PHP Discussion and technical support for using and deploying PHP based websites.

    Reply
     
    Thread Tools Search this Thread Rate Thread Display Modes
      #1  
    Old 05-05-2008, 03:42 AM
    salim6655 salim6655 is offline
    Registered User
     
    Join Date: May 2008
    Posts: 1
    Login Cookies not working in IE but works fine in firefox & also works in some Systm

    Hi
    i am using the below code to capture login details as cookie, however the the code is not functioning in IE but works fine in Fire fox , in some systems only, in many systems it works fine ,PLz help

    <?php
    // Connects to your Database
    mysql_connect("localhost", "", "") or die(mysql_error());
    mysql_select_db("links") or die(mysql_error());

    //Checks if there is a login cookie
    if(isset($_COOKIE['ID_my_site']))

    //if there is, it logs you in and directes you to the members page
    {
    $username = $_COOKIE['ID_my_site'];
    $pass = $_COOKIE['Key_my_site'];
    $check = mysql_query("SELECT * FROM all_members WHERE email_id = '$username'")or die(mysql_error());
    while($info = mysql_fetch_array( $check ))
    {
    if ($pass != $info['pass_wd'])
    {
    }
    else
    {
    ?>
    <table valign="top" align="left">
    <tr>
    <td align="left"><span class="style2">&nbsp; &nbsp; &nbsp; <span class="style6">&nbsp;</span>
    <?php
    echo " Hi ",$username," !";
    echo " <a href=logout.php>Logout</a>";
    //header("Location: members.php");
    ?>
    </span></td>
    </tr>
    </table>
    <?php
    }
    }
    }

    //if the login form is submitted
    if (isset($_POST['submit1'])) { // if form has been submitted

    // makes sure they filled it in
    if(!$_POST['username'] | !$_POST['pass']) {

    die('You did not fill in a required field please <a href=index.php> Click Here </a>to try again');
    }
    // checks it against the database

    if (!get_magic_quotes_gpc()) {
    $_POST['email'] = addslashes($_POST['email']);
    }
    $check = mysql_query("SELECT * FROM all_members WHERE email_id = '".$_POST['username']."'")or die(mysql_error());

    //Gives error if user dosen't exist
    $check2 = mysql_num_rows($check);
    if ($check2 == 0) {
    die('That user does not exist in our database <a href=AddDetails.php>Click Here to Register</a> or please <a href=index.php>Go Back </a>to try again');
    }
    while($info = mysql_fetch_array( $check ))
    {
    $_POST['pass'] = stripslashes($_POST['pass']);
    $info['pass_wd'] = stripslashes($info['pass_wd']);
    //$_POST['pass'] = md5($_POST['pass']);

    //gives error if the password is wrong
    if ($_POST['pass'] != $info['pass_wd']) {
    die('Incorrect password ! please <a href=index.php>Click Here </a>to try again');
    }
    else
    {

    // if login is ok then we add a cookie
    $_POST['username'] = stripslashes($_POST['username']);
    $hour = time() + 3600;
    setcookie(ID_my_site, $_POST['username'], $hour);
    setcookie(Key_my_site, $_POST['pass'], $hour);
    //then redirect them to the members area
    header("Location: CandDetails.php");
    }
    }
    }
    else
    {

    // if they are not logged in
    ?> </span></td>
    <?php if (!(isset($_COOKIE['ID_my_site'])))
    {
    ?>
    <tr>
    <td class="btnback" style="padding-left:15px"><strong>USER LOGIN </strong></td>
    </tr>
    <tr>
    <td>&nbsp;</td>
    </tr>
    <tr>
    <td><table width="73%" border="0" align="center" cellpadding="0">
    <tr>
    <td> User Name: </td>
    </tr>
    <tr>
    <td><input ype="text" name="username" class="searchinput" size="25" /></td>
    </tr>
    <tr>
    <td>Password:</td>
    </tr>
    <tr>
    <td><input type="password" name="pass" class="searchinput" size="25" /></td>
    </tr>
    <tr>
    <td><input type="submit" name="submit1" class="submit" value="LOGIN" /></td>
    </tr>
    <tr>
    <td>&nbsp;</td>
    </tr>
    <tr>
    <td><a href="#" class="bodylink">Forgot Password?</a> l <a href="#" class="bodylink">Signup!</a> </td>
    </tr>
    </table></td>
    </tr>

    <?php
    }
    }
    ?>
    Reply With Quote
      #2  
    Old 05-06-2008, 05:41 AM
    youthanesia youthanesia is offline
    Registered User
     
    Join Date: May 2008
    Posts: 1
    Try this

    <?
    session_start();

    $server = "localhost";
    $username = "";
    $password = "";
    $db_name = "";


    $db = mysql_connect($server,$username,$password) or DIE("Connection to database failed, perhaps the service is down !!");
    mysql_select_db($db_name) or DIE("Database name not available !!");

    $login = mysql_query("select * from users where (username = '" . $_POST['username'] . "') and (password = '" . md5($_POST['password']) . "')",$db);
    $rowcount = mysql_num_rows($login);
    if ($rowcount == 1) {
    $_SESSION['username'] = $_POST['username'];
    setcookie("failed", "", time() + 3600);
    $usrinfo = date;
    header("Location: members.php");
    }
    else
    {
    setcookie("failed", "Login failed, please try again...",
    time() + 3600);
    header("Location: login.php");

    }
    ?>
    Reply With Quote
    Reply

    Bookmarks


    Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
     
    Thread Tools Search this Thread
    Search this Thread:

    Advanced Search
    Display Modes Rate This Thread
    Rate This Thread:

    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 Off
    HTML code is Off
    Forum Jump


    All times are GMT -5. The time now is 11:57 PM.



    Acceptable Use Policy

    internet.comMediabistrojusttechjobs.comGraphics.com

    WebMediaBrands Corporate Info


    Advertise | Newsletters | Feedback | Submit News

    Legal Notices | Licensing | Permissions | Privacy Policy

    Powered by vBulletin® Version 3.7.3
    Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.