Click to See Complete Forum and Search --> : Need Help Please


Redhead
07-14-2003, 07:24 AM
Hey how is everyone

this is what i'm doing i have a page with a radio button that asks a yes or no answer

if they answer yes they go to a page

if they answer no they go to another page

here is my if statement

[PHP]if ($radio == "yes")
{
$k = "Location: http://www.domainnamehere.com/question3a.php?";
header($k);
}
else
{ $l = "Location: http://www.domainnamehere.com/question3b.php?";
header($l);
}PHP]

But i keep getting this error

Warning: Cannot modify header information - headers already sent by (output started at /home/city2003/public_html/survey/question2.php:8) in /home/city2003/public_html/survey/question2.php on line 24

Can anyone help me please??

Kr|Z
07-14-2003, 08:20 AM
The header-code have to be the first code in your document. Before any html-output.

Redhead
07-14-2003, 08:32 AM
I guess i should explan my self better i have 4 pages i'm working with

question1.php
question2.php
question3a.php
question3b.php


question1.php is just a form and when the hit submit button it takes them to question2.php page where the information is inserted into a db and the user is asked another question. the question is yes or no and if they answer yes they go to question3a.php and if they answer no they go to question3b.php

bellow is the code i have for question2.php


I'm not getting any errors but i'm not even seeing the page anymore, i have placed the php code above the html code and it brings me directly to question3b.php, if the informatin is placed inside the html tage i get the above header error please help me i'm going crazy here



<?php
$db = mysql_connect ("localhost", "username", "password");
mysql_select_db("database", $db);

$sql = "INSERT INTO table (checkbox, checkbox2, checkbox3, checkbox4, checkbox5, checkbox6, checkbox7, checkbox8, Other) VALUES ('$checkbox', '$checkbox2', '$checkbox3', '$checkbox4', '$checkbox5', '$checkbox6', '$checkbox7', '$checkbox8', '$Other')"
;

$results = mysql_query($sql, $db);

if ($radio == "Yes")
{
$k = "Location: http://www.cityscout.ca/survey/question3a.php?";
header($k);
exit;
}
else
{
$l = "Location: http://www.cityscout.ca/survey/question3b.php?";
header($l);
exit;
}
?>
<html>
<head>
<title>ATM Survey Question 2</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="survey.css" rel="stylesheet" type="text/css">
</head>

<body>
<form name="form1" method="post" action="<? echo $PHP_SELF; ?>">
<table width="100%" border="0" cellspacing="2" cellpadding="2">
<tr>
<td width="28%"><h1>Question 2</h1></td>
<td width="72%"><h1>&nbsp;</h1></td>
</tr>
<tr>
<td>Do you have an ATM on Site?</td>
<td>&nbsp;</td>
</tr>
<tr>
<td><input type="radio" name="radio" value="Yes">
Yes</td>
<td>&nbsp;</td>
</tr>
<tr>
<td><input type="radio" name="radio" value="No">
No </td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><input type="submit" name="Submit" value="Next"></td>
</tr>
</table>
</form>
</body>
</html>

Kr|Z
07-14-2003, 09:17 AM
Try place this inside <form> and </form>:

<input type="hidden" name="submitted" value="1">

and put the php-code inside:

if($submitted) {

// here

}