/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] email form

I’m new to php so I’m not too sure if what i’m doing is right. I’ve created an email form off of a simple script which originally had only two fields, name and email, i found that the html and php worked fine.
When I added more fields, I found that the form doesn’t work. This is the php:

[CODE]<?
$message = $_REQUEST[‘name’] ;
$email = $_REQUEST[’email’] ;
$penname = $_REQUEST[‘penname’] ;
$fftitle = $_REQUEST[‘fftitle’] ;
$genre = $_REQUEST[‘genre’] ;
$rating = $_REQUEST[‘rating’] ;
$period = $_REQUEST[‘period’] ;
$pship = $_REQUEST[‘pship’] ;
$pship2 = $_REQUEST[‘pship2’] ;
$sship = $_REQUEST[‘sship’] ;
$sship2 = $_REQUEST[‘sship2’] ;
$pship = $_REQUEST[‘pship’] ;
$summary = $_REQUEST[‘summary’] ;
$link1 = $_REQUEST[‘link1’] ;
$link2 = $_REQUEST[‘link2’] ;
$link3 = $_REQUEST[‘link3’] ;
$link4 =$_REQUEST[‘link4’] ;
$link5 = $_REQUEST[‘link5’] ;
$sship3 = $_REQUEST[‘sship3’] ;
$sship4 = $_REQUEST[‘sship4’] ;

mail( “[email protected]”, “Fanfiction listing”,
$message, “From: $email” );
header( “Location: http://www.example.com/thankyou.html” );
?>[/CODE]

[URL=”http://www.hp-ships.com/main_files/submitff2.htm”]This is the form.[/URL]

I found when i used _request for the form when it initially had two fields, it sent, though now it has more fields it doesn’t.
When I changed it to _
get, it posted an email, but it had no content at all.
Also I have no specified header yet, I don’t know if that makes a difference..
I’m learning as I go so a little help would be great!! Thanks.

to post a comment
PHP

5 Comments(s)

Copy linkTweet thisAlerts:
@cjc1055Feb 10.2007 — You're going to need some error checking in there, but first you need appropriate code to send the email, which I'm posting below. You need to add error checking, and I would change your form to POST, which is how I re-coded your mail function.

Hope this helps

[code=php]
<?
$message = "Name: {$_POST['name']}n";
$message .= "PenName = {$_POST['penname']}n";
$message .= "FFTitle: {$_POST['fftitle']}n";
$message .= "Genre: {$_POST['genre']}n";
$message .= "Rating: {$_POST['rating']}n";
$message .= "Period = {$_POST['period']}n";
$message .= "PShip: {$_POST['pship']}n";
$message .= "pship2: {$_POST['pship2']}n";
$message .= "SShip: {$_POST['sship']}n";
$message .= "SShip2 = {$_POST['sship2']}n";
$message .= "pship: {$_POST['pship']}n";
$message .= "Summary: {$_POST['summary']}n";
$message .= "link1: {$_POST['link1']}n";
$message .= "link2 = {$_POST['link2']}n";
$message .= "link3: {$_POST['link3']}n";
$message .= "link4: {$_POST['link4']}n";
$message .= "link5 = {$_POST['link5']}n";
$message .= "SShip3: {$_POST['sship3']}n";
$message .= "SShip4: {$_POST['sship4']}n";

$to = $_POST['email'] ;
$subject = "Subject here";
$mailheaders ="From: {$_POST['name']} <[email protected]>n";
$mailheaders .="Reply-To: <[email protected]> n";

mail($to,$subject,$message,$mailheaders);
header( "Location: http://www.example.com/thankyou.html" );
?>
[/code]
Copy linkTweet thisAlerts:
@LyssauthorFeb 10.2007 — I'm pretty sure it didn't send, I tried two different mail boxes. Thanks anyway. Any more suggestions? ?

Edit: Actually it did send, it sent to the email that I entered into the form. How would I go about changing that to a different email?! ?
Copy linkTweet thisAlerts:
@bathurst_guyFeb 10.2007 — Yes that is how cjc1055 wrote it for some reason ???

[code=php]<?
$message = "Name: {$_POST['name']}n";
$message .= "PenName = {$_POST['penname']}n";
$message .= "FFTitle: {$_POST['fftitle']}n";
$message .= "Genre: {$_POST['genre']}n";
$message .= "Rating: {$_POST['rating']}n";
$message .= "Period = {$_POST['period']}n";
$message .= "PShip: {$_POST['pship']}n";
$message .= "pship2: {$_POST['pship2']}n";
$message .= "SShip: {$_POST['sship']}n";
$message .= "SShip2 = {$_POST['sship2']}n";
$message .= "pship: {$_POST['pship']}n";
$message .= "Summary: {$_POST['summary']}n";
$message .= "link1: {$_POST['link1']}n";
$message .= "link2 = {$_POST['link2']}n";
$message .= "link3: {$_POST['link3']}n";
$message .= "link4: {$_POST['link4']}n";
$message .= "link5 = {$_POST['link5']}n";
$message .= "SShip3: {$_POST['sship3']}n";
$message .= "SShip4: {$_POST['sship4']}n";

$to = "[email protected]" ;
$subject = "Subject here";
$mailheaders ="From: {$_POST['name']} <$_POST['email']>n";
$mailheaders .="Reply-To: <$_POST['email']> n";

mail($to,$subject,$message,$mailheaders);
header( "Location: http://www.example.com/thankyou.html" );
?>[/code]
Copy linkTweet thisAlerts:
@LyssauthorFeb 11.2007 — It kept saying error on line 23, so I changed the brackets from < to { and it's working. Thankyou very much ?
Copy linkTweet thisAlerts:
@NightShift58Feb 11.2007 — This will not work - wrong mail header format...
×

Success!

Help @Lyss 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.18,
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,
)...