954,153 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

get data from a dynamic form

hallo,

i ve created a dynamic form. A user can select The number of fields he d like to fill in (test creation)

echo '<form method="post" action="createxml.php">';
for ($i =1; $i <=$number; $i+=1){ // THE $NUMBER CONTAINS //VALUE -ok-

echo '<fieldset width ="20%">';
echo   '<legend class = "login">WRITE A QUESTION</legend>';
echo '   <blockquote align="center">';
echo 'QUESTION '.$i.' (DESCRIPTION):';
echo '<textarea name="q".$i rows="3" cols="50"></textarea>';
echo 'ANSWEAR 1:<textarea name="q".$i."a1" rows="1" cols="50"></textarea>';
echo 'ANSWEAR 2:<textarea name="q".$i."a2" rows="1" cols="50"></textarea>';
echo 'ANSWEAR 3:<textarea name="q".$i."a3" rows="1" cols="50"></textarea>';
echo 'ANSWEAR 4:<textarea name="q".$i.a4" rows="1" cols="50"></textarea>';

echo '<input type="submit">';
echo '</form>';


Now in createxml.php i want to get the values in order to write them inside xml file. i have tried a lot but i can not do it. the last code i used which caused unfinishing loop with empty values was this

echo "$number";//ok
for ($i =1; $i <=$number; $i+=1){
       $q.$i = $_POST['q'.$i];
       echo "$q.$i";// empty
       echo "";
             
       $a.$i= $_POST["q".$i."a1"];
       $a.$i= $_POST["q".$i."a2"];
       $a.$i= $_POST["q".$i."a3"];
       $a.$i= $_POST["q".$i."a4"];
       
       echo "answear=".$_POST["q".$i."a4"];// empty
        echo "";

    }


can u help me??????

dourvas
Newbie Poster
20 posts since Dec 2008
Reputation Points: 10
Solved Threads: 0
 

hey I see you posted this on www.devnetworkforums.net .. what the hell... check your answer there

it2051229
Junior Poster in Training
82 posts since May 2007
Reputation Points: 7
Solved Threads: 1
 

Try to fix this line

echo 'ANSWEAR 4:<textarea name="q".$i.a4" rows="1" cols="50"></textarea>';
echo 'ANSWEAR 4:<textarea name="q".$i.<strong>"</strong>a4" rows="1" cols="50"></textarea>';


missing quote

Yayo_SK
Newbie Poster
11 posts since Jan 2009
Reputation Points: 10
Solved Threads: 1
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You