Forum Moderators: coopster
Here's the code, for the form:
<form name="form" method="post" action="contact_thanks.php">
<p class="bodymd">Your Name<br>
<input type="text" name="Name">
</p>
<p class="bodymd">Your Bands Name<br>
<input type="text" name="Bname">
</p>
<p class="bodymd">Your Email (for us to get back to you)<br>
<input type="text" name="Email">
</p>
<p class="bodymd">Additional Stuff To Add?<br>
<textarea name="Comments" rows="5" cols="40"></textarea>
</p>
<p class="bodymd">
<input type="submit" name="Submit" value="Submit">
<input type="reset" name="Reset" value="Clear Form">
</p>
</form>
And for contact_thanks.php file (the one they go to once they submit):
<?php
if (($Name == "") ¦¦ ($Bname == "") ¦¦ ($Email == ""))
{
echo "<form name=form method=post action=contact_thanks.php>";
echo "<p class=bodymd>All three fields of this form are required, or we can't get back to you!</p>";
echo "<p class=bodymd>Fill in the ones you missed, they are listed below.</p>";
}
if ($Name == "")
{
echo "<p class=bodymd>Your Name<br><input type=text name=Name></p>";
}
else
{
echo "<input type=hidden name=Name value=$Name>";
}
if ($Bname == "")
{
echo "<p class=bodymd>Your Bands Name<br><input type=text name=Bname></p>";
}
else
{
echo "<input type=hidden name=Bname value=$Bname>";
}
if ($Email == "")
{
echo "<input type=hidden name=Email value=$Email>";
}
else
{
echo "<input type=hidden name=Email value=$Email>";
}if (($Name == "") ¦¦ ($Bname == "") ¦¦ ($Email == ""))
{
echo "<input type=submit name=Submit value=Submit>";
echo "<input type=reset name=Reset value=Clear Form>";
echo "</form>";
}
else
{
$message = "Name: $Name\nBands Name: $Bname\nEmail: $Email\nComments: $Comments\n";
$extra = "From: $Name\r\nReply-To: $Email\r\n";
mail ("my@email.com", "my@email.com", $message, $extra);
echo "<p class=bodymd>Thanks for your inquiry, $Name.</p>";
echo "<p class=bodymd>A response will be sent to $Email as soon as possible, probably within 72 hrs.</p>";
}
?>
The problem is that once the user clicks submit, once they get to contact_thanks.php, the script displays the entire form, which it should only do if the fields aren't filled in. The user can't get to "Thanks for your inquiry" which is a successful form submission. It's like it's not maintaining the fields from the previous page, so the code on contact_thanks.php thinks all fields are blank.
I recently changed web hosts (due to terrible uptime), and I could've sworn it worked properly on the other host. Thanks for the assistance.
<?php
$mailto = 'admin@mydomain.com;
$subject = "Band Forum Request" ;
$formurl = "http://www.mydomain.com/heavy-metal-bands-forum.php" ;
$errorurl = "http://www.mydomain.com/contact-error.php" ;
$thankyouurl = "http://www.mydomain.com/contact-thanks.php" ;
$uself = 0;// -------------------- END OF CONFIGURABLE SECTION ---------------
$headersep = (!isset( $uself ) ¦¦ ($uself == 0))? "\r\n" : "\n" ;
$name = $_POST['name'] ;
$bname = $_POST['bnamel'] ;
$email = $_POST['email'] ;
$comments = $_POST['comments'] ;
$http_referrer = getenv( "HTTP_REFERER" );if (!isset($_POST['email'])) {
header( "Location: $formurl" );
exit ;
}
if (empty($name) ¦¦ empty($email) ¦¦ empty($bname))
{
header( "Location: $errorurl" );
exit ;
}
if ( ereg( "[\r\n]", $name ) ¦¦ ereg( "[\r\n]", $email ) )
{
header( "Location: $errorurl" );
exit ;
}if (get_magic_quotes_gpc())
{
$comments = stripslashes( $comments );
}$messageproper =
"This message was sent from:\n" .
"$http_referrer\n" .
"------------------------------------------------------------\n" .
"Your Name: $name\n" .
"Bands Name: $bname\n" .
"Email: $email\n" .
"------------------------- COMMENTS -------------------------\n\n" .
$comments .
"\n\n------------------------------------------------------------\n" ;mail($mailto, $subject, $messageproper,
"From: \"$name\" <$email>" . $headersep . "Reply-To: \"$name\" <$email>" . $headersep . "X-Mailer: chfeedback.php 2.08" );
header( "Location: $thankyouurl" );
exit ;?>
This
$name = $_POST['name'] ;
$bname = $_POST['bnamel'] ;
$email = $_POST['email'] ;
$comments = $_POST['comments'] ;
Is what I needed to do if register_globals was off, correct?