/    Sign up×
Community /Pin to ProfileBookmark

form to be sent to an email

I want a user to fill out a form and when they click submit, that form gets sent to an email address..
i’ve tried action=”mailto:[email protected]” but that isn’t want i’m looking to do. that opens a compose email window.

I’m wanting it to send the results of the form behind the scenes, and also send that them to a success page when the form is submitted.

I’ve also tried using action=”mailform.php”

and here is that code.

[code=php]<?php

$to = “[email protected]”;
$subject = “TA Online Enrollment Submission”;

while( list( $key, $value ) = each( $HTTP_POST_VARS ) ) {
$message .= “$key: $valuen”;
}

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

header( “Location: blablahblah.html” );

?>[/code]

That is the entire file.

it sends the user to the success page, but does not send the email.
Any suggestions?

to post a comment
HTML

4 Comments(s)

Copy linkTweet thisAlerts:
@eCatJul 08.2009 — Are you set on using PHP? Why not some simple HTML:

[CODE]<form name="yourform" action="/cgi-bin/sendmail.pl" method="post">
<input type="hidden" value="[email protected]" name="recipient">
<input type="hidden" name="redirect" value="http://www.your.domain/thank_you.html" />
....
</form>[/CODE]


Of course, you'd need to use the correct path to your server's sendmail script.

eCat
Copy linkTweet thisAlerts:
@kpjuniauthorJul 08.2009 — not set on php. didn't think about perl. i'll try it out.
Copy linkTweet thisAlerts:
@kpjuniauthorJul 08.2009 — This server has cgi - it has sendmail, but it is not a *.pl

there is a script on the server that the last webmaster put in, but it is very complicated and doesn't work. do you have a simple sendmail script i could use?
Copy linkTweet thisAlerts:
@savvykmsJul 09.2009 — I doubt this is the best solution or even a solution to "behind the scenes", but it is an old method i know of (not many people seem to know of it). Just throwing it out there.
[code=html]
<form method="post" action="mailto:[email protected]" enctype="text/plain">
<input type="text" name="username">
<input type="submit" value="Submit">
</form>
[/code]


The thing to worry about with this old method, is that it will require the user/client to have a way for the broswer to send email. Internet explorer work use the default email client i think. It may not be compatible etc.

Another method is using POST method to a PHP, ASP, etc script or a CGI script/program. This method could use the sendmail program on a *nix box and send to a given email address. This is the most broswer compatible method, but you may need a lot of validation. There are tons of examples out there.
×

Success!

Help @kpjuni 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.20,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

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