www.webdeveloper.com
Results 1 to 4 of 4

Thread: Need Help Please

  1. #1
    Join Date
    Dec 2002
    Posts
    131

    Need Help Please

    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??

  2. #2
    Join Date
    Jun 2003
    Posts
    61
    The header-code have to be the first code in your document. Before any html-output.

  3. #3
    Join Date
    Dec 2002
    Posts
    131

    Exclamation

    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 Code:
    <?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: [url]http://www.cityscout.ca/survey/question3a.php?[/url]";
        
    header($k);
        exit;
    }
    else
    {    
        
    $l "Location: [url]http://www.cityscout.ca/survey/question3b.php?[/url]";
        
    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>

  4. #4
    Join Date
    Jun 2003
    Posts
    61
    Try place this inside <form> and </form>:

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

    and put the php-code inside:

    if($submitted) {

    // here

    }

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles