Hi, Tuesday, April 20, 2004, 11:29:41 PM, you wrote: JWH> 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 JWH> 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.
JWH> Thanks for the tip. This requires you know what the elements of the form JWH> are, though. Like I said, if you know what's in the form, this whole process JWH> is pretty trivial. JWH> I want to take an unknown form, receive the data, then redisplay the form JWH> with the form elements gone and the values submitted replacing them. My JWH> personal needs incorporate sending this in an email, but that's the easy JWH> part. JWH> <input>, <select> and <textarea> elements will be easy, I think. You can JWH> just replace the whole element with a post variable matching it's name. JWH> $page = preg_replace('/<input type="text" name="([^"]+)"[^>>]+>/ie','$_POST[\'\1\']',$page); JWH> The checkboxes and radio buttons would be a little harder. JWH> <input type="checkbox" name="foo" value="1"> JWH> <input type="checkbox" name="foo" value="2"> JWH> I'm thinking this will take two passes. First match the names of each JWH> checkbox or radio button. Once I have the $name, I can say JWH> $_POST[$name][$_POST[$name]] = $_POST[$name]; JWH> resulting in JWH> $_POST['foo']['1'] = 1 JWH> if the first checkbox was selected. JWH> Then, do a replace JWH> $page = preg_replace('/<input type="checkbox" name="([^"]+)" value="([^"]+)"[^>>]+>/ie','$_POST[\'\1\'][\'\2\']',$page); JWH> Accounting for arrays would require something else and I'd obviously have to JWH> account for extra attributes within the form elements. Anybody thing of JWH> something that's more efficient? I'm still just brainstorming here. :) JWH> ---John Holmes... It does not need to know the form elements, only the reserved words it uses and you take those out and pass them directly to the class if needed. It takes the variable name from the POST array and uses it with the value. No need to know what the input fields are called or even what type - checkboxes and radio groups work fine. -- regards, Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php