PDA

View Full Version : Email confirmation


luke
06-07-2009, 07:23 PM
i would like to find a PHP script that makes sure an email address that has been entered into a textbox is a vaid email address, e.g, no one can leave it blank, it has to contain anything then @ then anything then .co.uk or .com, i can remember seeing one of these somewhere but i cannot remember where and cant seem to find one anywhere, any help would be appreciated.

Cheers in advance.



Luke

DWcourse
06-07-2009, 08:14 PM
If you have Dreamweaver, looks like you could do it with a Spry Validation Text Field of Type:Custom and a RegEx expression for the Pattern to match.

edbr
06-08-2009, 02:28 AM
use javascript for clientside validation, but also php incase javascript is turned off
tour script needs to include something like
if (!preg_match("/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/", $email)) {
echo "<h4>Invalid email address</h4>";
} elseif ($email == "") {
echo "<h4>You must enter an e mail address</h4>";

}

/* Sends the mail and outputs the "Thank you" string if the mail is successfully sent, or the error string otherwise. */

elseif (mail($recipient,$email,$message, $from)) {
echo "<h4>Thank you for sending email</h4>";
} else {
echo "<h4>Can't send email</h4>";
}

you will have to declare the variables sent from your form first, $email $message etc.
if you are needing a ready made there are many see hotscripts, chipmunk etc. yahoogle formmail, should return some results

luke
06-08-2009, 06:21 PM
So where would i put this code?

on the feedback form page or another page that the form submits to?

edbr
06-09-2009, 01:09 AM
it would need to be incorporated as your mailing script but if you are asking that you might be better checking for a script . check www.dtheatre.com/scripts/formmail it is a generic script free and and (last i checked) secure re spam attack

CRey
06-10-2009, 08:36 AM
If you are stuck and need some more guidance try and get hold of The Essential Guide to Dreamweaver CS4 with CSS, Ajax abd PHP by David Powers.
I used it to develop exactly what you are looking for and found it invaluable.
I'm nothing to do with the book or David Powers BTW ;-)
Regards
Clive

MagicPower
06-11-2009, 12:43 PM
you can do it in DW. shift + F4 Windows. Behaviours panels then validate form. you can set if you want the form to accept anything, emailaddress, numbers, number from_ to _. hop this helps.