Pass form values to one php for checking and then to a second php for processing -
the question says all!
i have form needs validated php (for javascript disabled browsers). then, once errors (if any) handled, data needs send php processing. found post same page processing useful because took care of validation on same page form - saves me need pass values original form...etc. [right ignoring issue of button , page refresh retaining values - totally undesirable pov)
however, noticed, in same post, looks form processing should placed on same page form. (i feel) make file ugly , headache maintain. wondering:
what if have completed (error checked) form processing in different php file? possible call file (not include) or send appropriate data (from validation code or other way) external processing file (similar how send post data actual form)?
the reason ask is, have working system form submits data external php file, processes , saves database. bad practice, know, thought of adding validation after done , working.
i guess simple enough copy code in external php php validates form input, somehow, doesn't seem such idea! prefer keep 'saving database' part of processing in separate file.
hence question:
- user fills in form (form.php);
- php on same page checks errors , reloads form entered data in case of errors (form.php).
- in case not encounter errors, sends (?) data (maybe) post values processing file (process.php)
is possible? if please give hint - no code learn how myself!
you can curl
- submit
form.php
- if errors, reload
- if no errors,
curl
curl
example
//open connection $ch = curl_init(); //set url, post data curl_setopt($ch,curlopt_url,$process_url); curl_setopt($ch,curlopt_postfields,$post_data); //execute post $result = curl_exec($ch); //close connection curl_close($ch);
source: post page within php script
Comments
Post a Comment