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
$_post[input2]wrong, should work. that's becauseinput2recognized constant, not string (what should be). change$_post['input2'](see php manual).- you haven't closed of brackets. pay attention legibility of code avoid this!
$_post[input2]doesn't check if processed inputinput2. should$key.
Comments
Post a Comment