Jump to content

Capturing/Seperating Certain Text Lines From A Form Submission????


smy101

Recommended Posts

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 Doe
Phone Number = 1231231231
Email 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.
Link to comment
Share on other sites

[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.
Link to comment
Share on other sites

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.
Link to comment
Share on other sites

I think you should make your form so that html is not included - no need to be dependable of modifying any message

Here 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]
<?php

if(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]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.