Basic Scripting Help

Hey all. I’m not a PHP guy - I’m mainly front-end. My client wants me to create a simple form - a name, email address, and message.

Does anyone have a script handy or know a site where I can get the php code to send an email (or create a log on the server) w/ the user’s name, email address, and message upon submitting it?

Thanks a lot in advance.
~TehYoyo

Here is a basic one. No user input has been sanitized though. You’ll need to add security to it now. Never trust user input.

HTML to match. Here is the example HTML for $email.


<input type="text" [b]name="email"[/b] value="Email" />
<?php
$email=$_POST['email'];
$name =$_POST['name'];
$message = $_POST['message'];
$subject = $_POST['subject'];
$from = "emailaddressthatitisbeingsentto@mail.com";



$send = mail($from , $subject , "Someone wants to contact you through your website.\
\
The user who wants to is. \
\
User: ".$name."\
Email: ".$email."\
\
".$message."\
\
Your welcome", "FROM: donotrespond@website.com");

if ($send||isset($send)||!empty($send))
{
header('Location: http://www.sitehere.com/page?mail=sent');
} else if(!$send||empty($send)||!isset($send)) {
header('Location: http://www.sitehere.com/page?error=true');
}
?>

You’ll need to setup an email account with your domain. Make sure it matches what is put in the script :).

Is it really working script, i am gonna give it try. Thanks for your efforts.

http://myphpform.com/

Does it have to be an email account w/ that domain? Or can I just use my gmail or yahoo?

~TehYoyo

Edit: Thanks, by the way.

Must be with that domain. Well, I assume so. You have to use an account linked to the domain. I don’t know what your host provides in terms of that :). I just made an account there. Had it be “donotrespond” etc…

Alright. Thanks a lot.

~TehYoyo

No problem :). Glad to help.