Results 1 to 4 of 4

Thread: Problem with PHP Forms

  1. #1
    Join Date
    Nov 2008
    Posts
    1,054

    Problem with PHP Forms

    I have a concern for PHP. I'm trying to code a test system, or survey, but it does not work. It returns me directly to the result, knowing that $result is $ q2 ... I do not understand this.. Could you enlighten me on this? Here is the code:

    PHP Code:
    <? php 
    if (isset ($ _POST 'q1'])){ 
    q1 = $ _POST 'q1']; 
    }
    if (isset ($ 
    _POST 'q2'])){ 
    q2 = $ _POST 'q2']; 
    }
    if (isset ($ 
    _POST 'q3'])){ 
    q3 = $ _POST 'q3']; 
    }
    if (isset ($ 
    _POST 'q4'])){ 
    q4 = $ _POST 'q4']; 
    }
    if (isset ($ 
    _POST 'q5'])){ 
    q5 = $ _POST 'q5']; 
    }
    if ($ 
    q1 == "" & & $ q2 == "" & & $ q3 == "" & & $ q4 == "" & & $ q5 == "") {
    echo 

    <form action="tests.php" method="post"> 
    <input type="radio" name="q1" value="1"> Yes <br/> 
    <input type="radio" name="q1" value="3"> No <br/> 
    <input type="radio" name="q1" value="5"> No opinion <br/> 
    <input type="submit" value="Valid"> 
    </form> '


    else if ($ 
    q1! = "") {
    echo 

    <form action="tests.php" method="post"> 
    <input type="radio" name="q2" value="1"> Yes <br/> 
    <input type="radio" name="q2" value="3"> No <br/> 
    <input type="radio" name="q2" value="5"> No opinion <br/> 
    <input type="submit" value="Valid"> 
    </form> '

    }
    else if ($ 
    q1! = "" & & $ q2! = "") {
    echo 

    <form action="tests.php" method="post"> 
    <input type="radio" name="q3" value="1"> Yes <br/> 
    <input type="radio" name="q3" value="3"> No <br/> 
    <input type="radio" name="q3" value="5"> No opinion <br/> 
    <input type="submit" value="Valid"> 
    </form> '

    }
    else if ($ 
    q1! = "" & & $ q2! = "" & & $ q3! = "") {
    echo 

    <form action="tests.php" method="post"> 
    <input type="radio" name="q4" value="1"> Yes <br/> 
    <input type="radio" name="q4" value="3"> No <br/> 
    <input type="radio" name="q4" value="5"> No opinion <br/> 
    <input type="submit" value="Valid"> 
    </form> '


    else if ($ 
    q1! = "" & & $ q2! = "" & & $ q3! = "" & & $ q4! = "") {
    echo 

    <form action="tests.php" method="post"> 
    <input type="radio" name="q5" value="1"> Yes <br/> 
    <input type="radio" name="q5" value="3"> No <br/> 
    <input type="radio" name="q5" value="5"> No opinion <br/> 
    <input type="submit" value="Valid"> 
    </form> '

    }
    else {
    $result $q1 $q2 $q3 $q4 $q5
    echo 
    $result
    }
    >

  2. #2
    Join Date
    May 2008
    Posts
    271

    Re: Problem with PHP Forms

    1. a more explicit please
    2. You Do not initialized your variables. A small error_reporting = E_ALL | E_STRICT in php.ini you do the most good.

  3. #3
    Join Date
    May 2008
    Posts
    3,971

    Re: Problem with PHP Forms

    On one page to another you do not retransmit the responses of old forms. $q1 and $q2, therefore can not exist simultaneously.

    Code:
    $ q1! = "" & & $ q2! = ""
    and other kinds of tests are always equal to 'false'.

  4. #4
    Join Date
    Nov 2008
    Posts
    1,054

    Re: Problem with PHP Forms

    Thank you I'm not good on this one. Wow it works!

Similar Threads

  1. Where to get NIFT forms
    By Atakapa in forum Education Career and Job Discussions
    Replies: 5
    Last Post: 11-11-2010, 01:16 PM
  2. Replies: 6
    Last Post: 08-07-2010, 06:46 AM
  3. Implementing forms with ASP
    By Dilbert in forum Software Development
    Replies: 4
    Last Post: 10-02-2010, 02:18 AM
  4. Problem running forms in network drive
    By L-cynthiya in forum Operating Systems
    Replies: 3
    Last Post: 28-11-2009, 04:09 PM
  5. Forms In C#.net
    By sagngh88 in forum Software Development
    Replies: 1
    Last Post: 19-05-2009, 08:09 AM

Posting Permissions

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