Jump to content


Photo

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


  • Please log in to reply
4 replies to this topic

#1 smy101

smy101
  • Members
  • PipPip
  • Member
  • 23 posts

Posted 22 September 2006 - 01:45 AM

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:

<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

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:

Full Name = John Doe
Phone Number = 1231231231
Email Address = john@johndoe.com



Any suggestions on what code to use or if anyone knows of an existing script that I can modify, I would be greatly appreciative.

#2 trq

trq
  • Staff Alumni
  • Advanced Member
  • 31,041 posts

Posted 22 September 2006 - 01:52 AM

How is the html getting into your form in the first place? You could try running it through strip_tags, but there might be a better way. It shouldn't really be there to start with is all.

#3 smy101

smy101
  • Members
  • PipPip
  • Member
  • 23 posts

Posted 22 September 2006 - 05:57 PM

How is the html getting into your form in the first place? You could try running it through strip_tags, but there might be a better way. It shouldn't really be there to start with is all.


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.

#4 smy101

smy101
  • Members
  • PipPip
  • Member
  • 23 posts

Posted 23 September 2006 - 07:44 AM

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.

#5 alpine

alpine
  • Members
  • PipPipPip
  • Advanced Member
  • 756 posts
  • LocationNorway

Posted 23 September 2006 - 08:23 AM

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)
<?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;
}

?>





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users