आज इस आर्टिकल में हम आपको Simple Form Validation With Error Message के बारे में बताएंगे।
Project: Simple Form Validation With Error Message
<?php extract($_REQUEST); function data_trim($data){ $data = trim($data); $data = strip_tags($data); $data = htmlspecialchars($data); return $data; } if (isset($signup)) { $fname = Data_trim($fname); $lname = Data_trim($lname); $email = Data_trim($email); $password = Data_trim($password); $confirm = Data_trim($confirm); // checking the all variable is empty or not if (!empty($fname) || !empty($lname) || !empty($email) || !empty($password) || !empty($confirm)) { if (!empty($fname)) { if (!empty($lname)) { if (!empty($email)) { if (!empty($password) || !empty($confirm)) { if ($password == $confirm) { // now store this data to database and show on same page......... }else{ // if $password & $confirm is empty $error1 = "<font color='red'>Please Check Your Password That You Input</font>"; } }else{ // if $password & $confirm is empty $error1 = "<font color='red'>Please Fill Up Password & Confirm Password</font>"; } }else{ // if $email is empty $error1 = "<font color='red'>Please Fill Up Email</font>"; } }else{ //if $lanme is empty $error1 = "<font color='red'>Please Fill Up Last Name</font>"; } }else{ //if $fname is empty $error1 = "<font color='red'>Please Fill Up First Name</font>"; } }else{ // if all variable is empty $error = "<font color='red'>* Please Fill Up All Details</font>"; } } ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Form Submit</title> </head> <body> <form action-xhr="#" method=""> <table> <tr> <td> <?php echo $retVal = (isset($error)) ? $error : ''; echo $retVal1 = (isset($error1)) ? $error1 : ''; ?> </td> </tr> <tr> <td>First Name:</td> <td><input type="text" name="fname"></td> </tr> <tr> <td>Last Name:</td> <td><input type="text" name="lname"></td> </tr> <tr> <td>Email:</td> <td><input type="email" name="email"></td> </tr> <tr> <td>Password:</td> <td><input type="password" name="password"></td> </tr> <tr> <td>Confirm Password:</td> <td><input type="password" name="confirm"></td> </tr> <tr> <td> <input type="submit" value="Sign Up" name="signup"> </td> </tr> </table> </form> </body> </html>
Final Words
- आज इस आर्टिकल में हमने आपको Simple Form Validation With Error Message के बारे में बताया।
- अगर आपको इससे जुडी कोई अन्य जानकारी चाहए है तो निचे कमेन्ट बॉक्स में कमेन्ट कर के पूछ सकते है।
इसे भी पढ़े –24 साल बाद ISRO के पूर्व वैज्ञानिक नंबी नारायण बरी