|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
Ajax Application Generator Generate database and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
|
|
#1
|
|||
|
|||
|
Hey thanks for a great tutorial!
I'm having problems with the headers though. The error/warning... Warning: Cannot add header information - headers already sent by (output started at c:\phpdev\www\newshopper.php:8) in c:\phpdev\www\newshopper.php on line 21 keeps on resulting when I try using the header('Location: login.php'); and session_start(); The functions work when they are by themselves, but when I place them in my code, I get the warning. The data is still getting to mySQL (no problems there). Here is the code I'm using. ANY help would be greatly appreciated. <?php $db = mysql_connect('localhost', '') or die("Couldn't connect to the database."); mysql_select_db('') or die("Couldn't select the database"); if (isset ($submitButton)){ $_POST['userName'] = addslashes($_POST['userName']); $_POST['password'] = md5($_POST['password']); $sql = "INSERT into user (userName, password, name) values ('$_POST[userName]', '$_POST[password]', '$name')"; if (mysql_query($sql)){ // Start the login session session_start(); // We've already added slashes and MD5'd the password $_SESSION['user'] = $_POST['userName']; $_SESSION['pass'] = $_POST['password']; header("Location: shoppingCart.php"); die(); } else { echo("error ". mysql_error()); } } ?> |
|
#2
|
|||
|
|||
|
To be able to use in the same script session_start() and header(),
you need to add a line : session_cache_limiter('public'); Then you can do session_start(); and header("location : whatever.php"); You can get some more information on the PHP site at: http://www.php.net/manual/en/function.header.php ciao! |
|
#3
|
|||
|
|||
|
Cannot add header information
warning: Cannot add header information - headers already sent in d:\web\hasp.php on line 12."
and i can't see any content. Soultion :- activate the flag output_buffering in the php.ini. Step 1:-Search PHP.ini Step 2: Find output_buffering variable Step 3: Replace off with 4096 For instance: output_buffering = 4096 Thanks n Regards, Shahzad Arain 92-334-5307738 |
![]() |
| Viewing: Dev Articles Community Forums > Programming > Programming Tools > Warning: Cannot add header information - headers already sent by |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|