php - Form Values not getting submitted -


i have following php code

    <form action="admin.php" method="post">      <?php     $conn=mysqli_connect("localhost","root","vravi","mrconnect");     if(!$conn)     {         echo "error establishing connection";     }     $sql="select userid,useremail users order userid";     $result=mysqli_query($conn,$sql);       if(mysqli_num_rows($result)>0)     {         while($row=mysqli_fetch_assoc($result))        {            echo $row["userid"];           echo  $row["useremail"]." ".'<input type=\"text\" name=\"name[]\"/>'."</br>";          }     echo '<button type=\"submit\" name=\"submit\"   value=\"submit\">'.submit.'</button></br>'; }     ?>     </form> 

which gives following output in browser.enter image description here

now have 2 questions.

1)when try insert values in 1 of textboxes , click submit button in bottom, values not getting submitted.

below admin.php php file.

    <?php     if(isset($_post['submit']))     {        echo "submitted";     }     else     {         echo "not submitted";      }       ?> 

2)now second question that, want email id submitted through form, normal text, can tell me how that?

there few things change:

  1. you don't need escape double quotes when between single quotes
  2. use name="name['.$row["userid"].']"
  3. change <button... <input type="submit"...

your page this:

<form action="admin.php" method="post">     <?php     $conn=mysqli_connect("localhost","root","vravi","mrconnect");     if(!$conn) { echo "error establishing connection"; }      $sql="select userid,useremail users order userid";     $result=mysqli_query($conn,$sql);      if(mysqli_num_rows($result)>0) {         while($row=mysqli_fetch_assoc($result)) {             echo $row["userid"] . ' ' . $row["useremail"] ." ";             echo '<input type="text" name="name['.$row["userid"].']" />'."<br />";         }         echo '<button type="submit" name="submit" value="submit">submit</button></br>';     }     ?> </form> 

then, when form submitted admin.php, can loop name.

<?php if( $_server['request_method'] == 'post' ) {     foreach( $_post['name'] $data => $value ) {         echo $data . ': ' . $value . '<br />';         // output    2:  12     } } ?> 

in example echo user id , submitted value. ofcourse save database.


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -