html5 - Use a php loop to process text and file inputs from html form -


i stuck on trying make work, have html form has file , text inputs, after submission want process these inputs through loop in php script. loop skips file input , processes text inputs. new @ php, , cant seem understand wrong , how fix it. here form code , php code process it.

<form action='loop.php' enctype="multipart/form-data" data-ajax="false" method="post">      <input type ="text" name ="input1"/>      <input type ="file" name ="input2"/>      <input type ="text" name ="input3"/>      <input type ="text" name ="input4"/>      <input type='submit' data-corners="false" value ='submit'/> </form> 

loop.php

<?php     foreach ($_post $key => $value){          if($_post[input2]) //check if file input          {//some manipulation on file}          else          //process other text inputs} ?>  

thanks help

  1. $_post[input2] wrong, should work. that's because input2 recognized constant, not string (what should be). change $_post['input2'] (see php manual).
  2. you haven't closed of brackets. pay attention legibility of code avoid this!
  3. $_post[input2] doesn't check if processed input input2. should $key.

Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

html - Unable to style the color of bullets in a list -

c# - must be a non-abstract type with a public parameterless constructor in redis -