bradgrafelman;10943043 wrote:Eh... it wasn't an awful mistake; you still got the point across that modifying HTTP headers (e.g. to add a cookie to them) can't be done once you've started outputting data.
Seem to have run into another problem:
<?php
/* Prevent duplicate submissions */
if(isset($_COOKIE['FormSubmitted'])){
show_error('You may only submit this form once per session!');
}
if (isset($_POST['Submit'])) {
$selected_radio = $_POST['handset'];
$selected_radio1 = $_POST['role'];
$list_type = $_POST['utype'];
if($selected_radio1=='Und' && $list_type=='Please'){
print "Please text";
exit();
}
if($selected_radio=='Yes' && empty($_POST['mtype'])){
print "Text field is empty. Please enter your Handset model number";
exit();
}
}
$selected_radio = $_POST['handset'];
$selected_radio1 = $_POST['role'];
$list_type = $_POST['utype'];
/* Get all the inputs */
$mobilised = $_POST['mobilised'];
$mchoice = $_POST['mchoice'];
$useMobile = $_POST['handset'];
$handsetType = $_POST['mtype'];
$buyData = $_POST['dp'];
$haveData = $_POST['dpm'];
$upgradePhone = $_POST['upm'];
$prevTried = $_POST['prevDepart'];
$browseUni = $_POST['mobOften'];
$useNet = $_POST['netMobile'];
$noneReason = $_POST['mwhy'];
$lectureTime = $_POST['grp1'];
$relevantContact = $_POST['grp2'];
$reportAbsences = $_POST['grp3'];
$reportLate = $_POST['grp4'];
$roomChange = $_POST['grp5'];
$newsfeed = $_POST['grp6'];
$job = $_POST['grp7'];
$examDate = $_POST['grp8'];
$otherFunc = $_POST['mfunc'];
$importance = $_POST['speed'];
$persistance = $_POST['compatible'];
$further = $_POST['mFin'];
/* Connect to the mySQL database */
$conn = mysql_connect("localhost","a","test");
// repeat for all questions.
mysql_select_db("test") or die(mysql_error);
mysql_query("INSERT INTO csd VALUES ('$selected_radio1','$list_type','$mobilised','$mchoice','$useMobile','$handsetType','$buyData','$haveData','$upgradePhone','$prevTried','$browseUni','$useNet','$noneReason','$lectureTime','$relevantContact','$reportAbsences','$reportLate','$roomChange','$newsfeed','$job','$examDate','$otherFunc','$importance','$persistance','$further')");
mysql_close($conn);
/* Set a cookie to prevent duplicate submissions */
setcookie('FormSubmitted', '1');
/* Redirect visitor to the thank you page */
header('Location: thanks.htm');
Print "Your information has been successfully added to the database";
exit();
function show_error($myError)
{
?>
<html>
<body>
<b>Please correct the following error:</b><br />
<?php echo $myError; ?>
</body>
</html>
<?php
exit();
}
?>
This does not seem to be working. Seems to stop working as soon as I added the
f (isset($_POST['Submit'])
method
thanks