multiple forms handled by one script php -


i try create order page on php. have created form stores data database. form number based on user , created dynamic.

<?php if(isset($_post['submit_num'])) {     $number=$_post['sky'];      for($i=0;$i<$number;$i++)     {             $item = $_session['item'];              echo $item;             $rec_query = "select * ylika";             $rec_result= mysql_query($rec_query) or die("my eroors");              echo '<form action="user_order_form.php" method="post">';             echo '<html>';             while($row_rec = mysql_fetch_array($rec_result))             {                 echo '<input type="checkbox" name="yliko[]" value='.$row_rec['onoma'].'> '.$row_rec['onoma'].'';                 echo '<br>';             }             echo '<br>';             echo '<input type="submit" name="submit" value="order">';             echo '</form>';      }  } ?> 

so have many forms , 1 script handle them. if submit 1 form applies data database other forms dissapear. second php 'handler'.

<?php if (isset($_post['submit'])) {        $max_id = "select max(id_order) id_of_orders";     $x=mysql_query($max_id) or die("my eroors");     $id= mysql_fetch_array($x);     $xyz = $id['max(id_order)'];      $item = $_session['item'];     $temp = $_post['yliko'];     $temp2 = implode(",", $temp);     $inserts = ("insert orders (order_id,product,ulika) values ('$xyz' , '$item','$temp2')");     $inc_prod=("update proion set counter = counter + 1 proion.onomasia='$item'");     mysql_query($inserts) or die(mysql_error());     mysql_query($inc_prod) or die(mysql_error()); } ?> 

i want submit forms. should try create 1 submit button of forms or there way handle of them separately ?

you can have many submit forms, define 1 big <form> of them, not lose information.

<?php if(isset($_post['submit_num'])) {     $number=$_post['sky'];      echo '<form action="user_order_form.php" method="post">';     for($i=0;$i<$number;$i++)     {             $item = $_session['item'];              echo $item;             $rec_query = "select * ylika";             $rec_result= mysql_query($rec_query) or die("my eroors");              echo '<html>';             while($row_rec = mysql_fetch_array($rec_result))             {                 echo '<input type="checkbox" name="yliko[]" value='.$row_rec['onoma'].'> '.$row_rec['onoma'].'';                 echo '<br>';             }             echo '<br>';             echo '<input type="submit" name="submit" value="order">';      }     echo '</form>';  } ?> 

now can add ~$i~ identifier input names, can distinguish which.


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

.htaccess - Matching full URL in RewriteCond -