/    Sign up×
Community /Pin to ProfileBookmark

Hey there,
I was using this CSS 3 and jQuery form tutorial to build a form for my website.
[url]http://youhack.me/2010/07/22/create-a-fancy-contact-form-with-css-3-and-jquery/[/url]
(the PHP is near the bottom)

It uses Ajax and Php to do the backend of the form, but in the tutorial there is not a $to. The form doesn’t work because it has nowhere to go.
Can someone please help me modify this code ‘so I can include a send to email address:

[code=html]
<?php

$name = $_POST[‘name’];
$email = $_POST[’email’];
$web = $_POST[‘web’];
$body = $_POST[‘text’];

if (!empty($name) & !empty($email) && !empty($body)) {
$body = “Name:{$name}nnWebsite :{$web}nnComments:{$body}”;
$send = mail($email, ‘Contact Form Submission’, $body, “From: {$email}”);
if ($send) {
echo ‘true’; //if everything is ok,always return true , else ajax submission won’t work
}

}
[/code]

?>

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@andypantsNov 27.2010 — It looks like you are sending an email back to the person that filled the form out. That is to say, this email will be to and from the same person. So to fix that you need to add an email to receive the mail.

[code=php]
<?php

$to = "[email protected]";

$name = $_POST['name'];
$email = $_POST['email'];
$web = $_POST['web'];
$body = $_POST['text'];

if (!empty($name) & !empty($email) && !empty($body)) {
$body = "Name:{$name}nnWebsite :{$web}nnComments:{$body}";
$send = mail($to, 'Contact Form Submission', $body, "From: {$email}");
if ($send) {
echo 'true'; //if everything is ok,always return true , else ajax submission won't work
}
}
[/code]


Email is sent with mail() function and "true" will be returned to your AJAX for verification. (code not tested)
Copy linkTweet thisAlerts:
@patrickorr1authorNov 27.2010 — Andypants, I appreciate the quick reply. I have already tried to add the line:

$to = "[email protected]";[/QUOTE]
I have also tried:
$to = $_POST['[email protected]'];[/QUOTE]

Unfortunately it is still returning to sender. I wish I could understand that PHP language better. Is there a part in the existing scripting that I need to remove so that it will stop sending to the email to the sender?

Thanks in advance.
Copy linkTweet thisAlerts:
@andypantsNov 27.2010 — Did you change it here too?

[code=php]
$send = mail($to, 'Contact Form Submission', $body, "From: {$email}"); [/code]
×

Success!

Help @patrickorr1 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.6,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...