bsamson Posted December 4, 2006 Share Posted December 4, 2006 I have a form w/ 7 mandatory fields:First Name, Last Name, City, Zip Code, Username, Password, and lastly AliasWhat is the most efficient way to check for values of all those fields and redirect back if any are found to be empty ... The following is the way I have been doing this:[code]<?phpif (empty($fname)) { header( ... } elseif { (empty($fname)) { header( ... // ETC ... ETC ...?>[/code]Any suggestions?? ... Thanks! Link to comment https://forums.phpfreaks.com/topic/29357-best-way-to-validate-7-fields-wo-js/ Share on other sites More sharing options...
btherl Posted December 4, 2006 Share Posted December 4, 2006 I would make a variable (string or array), so you can collect ALL missing fields in one go. Just use a seperate "if" for each.Then after the checks, check if there are any messages, and if so, redirect and pass along the message to be displayed. You can do it with eg [code=php:0]header("Location: http://site.com/script.php?msg=" . urlencode($msg));[/code] Link to comment https://forums.phpfreaks.com/topic/29357-best-way-to-validate-7-fields-wo-js/#findComment-134638 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.