puritystandsout Posted July 14, 2006 Share Posted July 14, 2006 Please could you help? Here is my script:[code]<?php// start the sessionsession_start();$errorMessage = '';if ( (isset($_POST['username'])) && (isset($_POST['password'])) ) { include '../db/config.php'; include '../db/opendb.php'; $username = $_POST['username']; $password = $_POST['password']; $password_hashed = md5($password); // check if the user id and password combination exist in database $sql = "SELECT * FROM accounts WHERE username = '$username' AND password = '$password_hashed' "; $result = mysql_query($sql) or die('Query failed. ' . mysql_error()); if (mysql_num_rows($result) == 1) { // the user id and password match, // set the session while ($member_details_array = mysql_fetch_assoc($result)) { $member_id = $member_details_array['member_id']; $_SESSION[$member_id] = true; } // after login we move to the main page header("Location: main.php"); exit; } else { $errorMessage = 'Sorry, wrong username and password combination'; } include '../db/closedb.php';}?>[/code]----------------------------------------------It seems to do all the db stuff ok, logs the user in but I get this error:Cannot modify header information - headers already sent by ...Many Thanks in advance for your help.Regards and Jesus Christ's blessings,Chris Cundill Quote Link to comment https://forums.phpfreaks.com/topic/14568-login-script-problem/ Share on other sites More sharing options...
puritystandsout Posted July 14, 2006 Author Share Posted July 14, 2006 Fixed it sorry to bother you.For the benefit of the community it was blank lines after my closing ?> and the beginning of my html!Thats all! Quote Link to comment https://forums.phpfreaks.com/topic/14568-login-script-problem/#findComment-57805 Share on other sites More sharing options...
redarrow Posted July 14, 2006 Share Posted July 14, 2006 sometimes it's better to get more sessions set ok like.$_SESSION['name'];ectectthen in the future you can use them ok.good luck. Quote Link to comment https://forums.phpfreaks.com/topic/14568-login-script-problem/#findComment-57868 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.