Best web hosting - BRINGING FORMS TO LIFE // go ahead only

BRINGING FORMS TO LIFE // go ahead only if not suspect and all required fields OK if (!$suspect && empty($missing)) { Designing a regular expression to recognize a valid-looking email address is notoriously difficult, and many that you find in books or on the Internet reject valid email addresses. Instead of striving for perfection, $checkEmail simply checks for an @ mark surrounded by at least one character on either side. More important, it rejects any attempt to append spurious email headers. If the contents of $email don t match the regex, email is added to the $missing array. I decided not to create a special variable to indicate a suspected attack because the user may have innocently mistyped the email address. Moreover, it keeps the logic of the code simple. If the $missing array contains any elements, the message isn t sent, which is the whole point: you ve stopped the attack. 2. You now need to add the additional headers to the section of the script that sends the email. Place them immediately above the call to the mail() function like this: // limit line length to 70 characters $message = wordwrap($message, 70); // create additional headers $additionalHeaders = ‘From: Japan Journey‘; if (!empty($email)) { $additionalHeaders .= “rnReply-To: $email”; } // send it $mailSent = mail($to, $subject, $message, $additionalHeaders); If you don t want email to be a required field, there s no point in using a nonexistent value in the Reply-To header, so I have wrapped it in a conditional statement. Since you have no way of telling whether the Reply-To header will be created, it makes sense to put the carriage return and new line characters at the beginning of the second header. It doesn t matter whether you put them at the end of one header or the start of the next one, as long as a carriage return and new line separates each header. For instance, if you wanted to add a Cc header, you could do it like this: $additionalHeaders = “From: Japan Journeyrn”; $additionalHeaders .= ‘Cc: admin@example.com’; if (!empty($email)) { $additionalHeaders .= “rnReply-To: $email”; } Or like this: $additionalHeaders = ‘From: Japan Journey‘; $additionalHeaders .= “rnCc: admin@example.com”; if (!empty($email)) { $additionalHeaders .= “rnReply-To: $email”; } Finally, don t forget to add $additionalHeaders as the fourth argument to mail(). 141
Note: If you are looking for cheap and reliable webhost to host and run your mysql application check mysql web server services.

Leave a Reply