Jump to content

trying to strip tags and trim fields before a user submits an email


Recommended Posts

can someone show me the correct syntax on how to fix my code to do this? I know what i have is not right.

 

$date = trim(strip_tags($_POST['date']));
$lastname = trim(strip_tags($_POST['lastname']));
$middle = trim(strip_tags($_POST['middle']));
$firstname = trim(strip_tags($_POST['firstname']));
$address = trim(strip_tags($_POST['date']));
$address_continue = trim(strip_tags($_POST['address']));
$city = trim(strip_tags($_POST['address_continue']));
$state = trim(strip_tags($_POST['state']));
$zip = trim(strip_tags($_POST['zip']));
$phone = trim(strip_tags($_POST['phone']));
$alternate = trim(strip_tags($_POST['alternate']));
$email = trim(strip_tags($_POST['email']));
$position = trim(strip_tags($_POST['position']));
$referred = trim(strip_tags($_POST['referred'])); 
$coverletter = trim(strip_tags($_POST['coverletter']));
$resume = trim(strip_tags($_POST['resume']));

$body = "
\n\n Date: "$date"
\n\n Last Name: "$lastname"
\n\n Middle: "$middle"
\n\n First Name: "$firstname"
\n\n Address: "$address"
\n\n          "$address_continue"
\n\n City: "$city"
\n\n State: "$state"
\n\n Zip: "$zip"
\n\n Phone Number: "$phone"'
\n\n Alternate Number: "$alternate"
\n\n E-Mail Address: "$email"
\n\n Position: "$position"
\n\n Referred by: "$referred" 
\n\n Cover Letter or Addtional Information: "$coverletter"
\n\n Resume: "$resume"";

mail ($to, $subject, $body);

What type of tags are you trying to strip, just HTML Tags?

 

Is there a particular reason you are trying to strip HTML Tags for an email?

 

How do you know what you have is not right?

 

Also remove the quotes around the strings in the body portion, it is not needed with double quotes and will throw syntax errors.

well I am not sure if I need to strip the tags but  I am suspicious of someone messing with the form because I am getting blank emails sent to the assigned account. soI thought I would try something differeent.  I know the form works because information is being sent but so is blank forms too. You have any ideas why I migth be getting these blank forms?  I am using javascript to check for required fields.

What are the required fields? For the required fields I would do a php check also, just to make sure.

 

<?php
$email = isset($_POST['email'])?trim($_POST['email']):null;
$error = null;
if (is_null($email) || empty($email)) {
     $error .= "Please supply a valid email.<br />";
} 
?>

 

Do that for each required field. If $error is not null than do not send the form but revert them back explaining the error message/required fields were not populated.

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.