smy101 Posted September 22, 2006 Share Posted September 22, 2006 Ok, so I set up a basic HTML/PHP form for a user-submittable feedback form. When the submission is emailed to me, it is in this form:[code]<font color=blue>Full Name</font> = John Doe<font color=blue>Phone Number = 1231231231 <font size=1 color=#FF0000>*</font><font color=blue>Email Address = john@johndoe.com[/code]What I would like to happen is to either filter it through another script or set up a seperate script that I can manually copy/paste into and the script will strip away the unneeded material. I use to know how to do this but it escapes me now. Basically I need a script that once submitted with the above code, will spit out something like:[b]Full Name = John DoePhone Number = 1231231231Email Address = john@johndoe.com[/b]Any suggestions on what code to use or if anyone knows of an existing script that I can modify, I would be greatly appreciative. Quote Link to comment Share on other sites More sharing options...
trq Posted September 22, 2006 Share Posted September 22, 2006 How is the html getting into your form in the first place? You could try running it through [url=http://php.net/strip_tags]strip_tags[/url], but there might be a better way. It shouldn't really be there to start with is all. Quote Link to comment Share on other sites More sharing options...
smy101 Posted September 22, 2006 Author Share Posted September 22, 2006 [quote author=thorpe link=topic=109005.msg439108#msg439108 date=1158889925]How is the html getting into your form in the first place? You could try running it through [url=http://php.net/strip_tags]strip_tags[/url], but there might be a better way. It shouldn't really be there to start with is all.[/quote]I'm not entirely sure. I used a PHP Form Generator that I found somewhere on the web. I'll have to look around all the files to see if I can find out why. Quote Link to comment Share on other sites More sharing options...
smy101 Posted September 23, 2006 Author Share Posted September 23, 2006 I can't figure out how to stop it from sending me the HTML tags.Is there some way that I can set it up to strip starting at the "=" sign and isolating text forward until it hits the "<" and backwards until it hits the ">" brackets of the html tags?Thanks again for your help. Quote Link to comment Share on other sites More sharing options...
alpine Posted September 23, 2006 Share Posted September 23, 2006 I think you should make your form so that html is not included - no need to be dependable of modifying any messageHere is a very basic form that you can start with, should be set up easy and hopefully you can learn from it.File is named "contact.php" (or change name in form action)[code]<?phpif(isset($_POST['submit'])){foreach( $_POST as $key => $value ){ ${$key} = htmlspecialchars($value);}if(!empty($name) && !empty($phone) && !empty($email) && !empty($message)){// alter this to suited$to = "your@email.net";$from = "your@email.net";$from_name = "Your Name";$subject = "Email message";// alter this to include every {$}formfield-name, \r\n is linebreaks in email message$msg = "Posted info:\r\n\r\nName: $name\r\nPhone: $phone\r\nEmail: $email\r\nMessage: $message";// no need to toutch headers$headers = "From: $from_name <$from>\r\n";$headers .= "Reply-To: $from_name <$from>\r\n";$headers .= "Return-Path: $from_name <$from>\r\n";$headers .= "X-Mailer: PHP v".phpversion()."\r\n";$send = mail($to, $subject, $msg, $headers);if($send){ echo "Info was sendt"; $done = 1; // hides form}else{ echo "An error may occurred, please try again";}}else{ echo "Please fill in all fields...";}}if(!$done){echo <<<__HTML<form method="post" action="contact.php">Name: <input type="text" name="name" value="$name" size="25" /><br />Phone: <input type="text" name="phone" value="$phone" size="25" /><br />Email: <input type="text" name="email" value="$email" size="25" /><br />Message:<br /><textarea name="message">$message</textarea><br /><input type="submit" value="Send Info" name="submit" /></form>__HTML;}?>[/code] 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.