/    Sign up×
Community /Pin to ProfileBookmark

Mail Form, keep getting error

I keep getting the error message “Missing” från this script. The web demo works, but not even the unaltered script works (ok, I altered the email so I would recieve one).

Here’s mine that is more “styled”

[code=php]<HTML>
<HEAD>
<TITLE>DEAD MAN RISING</TITLE>
<LINK REL=”stylesheet” HREF=”../style.css” TYPE=”text/css”>
<?php include “../scripts/highlight.php” ?>
<?php
$recipientname = “DMR Form Mailer”;
$recipientemail = “[email protected]”;
$subject = “DMR Form Mailer”;
$thanks = “Thank you for contacting us.<BR>We will get back to you as soon as possible.<br>”;
?>
</HEAD>
<BODY>
<TABLE HEIGHT=”100%” WIDTH=”100%” BORDER=”0″ CELLSPACING=”0″ CELLPADDING=”0″>
<TR>
<TD ALIGN=”left” VALIGN=”top”>
<FONT>
<?php
if($_POST[‘submitform’]) {
$Name = $HTTP_POST_VARS[‘Name’];
$Email = $HTTP_POST_VARS[‘Email’];
$Comments = $HTTP_POST_VARS[‘Comments’];
// check required fields
$dcheck = explode(“,”,$require);
while(list($check) = each($dcheck)) {
if(!$$dcheck[$check]) {
$error .= “Missing $dcheck[$check]<br>”;
}
}
// check email address
if ((!ereg(“.+@.+..+”, $Email)) || (!ereg(“^[[email protected]]+$”, $Email))){
$error .= “Invalid email address<BR>”;}
// display errors
if($error) {
?>
<B>Error</B><BR>
<?php echo $error; ?><BR>
<A HREF=”#” onClick=”history.go(-1)”>Try again</A>
<?php
}
else
{
$browser = $HTTP_USER_AGENT;
$ip = $REMOTE_ADDR;
// format message
$message = “Response for $recipientname:
Name: $Name
Email: $Email
Comments: $Comments
—————————–
Browser: $browser
User IP: $ip”;
// send mail and print success message
mail($recipientemail,”$subject”,”$message”,”From: $Name <$Email>”);
echo “$thanks”;
}
}
else {
?>
<TABLE BORDER=”0″ CELLSPACING=”0″ CELLPADDING=”0″ WIDTH=”300″>
<TR>
<TD ALIGN=”left” VALIGN=”top”>
<FONT>
Contact us for gigs, opinions and such.<BR>
Use this form or the mail adress below.<BR>
(<A HREF=”mailto:[email protected]”>[email protected]</A>)<BR>
</FONT>
<BR>
<FORM NAME=”contactform” ACTION=”<?php echo $PHP_SELF; ?>” METHOD=”post”>
<INPUT NAME=”require” TYPE=”hidden” VALUE=”Name,Email,Comments”>
<INPUT NAME=”Name” SIZE=”33″ VALUE=”Name” CLASS=”formstyle” STYLE=”filter:alpha(opacity=60)” onMouseOver=”high(this)” onMouseOut=”low(this)” onFocus=”javascript: this.select()”>
<INPUT NAME=”Email” SIZE=”33″ VALUE=”Email” CLASS=”formstyle” STYLE=”filter:alpha(opacity=60)” onMouseOver=”high(this)” onMouseOut=”low(this)” onFocus=”javascript: this.select()”>
<TEXTAREA NAME=”Comments” ROWS=”7″ COLS=”30″ CLASS=”formstyle” STYLE=”filter:alpha(opacity=60)” onMouseOver=”high(this)” onMouseOut=”low(this)” onFocus=”javascript: this.select()”>Message</TEXTAREA>
<BR>
<SPAN CLASS=”formtext”>
<INPUT NAME=”submitform” TYPE=”submit” VALUE=” Send ” CLASS=”submitstyle” STYLE=”filter:alpha(opacity=60)” onMouseOver=”high(this)” onMouseOut=”low(this)”>
<INPUT NAME=”reset” TYPE=”reset” VALUE=” Reset ” CLASS=”submitstyle” STYLE=”filter:alpha(opacity=60)” onMouseOver=”high(this)” onMouseOut=”low(this)”>
</SPAN>
</FORM>
<?php } ?>
</FONT>
</TD>
</TR>
</TABLE>
</TD>
</TR>
</TABLE>
</BODY>
</HTML>[/code]

Any ideas?

to post a comment
PHP

5 Comments(s)

Copy linkTweet thisAlerts:
@jinkasSep 11.2004 — In more modern versions of PHP you have to explicitly pull all variables from the $_GET[] and/or $_POST[] arrays, and you aren't actually pulling the require variable...so update the following section of code as show below

old:
[code=php]
<?php
if($_POST['submitform']) {
$Name = $HTTP_POST_VARS['Name'];
$Email = $HTTP_POST_VARS['Email'];
$Comments = $HTTP_POST_VARS['Comments'];
// check required fields
$dcheck = explode(",",$require);
while(list($check) = each($dcheck)) {
if(!$$dcheck[$check]) {
$error .= "Missing $dcheck[$check]<br>";
}
}
// check email address
if ((!ereg(".+@.+..+", $Email)) || (!ereg("^[[email protected]]+$", $Email))){
$error .= "Invalid email address<BR>";}
// display errors
if($error) {
?>
[/code]


new:
[code=php]
<?php
if($_POST['submitform']) {
$Name = $_POST['Name'];
$Email = $_POST['Email'];
$Comments = $_POST['Comments'];
$require = $_POST['require'];
// check required fields
$dcheck = explode(",",$require);
while(list($check) = each($dcheck)) {
if(!$$dcheck[$check]) {
$error .= "Missing $dcheck[$check]<br>";
}
}
// check email address
if ((!ereg(".+@.+..+", $Email)) || (!ereg("^[[email protected]]+$", $Email))){
$error .= "Invalid email address<BR>";}
// display errors
if($error) {
?>
[/code]
Copy linkTweet thisAlerts:
@NoumenonauthorSep 12.2004 — Okay.

But now I get this error: Warning: Failed to connect to mailserver, verify your "SMTP" setting in php.ini in f:webserverdmrcontentsinteractive_contact.php on line 55
Copy linkTweet thisAlerts:
@ChickenmanSep 13.2004 — [mail function]

; For Win32 only.

SMTP = localhost

Is it like that, what php.ini says?

Do you have a mailserver running on localhost? If not, You may install f.e. Hamster, which is easy.

http://www.elbiah.de/hamster/pg/hpg17.zip

Then You can edit php.ini and set Your email-address to admin@localhost. With an additional localhost-account in Your email-client You should receive Your emails locally. Anyway, Your script should already work on an [B]internet[/B] installation.

Alex
Copy linkTweet thisAlerts:
@HellspireSep 13.2004 — I dont know how many times i have to reiterate this fact, you dont need to declare all these variables yourself. like

$name = $_POST[name]

what if you have 1000 form fields, and you change several, there is a much much simpler method.

[code=php]
foreach($_POST as $var => $val){$$var = $val;}
[/code]

This change to your code can allow you to massively trim() or stripslashes() or whatever you need. Of course, naturally, there you would have to do any custom function changes to a variable yourself, however the first initalization will make your code much more efficent, and less prone to errors, should certain directives be disabled by yourserver.

Also his code change does not effect the error you are receiving. Contact your server admin
Copy linkTweet thisAlerts:
@NoumenonauthorSep 13.2004 — Hellspire, I am my server admin ?

Chickenman, oh, never thought of that one *lol*
×

Success!

Help @Noumenon 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.17,
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,
)...