Contact Form not validating email address

Hi All

I am using a standard Rapidweaver Contact form.

While it does send messages, it does not validate email addresses. Is it supposed to? I would be happy with just a simple string validation (test if there is a @ and a dot).

cheers
Rob

To clarify:

I am receiving emails, but some people are not filling out the (return) email section correctly and therefore I can’t reply to them. It would be nice if the script could warn users that they have not entered a valid email address.

I have read on the old forum that the /mailer.php script that Rapidweaver uses does do a validity check (looking for a @ and a dot) but it does not seem top be working for me.

I have defined the email field
I am using a valid “Send to” email address
I have ticked “Send email using your email address” and the emails are being sent
I have ticked “Define email address in php script”
My sever does support php.

???

OK I have done some further checking:

the mail is sent via mailer.php

mailer.php does have a email validity checker, but it does not warn the user if they have typed an invalid email address.

I think it would be preferable if I have set a reply-to email as a required field, to warn the user if their email is invalid.

So I have edited mailer.php to include the following lines:

	//check user-type valid email
if (! check_email($submitted_email)) {
		redirect($return_url, 'The email address you have typed is not valid. Please try again.');
}

This will exit the mailer and give the user a warning that they have not typed a valid email.

Could this be included as a standard or at least as an option in future releases?

1 Like

that’s a brilliant solutiont! I only noticed the problem when i read your post. I assumed the RW form would validate an email address.

Should the code just be pasted into the “Begin variables to be written out by RapidWeaver //” section at the end of the section? or somewhere else in that section?

I think it’s a great and extremely necessary option to make the RW form viable. Please post the request in the feature requests - i think all RW users would appreciate that option. And perhaps even a “re-enter email” kind of validation. A recaptcha option would be also be appreciated, but maybe that’s asking too much.

The additional code needs to be inserted after submitted_email is declared, at about line 90.

I pasted it after this bit of code:

	if (check_email($submitted_email) && $send_from_users_email === false) {
	$from = $reply_to = $_SESSION['form'][$mail_from_name].' <'.$submitted_email.'>';

} else {
	$from = '<'.$email.'>';
	$reply_to = check_email($submitted_email) ? '<'.$submitted_email.'>' : $from;
}
1 Like

Thanks - that’s great! Really appreciate it!!!