Jump to content

PHP Send mail script


VeronMan

Recommended Posts

I've got a website http://veron.sitesled.com, and I need a script that works to send an email to somebody who types in their name, e-mail address, and message, and then when the user clicks "Send", it sends their name, e-mail and message to me. Here's the script im using:

 

<?

$form_block = "

<FORM method=\"POST\" action=\"$_SERVER[php_SELF]\">

<P>Your Name:<br>
<INPUT type=\"text\" name=\"sender_name\" 
value=\"$_POST[sender_name]\" size=30></p>

<P>Your E-Mail Address:<br>
<INPUT type=\"text\" name=\"sender_email\"  
value=\"$_POST[sender_email]\" size=30></p>

<P>Your Message:<br>
<textarea name=\"message\" cols=30 
rows=5>$_POST[message]</textarea>
</p>

<INPUT type=\"hidden\" name=\"op\" value=\"ds\">


<P><INPUT type=\"submit\" value=\"Send This Form\"></p>

</FORM>

";

if ($_POST[op] != "ds") {

// they need to see the form

echo "$form_block";

} else if ($_POST[op] == "ds") {

$send = "yes";
               
// check each required field and create an error message.
// if any of the required fields are blank, set $send to "no".

if ($_POST[sender_name] == "") {

$name_err = "
<font color=red>Please enter your name!</font><br>
";
	$send = "no";

} 

if ($_POST[sender_email] == "") {

$email_err = "
<font color=red>Please enter your e-mail address!</font><br>
";
$send = "no";	

} 

if ($_POST[message] == "") {

$message_err = "
<font color=red>Please enter a message!</font><br>
";
$send = "no";

} 



// now do something depending value of $send 

if ($send == "yes") {

$headers = "From: \"$_POST[sender_name]\" <$_POST[sender_email]>\n";
mail("email", "Feedback", $message, $headers);
echo "<P>Mail sent!</p>";

} else if ($send == "no") {

echo "$name_err";
echo "$email_err";
echo "$message_err";
echo "$form_block";	

}

}

?>

 

But when I try to test the service, it won't work, it displays an error screen which says: 

Method Not Allowed
The requested method POST is not allowed for the URL /php/scripts/form.php.


--------------------------------------------------------------------------------

Apache/1.3.34 Server at veron.sitesled.com Port 80

 

So, what's the problem? All help is appreciated.

 

PS: If you want to check out the site/the non-working script for yourself, goto this link: http://veron.sitesled.com/message.html

 

Any help is good.  ;)

Link to comment
https://forums.phpfreaks.com/topic/41404-php-send-mail-script/
Share on other sites

Ok.

 

1 have you tried google for Method not allowed.  First thing you should always do.

 

2 What have you tried to fix the issue

 

3. Have you contacted the webhost since it is your server that is not allowing the post.

 

4. Move directories of the form.  No explanation as to why....but this worked for me.

 

5. Begging will get you nowhere

 

6. All of our problems are important.

 

 

Link to comment
https://forums.phpfreaks.com/topic/41404-php-send-mail-script/#findComment-202033
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.