<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<title></title>
</head>
<body>
<?php
if ($_POST['password'] != $_POST['confirmpassword'])
{
$password = md5($_POST['password']);
$confirmPass = md5($_POST['confirmpassword']);
echo "<script type='text/javascript'>alert('Error. Passwords do not match.');</script>";
header("Refresh:0; Registration.html");
}
else
{
$password = md5($_POST['password']);
$confirmPass = md5($_POST['confirmpassword']);
echo 'Name: '.$_POST['firstname'].' '.$_POST['lastname']. '<br>';
if($_POST['agerange'] == 1)
{
echo "Under 18<br>";
}
elseif($_POST['agerange'] == 2)
{
echo "Age 18-24<br>";
}
elseif($_POST['agerange'] == 3)
{
echo "Age 25-34<br>";
}
elseif($_POST['agerange'] == 4)
{
echo "Age 35-44<br>";
}
elseif($_POST['agerange'] == 5)
{
echo "Age 45-54<br>";
}
elseif($_POST['agerange'] == 6)
{
echo "Age 55-64<br>";
}
else
{
echo "Age 65 or older<br>";
}
if ($_POST['sex'] == 'male')
{
echo "Gender: Male<br>";
}
else
{
echo "Gender: Female<br>";
}
echo 'Phone Number: '.$_POST['daytimephone']. '<br>';
echo 'Email: '.$_POST['email']. '<br>';
echo 'Username: '.$_POST['username']. '<br>';
if(isset($_POST['specialoffers']))
{
echo "You would like to recieve special offers from us via email.";
}
else
{
echo "You would NOT like to recieve special offers from us via email.";
}
}
?>
</body>
</html>
So this PHP script calls my Registration.html form. When the password field does not match the confirm password field, an alert is posted saying they do not match then the page should be refreshed. For some reason I can't figure out why it's kicking out this error: Cannot modify header information - headers already sent by (output started at Documents\My Web Sites\Week 2\Exercise 4\Register.php:8) in Documents\My Web Sites\Week 2\Exercise 4\Register.php on line 14 Does anyone have a suggestion on how to fix this? All I want is to refresh the registration form if the password fields do not match.