RAFC_1990 Posted April 13, 2011 Share Posted April 13, 2011 I keep getting the following error and its frustrating the hell out of me, supposedly to do with whitespace but i see no problems in my code. Error: Warning: Cannot modify header information - headers already sent by (output started at /home/robwdri1/public_html/bsddesigns.co.uk/eventline/carddetails.php:18) in /home/robwdri1/public_html/bsddesigns.co.uk/eventline/carddetails.php on line 120 Code: <?php // Date from form put into variables $cardnumber = $_POST['cardnumber']; $holdersname = $_POST['holdersname']; $expirydate = $_POST['expirydate']; // Card Check Function function LuhnCheck($cardnumber) { $sum = 0; $alt = false; for($i = strlen($cardnumber) - 1; $i >= 0; $i--) { if($alt) { $temp = $cardnumber[$i]; $temp *= 2; $cardnumber[$i] = ($temp > 9) ? $temp = $temp - 9 : $temp; } $sum += $cardnumber[$i]; $alt = !$alt; } return $sum % 10 == 0; } // Check if works if (!empty($cardnumber)) { if (LuhnCheck($cardnumber)) { header("location: confirmation.php"); } else { echo '<font color="red">Error, wrong card details!</font>'; } } ?> Any help please. Quote Link to comment https://forums.phpfreaks.com/topic/233605-headers-not-working/ Share on other sites More sharing options...
Pikachu2000 Posted April 13, 2011 Share Posted April 13, 2011 It isn't just whitespace that causes problems, it's any output at all. output started at /home/robwdri1/public_html/bsddesigns.co.uk/eventline/carddetails.php:18 The output starts on line 18 of carddetails.php. What is on that line? Quote Link to comment https://forums.phpfreaks.com/topic/233605-headers-not-working/#findComment-1201117 Share on other sites More sharing options...
RAFC_1990 Posted April 13, 2011 Author Share Posted April 13, 2011 Seems weird as line 18 is just some random HTML code 13 <body> 14 <div id="Wrapper"> 15 <div id="Header"> 16 <div id="HeaderRight"> 17 <a href="adminlogin.html"><img src="Pics/admin.png" border="0"></a> 18 <a href="eventlogin.html"><img src="Pics/event.png" border="0"></a> 19 </div> 20 <div id="HeaderLeft"> 21 <a href="index.php"><img src="Pics/logo.jpg" border="0"></a> 22 </div> 23 </div> Quote Link to comment https://forums.phpfreaks.com/topic/233605-headers-not-working/#findComment-1201121 Share on other sites More sharing options...
Pikachu2000 Posted April 13, 2011 Share Posted April 13, 2011 It isn't just whitespace that causes problems, it's any output at all. Quote Link to comment https://forums.phpfreaks.com/topic/233605-headers-not-working/#findComment-1201132 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.