validation - PHP using for or statement giving error -


i trying write validation code when user upload file. condition : file size maximum 500kb , doc , docx file use code not working properly.

i want give visitor permission upload cv in website, server side validation (php).

<html> <head> <title>validation</title> </head>  <body> <?php $msg = ""; $msgsize = ""; if(isset($_post['add'])) {     $filename=$_files['resume']['name']; $ext = substr($filename, strpos($filename,'.'), strlen($filename)-1);     $uname = $_post['uname'];     $uemail = $_post['uemail'];     $uphone = $_post['uphone'];     $resume = $_files['resume']['name'];      if($uname=="" || $uemail=="" || $uphone=="" || $resume=="")     {         $msg = "please fill in required fields!";     }     else if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/",$uemail))      {         $msg = "invalid email format";      }       //echo $ext;     else if($ext != '.doc' or $ext != '.docx')     {                $msg = "type error";     }     else if($_files["resume"]["size"]>500000)     {         $msg = "size error". $_files["resume"]["size"] . "only 500kb resume allowed";     }        else      {         $msg = "good";     } } ?> <div style="background:#ff6600; padding:10px;"><?php echo $msg . $msgsize; ?></div> <form id="form1" enctype="multipart/form-data" name="form1" method="post" action="<?php $_php_self ?>"> <table width="700" border="1">   <tr>     <td width="178">name</td>     <td width="506"><input name="uname" type="text" /></td>   </tr>   <tr>     <td>email</td>     <td><input name="uemail" type="text" /></td>   </tr>   <tr>     <td>phone</td>     <td><input name="uphone" type="text" /></td>   </tr>   <tr>     <td>resume</td>     <td><input name="resume" value="60000000" id="resume" type="file" /></td>   </tr>   <tr>     <td>&nbsp;</td>     <td>               <input type="submit" name="add" id="add" value="add">     </td>   </tr> </table>  </form> </body> </html> 

here need change

else if($ext != '.doc' , $ext != '.docx') {     //use , instead of or     $msg = "type error"; } 

Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -