TheJoey Posted September 3, 2009 Share Posted September 3, 2009 I have a form which on submit saves information to .txt. i now want to add form validation but dont know if can sumbit more then one process. For example <form action="process.php" method="POST" name="inputform" id="inputform"> Field 1 <br /> <input type="text" size="100" name="field1" /> <br /> Field 2 <br /> <input type="text" size="100" name="field2" /> <br /> <input type="submit" name="submit" value="Submit" /> </form> is there another way to make it process validation then if successfull process save file. ? Link to comment https://forums.phpfreaks.com/topic/172984-solved-ran-into-a-problem/ Share on other sites More sharing options...
Bricktop Posted September 3, 2009 Share Posted September 3, 2009 Hi TheJoey, Just add the form validation to the top of the process.php file. Something like: $field1 = $_POST['field1']; $field2 = $_POST['field2']; if(!$field1) { $errors .= "\nYou must enter something for field1"; echo $errors; } if(!$field2) { $errors .= "\nYou must enter something for field2"; echo $errors; } if(!$errors) { put your process/save text code here } The above is very basic validation and will check for empty values being posted in both fields. If errors are found an error message is displayed, if no errors are found the code continues processing. Get the above working first and then you can build on the validation as required. Hope this helps! Link to comment https://forums.phpfreaks.com/topic/172984-solved-ran-into-a-problem/#findComment-911699 Share on other sites More sharing options...
TheJoey Posted September 3, 2009 Author Share Posted September 3, 2009 thank you ill give it a try. Link to comment https://forums.phpfreaks.com/topic/172984-solved-ran-into-a-problem/#findComment-911771 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.