From: "Tom Rogers" <[EMAIL PROTECTED]> > JWH> Does anyone know of a script that'll receive the results of a form, > JWH> parse the original form and substitute the user supplied data in for the > JWH> form elements and then send an HTML email of the "form"? > > Here is a class I use with my template system but it is easy to modify > it.
Thanks for the tip. This requires you know what the elements of the form are, though. Like I said, if you know what's in the form, this whole process is pretty trivial. I want to take an unknown form, receive the data, then redisplay the form with the form elements gone and the values submitted replacing them. My personal needs incorporate sending this in an email, but that's the easy part. <input>, <select> and <textarea> elements will be easy, I think. You can just replace the whole element with a post variable matching it's name. $page = preg_replace('/<input type="text" name="([^"]+)"[^>]+>/ie','$_POST[\'\1\']',$page); The checkboxes and radio buttons would be a little harder. <input type="checkbox" name="foo" value="1"> <input type="checkbox" name="foo" value="2"> I'm thinking this will take two passes. First match the names of each checkbox or radio button. Once I have the $name, I can say $_POST[$name][$_POST[$name]] = $_POST[$name]; resulting in $_POST['foo']['1'] = 1 if the first checkbox was selected. Then, do a replace $page = preg_replace('/<input type="checkbox" name="([^"]+)" value="([^"]+)"[^>]+>/ie','$_POST[\'\1\'][\'\2\']',$page); Accounting for arrays would require something else and I'd obviously have to account for extra attributes within the form elements. Anybody thing of something that's more efficient? I'm still just brainstorming here. :) ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php