Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Register Tags Active Topics RSS Search Mark Forums Read

Sponsored Links



Problem with PHP Forms

Software Development


Reply
 
Thread Tools Search this Thread
  #1  
Old 31-03-2009
Member
 
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
}
>

Reply With Quote
  #2  
Old 31-03-2009
XSI XSI is offline
Member
 
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.
Reply With Quote
  #3  
Old 31-03-2009
Member
 
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'.
Reply With Quote
  #4  
Old 31-03-2009
Member
 
Join Date: Nov 2008
Posts: 1,054
Re: Problem with PHP Forms

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

  TechArena Community > Software > Software Development
Tags: ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Problem with PHP Forms"
Thread Thread Starter Forum Replies Last Post
Where to get NIFT forms Atakapa Education Career and Job Discussions 5 11-11-2010 02:16 PM
Adobe acrobat reader 9 problem saving forms and copying photos Biloxi Windows Software 6 08-07-2010 07:46 AM
Implementing forms with ASP Dilbert Software Development 4 10-02-2010 03:18 AM
Problem running forms in network drive L-cynthiya Operating Systems 3 28-11-2009 05:09 PM
Forms In C#.net sagngh88 Software Development 1 19-05-2009 09:09 AM


All times are GMT +5.5. The time now is 01:40 AM.