dbk Posted June 2, 2010 Share Posted June 2, 2010 Hi I have a page with a quite large form, sending the data with 'POST' action. The code that handles the form data is placed in a seperate document called 'commit.php'. Should I place the functions that evaluates the data in a seperate document, maybe 'evaluate.php' and if this is the way - how do I pass the data to 'commit.php'? Or is the best way to put the evaluating functions in the form document? And... yes I'm new to php - actually I find this passing variables between pages a bit hairy! Quote Link to comment Share on other sites More sharing options...
pornophobic Posted June 2, 2010 Share Posted June 2, 2010 I usually use javascript to validate the form client-side with onblur() functions, but you need to have a server side validation too for security, which I usually do on the page the form is submitted to. I check each value with regular expressions, or whatever I need in order to make sure it's the data I want and if they all check out clean I then clean the data for database entry, if it doesn't check out, I take them back to the form and they can try again. Quote Link to comment Share on other sites More sharing options...
teamatomic Posted June 2, 2010 Share Posted June 2, 2010 You can put the evaluation code at the start of the commit.php page. That way if the data is not valid you can just redirect via a header() back to the form page passing an error message with the url as a get. Pretty simple to do and easy to understand. HTH Teamatomic Quote Link to comment Share on other sites More sharing options...
Karlos94 Posted June 2, 2010 Share Posted June 2, 2010 First off, you could create another file if you wished so but then again... There's no point! To simply evaluate and process the data we could just do it nice and simply. <?php if (isset($_POST['only_need_one_field_name'])) { // Your form evaluation and processing } else { // Your HTML form, knock yourself out } Why did I use isset()? Simple, because if I didn't and just went on to the exactly same page without it, you'll get a nice undefined error. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.