/    Sign up×
Community /Pin to ProfileBookmark

Whats wrong with this?

Hi,
Im getting these once ive clicked “Submit”

Notice: Undefined index: check in /home/fhlinux172/b/*****.com/user/htdocs/mailer.php on line 21

Warning: Invalid argument supplied for foreach() in /home/fhlinux172/b/best******.com/user/htdocs/mailer.php on line 21

Notice: Undefined variable: check_msg in /home/fhlinux172/b/best*****.com/user/htdocs/mailer.php on line 27

Notice: Undefined variable: confrimemail_field in /home/fhlinux172/b/best*****.com/user/htdocs/mailer.php on line 27

CODE:

<?php
if(isset($_POST[‘submit’])) {

$to = “info@*****.co.uk”;
$subject = “From Best*
**
**.com Online Query”;
$name_field = $_POST[‘name’];
$email_field = $_
POST[’email’];
$confirmemail_field = $_POST[‘confirmemail’];
$message = $_
POST[‘message’];
$dropdown = $_POST[‘drop_down’];

foreach($_POST[‘check’] as $value) {
$check_msg .= “Checked: $valuen”;
}

//You needed a from header.
$headers = “From: “.$email_field.” n”;
$body = “From: $name_fieldn E-Mail: $email_fieldn $check_msg Confirm E-mail: $confrimemail_fieldn `Drop-Down: $dropdownn Message:n $messagen”;

mail($to, $subject, $body, $headers);
echo “Data has been submitted to $to!”;
} else {
echo “blarg!”;
}
?>

I dont understand PHP that much and i deffiantly dont understand why it is giving me Undifined Variables.

Hope you can help.

Crast?

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@CrasterauthorJan 16.2008 — Please can anybody help this is urgent...?
Copy linkTweet thisAlerts:
@NogDogJan 17.2008 — You can help us to help you by using the [code=php] [url=http://www.webdeveloper.com/forum/misc.php?do=bbcode]bbcode tags[/url] around your code sample, and indicating (perhaps with comments?) which lines are the line numbers cited in the error messages.
Copy linkTweet thisAlerts:
@Reli4ntJan 17.2008 — Sound Advise.

Also, double check the form field named check, if there even is one. I suspect your form is not submitting one so $_POST['check'] is not being found.

The rest of the issues may cascade from there.
×

Success!

Help @Craster 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.19,
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,
)...