<!--------- THIS IS A DEMO FORM I WANT TO VALIDATE THIS ON SERVER SIDE -->
<form name= "registration" id= "registration" method= "post" action= "">
<table width= "400" border= "0" align="center" cellpadding= "4" cellspacing= "1">
<tr>
<td>Employee Name:</td>
<td><input name= "emp_name" type= "text" id="emp_name" value=""></td>
</tr>
<tr>
<td>Contact No.: </td>
<td><input name= "emp_number" type= "text" id= "emp_number" value=""></td>
</tr>
<tr>
<td> Personal Email: </td>
<td><input name= "emp_email" type= "text" id= "emp_email" value=""></td>
</tr>
<tr>
<td> </td>
<td><input type= "submit" name= "Submit" value= "Submit" ></td>
</tr>
</table>
</form>
<!-- end snippet -->
1 个解决方案
#1
First step is to make sure the form redirects the script to a PHP file or this HTML is inside the PHP file.
第一步是确保表单将脚本重定向到PHP文件,或者此HTML在PHP文件中。
It is not clear what you mean by validation but if you would like to validate for empty fields, you can try this:
目前尚不清楚验证的含义,但如果您想验证空字段,可以试试这个:
if($_POST["emp_name"] == "") { // Used post because that is what you specified in your form tag
echo 'Please fill out the employee name'; // Output stuff here
}
#1
First step is to make sure the form redirects the script to a PHP file or this HTML is inside the PHP file.
第一步是确保表单将脚本重定向到PHP文件,或者此HTML在PHP文件中。
It is not clear what you mean by validation but if you would like to validate for empty fields, you can try this:
目前尚不清楚验证的含义,但如果您想验证空字段,可以试试这个:
if($_POST["emp_name"] == "") { // Used post because that is what you specified in your form tag
echo 'Please fill out the employee name'; // Output stuff here
}