Jump to content

Sending email


Roopavathy

Recommended Posts

Hi,

 

Here is my site :http://bhc.edu.in/COMMCOLLEGE/index.php

 

I have written code for sending email (The form is in footer).

 

But every time  when the page is loaded,it shows the message "Your feedback or enquiry is sent successfully". And i am getting empty  mail  to my email id.Please help,what should i do?

Link to comment
https://forums.phpfreaks.com/topic/285514-sending-email/
Share on other sites


<section class="contform">
<h3>FOR ENQUIRIES</h3>
<form action="index.php" method="post" name="Contact" class="contact">
<label class="labelformat">Name  :</label>
<input name="Name" type="text" maxlength="50" class="txt" /><br />
<label class="labelformat">E-mail :</label>
<input name="email" type="text" maxlength="100" class="txt" /><br />
<label class="labelformat">Enquiry:</label>
<textarea name="message" class="txt" cols="15" rows="2"></textarea>
<input class="txt" name="Submit" type="button" value="Send" />
</form>
<script type="text/javascript">

<?php

if(isset($_REQUEST['email']) && isset($_REQUEST['message']))
{

$to="[email protected]";
$subject="Feedback/Enquiry";
$mail=$_REQUEST['email'];
$message=$_REQUEST['message'];
$header="From:$mail";
$send=mail($to,$subject,$message,$header);

if($send)
{
echo "alert('Your feedback or enquiry is sent successfully!');";
}
else
{
echo "alert('Enter all the fields properly!');";
}

}
?>
</script>
</section>
Link to comment
https://forums.phpfreaks.com/topic/285514-sending-email/#findComment-1465840
Share on other sites

code after if condition is okay i guess. should check the code before. or send a simple mail without the query form with variables in code and check if mail() is working or not.

                        $to="[email protected]";
			$subject="Feedback/Enquiry";
			$mail="[email protected]";
			$message="test message" ;
			$header="From:$mail";
			$send=mail($to,$subject,$message,$header);
			
			if($send)
			{
				echo "alert('Your feedback or enquiry is sent successfully!');";
			}
			else
			{
				echo "alert('Enter all the fields properly!');";
			}


most probably it may be server problem. :x

Link to comment
https://forums.phpfreaks.com/topic/285514-sending-email/#findComment-1465974
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.