Search the Community
Showing results for tags 'login functions'.
-
I'm working through Larry's PhP 6 and MySqL 5 book which so far has been excellent but I've hit a snag I can't get past. On Chapter 11 'Cookies & Sessions' I've completed page 327 - 339 and when I test my pages on my MacOSX running Xampp I get errors shown below. Warning: Cannot modify header information - headers already sent by (output started at /Applications/XAMPP/xamppfiles/htdocs/php/mysqli_connect.php:4) in /Applications/XAMPP/xamppfiles/htdocs/php/ch11/login.php on line 23 Warning: Cannot modify header information - headers already sent by (output started at /Applications/XAMPP/xamppfiles/htdocs/php/mysqli_connect.php:4) in /Applications/XAMPP/xamppfiles/htdocs/php/ch11/login.php on line 24 Warning: Cannot modify header information - headers already sent by (output started at /Applications/XAMPP/xamppfiles/htdocs/php/mysqli_connect.php:4) in /Applications/XAMPP/xamppfiles/htdocs/php/ch11/login.php on line 28 I've checked the code and removed all the spaces after the final ?> php tag but I still get the error. Could you help please, many thanks in advance. Below is the code on 'Login.php' Line 23/24 is the setcookie function Line 28 is the header function <?php # Script 9.3 - login.php // This page processes the login form submission. // Upon successful login, the user is redirected. // Two included files are necessary. // Send NOTHING to the Web browser prior to the setcookie() lines! // Check if the form has been submitted: if (isset($_POST['submitted'])) { // For processing the login: require_once ('includes/login_functions.inc.php'); // Need the database connection: require_once ('../mysqli_connect.php'); // Check the login: list ($check, $data) = check_login($dbc, $_POST['email'], $_POST['pass']); if ($check) { // OK! // Set the cookies: setcookie ('user_id', $data['user_id']); setcookie ('first_name', $data['first_name']); // Redirect: $url = absolute_url ('loggedin.php'); header("Location:$url"); exit(); // Quit the script. } else { // Unsuccessful! // Assign $data to $errors for error reporting // in the login_page.inc.php file. $errors = $data; } mysqli_close($dbc); // Close the database connection. } // End of the main submit conditional. // Create the page: include ('includes/login_page.inc.php'); ?>