Jump to content

whisperkay

New Members
  • Posts

    3
  • Joined

  • Last visited

whisperkay's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. im a newbie in php. dont know about that@khalilrumi. i will be glad if u can help out
  2. Thanks so much for your swift reply. Can you Tell me how to turn it off?
  3. Hello everyone. I am currently working on my first website, and i am encountering some problems with logging in users after registration. the site url is - www.eastlogicsystems.com. The error i am recieving goes thus - Warning: Cannot modify header information - headers already sent by (output started at /home/eastlogi/public_html/login.php:50) in /home/eastlogi/public_html/login.php on line 143 Warning: Cannot modify header information - headers already sent by (output started at /home/eastlogi/public_html/login.php:50) in /home/eastlogi/public_html/login.php on line 145 the funniest thing is that the code is working fine on my local server, using xamp, but when it is hosted on an internent server, it refuses to work This is my login.php code- <?php // Connects to your Database require_once("connect.php"); //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 userinfo WHERE username = '$username'")or die(mysql_error()); while($info = mysql_fetch_array( $check )) { if ($pass != $info['pass1']) { } else { header("Location: index2.php"); ; } } } //if the login form is submitted if (isset($_POST['submit'])) { // if form has been submitted // makes sure they filled it in if(!$_POST['username'] | !$_POST['pass1']) { die('You did not fill in a required field.'); } // checks it against the database if (!get_magic_quotes_gpc()) { $_POST['email'] = addslashes($_POST['email']); } $check = mysql_query("SELECT * FROM userinfo WHERE username = '".$_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=register.php>Click Here to Register</a>'); } while($info = mysql_fetch_array( $check )) { $_POST['pass1'] = stripslashes($_POST['pass1']); $info['pass1'] = stripslashes($info['pass1']); $_POST['pass1'] = md5($_POST['pass1']); //gives error if the password is wrong if ($_POST['pass1'] != $info['pass1']) { die('Incorrect password, please try again.'); } else { // if login is ok then we add a cookie $_POST['username'] = stripslashes($_POST['username']); $hour = time() + 3600; line 143 - setcookie(ID_my_site, $_POST['username'], $hour); line 145 - setcookie(Key_my_site, $_POST['pass1'], $hour); line 147 - header("Location: index2.php"); //then redirect them to the members area } } } else { // if they are not logged in ?> <form action="<?php echo $_SERVER['PHP_SELF']?>" method="post"> <table width="80%" border="5" cellspacing="5" cellpadding="5"> <tr> <td colspan="2" align="center">Login here</td> </tr> <tr> <td>Username</td> <td> <input name="username" type="text" value="" size="30" maxlength="20" /></td> </tr> <tr> <td>Password</td> <td> <input name="pass1" type="password" value="" size="30" maxlength="20" /></td> </tr> <tr> <td><input name="submit" type="submit" value="login" /></td> <td><a href="register.php">New User? Register</a></td> </tr> </table> </form> <?php } ?> Please i need help.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.