Jump to content

need help! why no worky?


Recommended Posts

Hi, can anyone figure out whats wrong with this email form processing script? I'm new at this and I patched this together from multiple tutorials but I'm not sure if its written properly especially with calling on the function. Any help is appreciated. Thanks!



// Mail header removal
function isInjected($str) {
$injections = array(
$inject = join('|', $injections);
$inject = "/$inject/i";
if(preg_match($inject,$str)) {
	return true;
else {
	return false;

// Build the email 
$to = 'info@site.com';
$subject = "Secure contact form message from: $subject";
$message = "$name said: $message";
$headers = "From: $email";

// field validation
if ($subject=="" || $message=="" || $name=="")
print ("All form fields are required. Please go back and try again.");

// email validation
if(!eregi('^([._a-z0-9-]+[._a-z0-9-]*)@(([a-z0-9-]+\.)*([a-z0-9-]+)(\.[a-z]{2,3})?)$', $email)) 
print ("Your email address does not appear to be valid. Please go back and try again.");

// Send the mail using PHPs mail() function
mail(isInjected($to), isInjected($subject), isInjected($message), isInjected($headers));

// Redirect
header('Location: ../submitted.php');


Link to comment
Share on other sites

This line

mail(isInjected($to), isInjected($subject), isInjected($message), isInjected($headers));

is not going to work, since the function isInjected() returns only a "true" or "false" value and the mail() function is expecting strings as parameters.


Do the calls before calling mail() and only do the mail() function if all the returned values are "true".



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.

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.