Nandini Posted August 19, 2008 Share Posted August 19, 2008 Hi all Can any one tell me how can i validate following form. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> </head> <body> <? extract($_POST); //$lang_error = "<center>The following errors were found:</center>"; $error_colour = "red"; // Must use HTML compatible colour $lang_peeruser = "Enter peer or user\n"; if ((empty($_POST['peer'])) || (empty ($_POST['user']))) { $error = "1"; $info_error .= "".$lang_peeruser . ""; } if ($error == "1") { $info_notice = "<span style=\"color: " . $error_colour . "; font-weight: bold;\">" . $lang_error . "</span><br>"; if (empty ($submit)) { $info_error = ""; $info_notice = $lang_notice; } ?> <form method="post" action=""> <table border="1" align="center"> <tr align="left" valign="top"> <td colspan="2"><?php echo "<font color=red>".$info_notice.$info_error. "</font>" ?></td> </tr> <tr><td colspan="4" align="center">Outgoing</td></tr> <tr><td valign="top">Peer:</td> <td><input type="text" name="peer[]" /><br /> <input type="text" name="peer[]" /><br /> <input type="text" name="peer[]" /> </td></tr> <tr><td colspan="4" align="center">Incoming</td></tr> <tr><td valign="top">User:</td> <td><input type="text" name="user[]" /><br /> <input type="text" name="user[]" /><br /> <input type="text" name="user[]" /> </td></tr> <tr><td colspan="2" align="center"> <input type="submit" name="submit" value="submit" /> </td></tr> </table> </form> <? } else { /////////////database here if(isset($_POST['peer'])) { $language = $_POST['peer']; $n = count($peer); $i = 0; //echo "The languages you selected are \r\n" ."<ol>"; while ($i < $n) { echo $peer[$i]." \r\n"; $i++; } //echo "</ol>"; } echo "<br>"; echo '<a href="register.php">back</a>'; } ?> </body> </html> Link to comment https://forums.phpfreaks.com/topic/120391-php-form-validation/ Share on other sites More sharing options...
revraz Posted August 19, 2008 Share Posted August 19, 2008 Validate in what way? Link to comment https://forums.phpfreaks.com/topic/120391-php-form-validation/#findComment-620304 Share on other sites More sharing options...
Nandini Posted August 19, 2008 Author Share Posted August 19, 2008 See error meesage to of the page. thats not displayed. Link to comment https://forums.phpfreaks.com/topic/120391-php-form-validation/#findComment-620311 Share on other sites More sharing options...
revraz Posted August 19, 2008 Share Posted August 19, 2008 Which error, be more specific. Link to comment https://forums.phpfreaks.com/topic/120391-php-form-validation/#findComment-620314 Share on other sites More sharing options...
Nandini Posted August 19, 2008 Author Share Posted August 19, 2008 if user enter first 3 fields or next 3 fields. dont accept form without fill any field. if click submit without fill any field the error will be occured. Link to comment https://forums.phpfreaks.com/topic/120391-php-form-validation/#findComment-620323 Share on other sites More sharing options...
Nandini Posted August 19, 2008 Author Share Posted August 19, 2008 i am creating text fields with the same name. So, i want to validate these fields. How can i do that. Link to comment https://forums.phpfreaks.com/topic/120391-php-form-validation/#findComment-620347 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.