Jump to content

Headers not working


RAFC_1990

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/233605-headers-not-working/
Share on other sites

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?

Link to comment
https://forums.phpfreaks.com/topic/233605-headers-not-working/#findComment-1201117
Share on other sites

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>

Link to comment
https://forums.phpfreaks.com/topic/233605-headers-not-working/#findComment-1201121
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.