Jump to content

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="kiruthigabaskaran@gmail.com";
$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="kiruthigabaskaran@gmail.com";
			$subject="Feedback/Enquiry";
			$mail="test@email.com";
			$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

Edited by cyber_alchemist
Link to comment
https://forums.phpfreaks.com/topic/285514-sending-email/#findComment-1465974
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.