Form system by base date how to pick up data in $_POST

Asked

Viewed 97 times

0

how to format

put returns between paragraphs

for line break add 2 spaces at the end

italic or bold

indent the code in 4 spaces

leaks of severe accents parecido _portanto_

highlighting placing > at the beginning of the line

to make links

http://foo.com foo foo

Basic HTML is also allowed

help in the format

2 answers

0

I tested your code with update follows how it would look to work:

   <code>
       <?php   
        require_once('Connections/localhost.php'); 
        if (isset($_POST['acao'])) {
            if (isset($_POST['nome'])) {
                reset($_POST['nome']); 
                while (list($key, $val) = each($_POST['nome'])) {  
                      //echo "$key => $val\n";  
                      mysql_select_db($database_localhost, $localhost);
                      $gostou = mysql_query("update tab_statusoperacao SET DESCRICAO = '$val' WHERE CODSTATUSOPERACAO = '$key' ");

                }
            }
        }
        ?>

        <form method="post" enctype="multipart/form-data" style="margin-bottom:5px"> 
            <input type="hidden" name="acao" id="acao" value="1" /> 
            <?php
            mysql_select_db($database_localhost, $localhost);
            $get_form = mysql_query("SELECT * FROM tab_statusoperacao") or die(mysql_error());
            while ($form = mysql_fetch_assoc($get_form)) { ?>
              <p>
                <label class="label-form" for="<?php echo $form['CODSTATUSOPERACAO']; ?>"><?php echo $form['DESCRICAO']; ?></label>
                <br />      
                <input type="text" name="nome[<?php echo $form['CODSTATUSOPERACAO']; ?>]" id="<?php echo $form['CODSTATUSOPERACAO']; ?>" class="input-form" value="<?php echo $form['DESCRICAO'];?>" />
                <br />  
              </p>
            <?php } ?>
            <input type="submit" name="enviar2" class="input-form" value="Enviar" />
        </form> 
    </code>
  • in input name I passed id to recover in post and update

  • Hello! I tested here and got no results, nothing entered in the base date, I tested with INSERT.

  • And would it be possible to recover in the POST only like this? name="<? php echo $form['CODSTATUSOPERACAO']; ? >" It would be too massive!

  • In relation to not working with Insert may be something you forgot in your code that posted the value to the correct post, compared to recover in the POST only with name="<? php echo $form['CODSTATUSOPERACAO']; ? >" it is possible yes, as long as the post is validated, I have already made a system that mounted fields through the base, but my post only had fields that I would use in the base example Hidden acao...would have to validate and disregard it there would not put while (list($key, $val) = each($_POST['name'])) and yes while (list ($key, $val) = each ($_POST)) {

  • And not to use the name in the name the if related to it would not exist if (isset($_POST['name'])) { neither reset with that post

  • Solange, then the if (isset($_POST['name'])) { would look like this if (isset($_POST)) ? or would not have this Post just from the while (list ($key, $val) = each ($_POST)){

  • Solange, I did as you said, and I reread the form code and it worked fine, thank you. Do you know how to check if the q fields are mandatory at the base date work? Example the photo field is required but the email field is not, ai check if filled only the photo field q is required only q besides the fields are by the base date this is also required. It is hard to explain rsrs more know how I can do?

  • Well if I understand correctly put if for example in the input: <?php if($form['required'] == 'yes'){ ? >required="required"<? php } ? > ...now if it is the validation when it is time to perform the inclusion in the base, there at the time to give the Insert, could pass through a Hidden, but if you did without the variable with the name in the name there would already increase the work in relation to ignore that Hidden, perhaps a select before Insert would be more feasible

  • I used the required and look for sure is easier kk, is it possible to put a custom message in the required? An Alert script? The ULTTIMA COISA kk, it is possible I put a form to send an image a type file more q so accepted Image, in case I would insert the image in a folder of the server and insert the link in the base date along with the forms, tell me q yes and q the code is simple, and thank you again for your help.

  • Yes it is possible custom message in required using css or a jquery has several templates on the net gives a searched with several different css and such, regarding the file yes field it is possible you can validate file format by javascript or same php, i prefer by php, also have enough material on the internet about this.

Show 5 more comments

0

if (isset($_POST['nome']))
{
   foreach($_POST['nome'] as $key => $value)
   {
       echo 'Nome: '.$value;
       echo '<hr/>';
   }
}
  • Hello! How can I insert this in the base date, I say in INSERT I put, the $value?

  • I put here in the Insert and did not insert anything in the base date, as if this code was blocking the Insert, I click on the button to "send" the updated page but nothing happens. I have tried changing the if (isset($_POST['name'])) with another name in the form but does not enter anything in the base date :(

  • @devmacedo can you explain the code you put in the answer? click [Edit] to add this to the answer

  • @Carlosgomes Please do not change the question according to the answers, otherwise the existing answers (in this case) lose their meaning. Let’s wait for the devmacedo to come back and supplement the answer. If this does not resolve your question, you can post another question based on the new situation. Thank you.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.