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
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.