Forum Moderators: coopster

Message Too Old, No Replies

PHP Form Submitting on Page Load

Form submitting prematurely

         

livetoride

5:14 am on Jul 21, 2007 (gmt 0)



Hi,

I'm pretty new to PHP and I am trying to submit a form to itself. I used 'echo' to include any images so everything looks as it should (if someone has a better way to that, enlighten me).

I had loaded the page a few times and it looked/worked right, minus the bad validations I worked out. Now that specific page is not loading at all now, but when I navigate to contact.php, the internal server error shows up, but I get a blank email anyway. The script processed without the page even loading. Is there something I can do to load up the page, but not execute the script. Or is it possibly just the server problem?

Gian04

7:19 am on Jul 21, 2007 (gmt 0)

10+ Year Member



Please post a part of your codes here, in order for us to get a clearer picture of the problem.

livetoride

1:19 pm on Jul 21, 2007 (gmt 0)



<?php
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Expires: Mon, 16 Jul 2007 05:00:00 GMT");
header("Content-type: image/gif");
$name = $_REQUEST['name'];
$phone = $_REQUEST['phone'];
$email = $_REQUEST['email'];
$typeofwork = $_REQUEST['typeofwork'];
$message = $_REQUEST['message'];
$reference = $_REQUEST['reference'];
$autoreply = "Thanks for contacting us!\nA reponse will be made within 24-48 hours.";
$bodycontent = "$name\n$phone\n$email\n$typeofwork\n$message\n$reference";

if (ereg("^[[:alpha:]]+$", $name)) {
echo "Please enter your name.\n";
}

if (ereg("^([^@]+)@([a-z\-]+\.)+([a-z]{2,4})$", $email)) {
echo "Invalid email, please try again.\n";
}

if (ereg("^[[:alpha:]]+[[:digit:]]*$", $message)) {
echo "Please enter a message.";
?>
<html>
/*HTML*/
<form action="contactphp.php" method="post">
/*More HTML*/
</table></form></blockquote></td>
<?php
}
else {
mail("pvalure@example.com", "Contact Form Submission", $bodycontent, "From: example");
mail($email, "Auto-Reply", $autoreply, "From: example");
header("Location: http://www.example.com/thanks.html");
}
?>

i'm so new to this, any ideas?

[edited by: jatar_k at 2:06 pm (utc) on July 21, 2007]
[edit reason] please use example.com [/edit]