echocpt Posted September 6, 2008 Share Posted September 6, 2008 Hi, basicly i have a login script that i have already used for one of my sites and it worked fine but when i moved it over to a new site it is'nt working. Could someone please point me in the correct direction? Thanks alot. This is the login php code for "login2.php": <?php // login2.php session_start(); include("connection.php"); if(isset($_POST['submit'])) { if(empty($_POST['username']) || empty($_POST['password'])) { header("Location: login.php"); exit; } $username = $_POST['username']; $password = $_POST['password']; $password = md5($password); $query = "SELECT username,password FROM `user` WHERE username='$username'"; $result = mysql_query($query); if(!$result) { echo "The query failed " . mysql_error(); } else { $row = mysql_fetch_object($result); if($row->password != $password) { echo "The password is fucked" . mysql_error(); } $_SESSION['username'] = $username; $_SESSION['sid'] = session_id(); $_SESSION['ip'] = $_SERVER['REMOTE_ADDR']; header("Location: welcome.php"); exit; } } ?> This is the html form code: <form id="form6" name="form6" method="post" action="login2.php"> <table width="638" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="190">Username:</td> <td width="449"><label> <input name="username" type="text" class="area" id="username" value="" /> </label></td> </tr> <tr> <td> </td> <td> </td> </tr> <tr> <td>Password:</td> <td><label> <input name="password" type="password" class="area" id="password" value="" /> </label></td> </tr> <tr> <td> </td> <td> </td> </tr> <tr> <td> </td> <td><label> <input type="submit" name="submit" id="submit" value="Login" /></form> Thanks for any help. Quote Link to comment https://forums.phpfreaks.com/topic/123061-solved-login-script-help/ Share on other sites More sharing options...
echocpt Posted September 6, 2008 Author Share Posted September 6, 2008 Sorry for the double post but it seems u can't edit posts for some crazy reason. Completly forgot to post the error message displayed which was: Warning: Cannot modify header information - headers already sent by (output started at /home/zerosite/public_html/ccf/redo/pages/login2.php:39) in /home/zerosite/public_html/ccf/redo/pages/login2.php on line 49 Thanks Quote Link to comment https://forums.phpfreaks.com/topic/123061-solved-login-script-help/#findComment-635502 Share on other sites More sharing options...
steveclondon Posted September 6, 2008 Share Posted September 6, 2008 would help to know what was on line 39, and whats in the includes like login.php. Check you are not echoing information out to the browser before you are setting cookies. Quote Link to comment https://forums.phpfreaks.com/topic/123061-solved-login-script-help/#findComment-635516 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.