|
|||||||
| PHP Discussion and technical support for using and deploying PHP based websites. |
![]() |
|
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#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"> <span class="style6"> </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> </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> </td> </tr> <tr> <td><a href="#" class="bodylink">Forgot Password?</a> l <a href="#" class="bodylink">Signup!</a> </td> </tr> </table></td> </tr> <?php } } ?> |
|
#2
|
|||
|
|||
|
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"); } ?> |
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|