Hi Friends,
I have used this mail function it works properly. mail has sent when i submit the enquiry form. i need the "Enquiry posted sucessfully" message will be displayed in enquiry form. please tell the solution for my problem.

usermail.php

<?php
if( isset($_POST['name']) && isset($_POST['companyname']) && isset($_POST['address'])&& isset($_POST['country'])&&
	isset($_POST['email'])&& isset($_POST['phone']) &&
	isset($_POST['enquiry'])&& isset($_POST['details'])
  ){
    $msg = "<b>Name</b> : ". $_POST['name'] . "<br><b>Company Name</b> : " . $_POST['companyname'] . "<br><b>Address</b> : " . $_POST['address']."<br><b>Country</b>:".$_POST['country']."<br><b>Email</b>:".$_POST['email']."<br><b>Phone</b>:".$_POST['phone']."<br><b>Enquiry for</b>:".$_POST['enquiry']."<br><b>Details</b>:".$_POST['details'];
	$mailSent = sendMail("sundar_a1984@yahoo.com",$_POST['name'],$_POST['email'],$msg,"Enquiry Details");
}
function sendMail($to, $fromname, $fromemail, $msg, $subject){
	$headers  = "MIME-Version: 1.0\r\n";
   	$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
   	$headers .= "From: ".$fromname." <".$fromemail.">\r\n";
	$msg = stripslashes($msg);
	if ( mail($to,$subject,$msg,$headers) )
		return 1;
	else
		return 0;
echo "<script language='javascript'>";
echo "window.alert('Thank You! Your Enquiry has posted successfuly.')";
echo "</script>";

}
?>
<?php
echo header('Location:enquiry.php');
?>

Try this in place of that:

<script type="text/javascript">
window.alert("Thank You! Your Inquiry has posted successfully.")
</script>

hi drewpark
i used that code in that area but i didnt get the message alert box when i submit the enquiry form.

Hmmm...ok try this:

echo "<script type="text/javascript">window.alert("Thank You! Your Inquiry has posted successfully")</script>";
    exit;

hi drewpark
i used that code in that area but i didnt get the message alert box when i submit the enquiry form.

no friend.. still now i didnt get the message alert. can u tell me some another solution.

Ok then lets try this:

<script type="text/javascript">
function display_alert()
  {
  alert("Thank You! Your Inquiry has posted successfully.");
  }
</script>

If that worked, please remember to mark this thread as solved. Maybe you could even give me some reputation points....I just joined so I am still a newbie :)

commented: thanks drewpark.. +1

hi firend,
ok i will change when it is worked. can u try to solve it if u have free time. thanks for ur effort.

1. It will not alert your message because you are already returning a value [1 or 0] from the function. Once you return a value, you are out of the function. Either return the value after the alert, or simply, put the alert after the function call.
2. It's not advisable to have any echo/print statements before calling the header function [not even a simple html tag]. This will generate a warning, which can be overridden by using ob_start. :)

hi nav33n
i have been used the normal javascript before the header function.but not working can u tell how to solve it.

with regards
sundar

Hi nav33n ,
i used the java script alert after the mail function. but not working so can u tell some other solution..

Can you post your latest code ?

anyways I am using this code, and it's working good on my machine...

form.htm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
 <HEAD>
  <TITLE> New Document </TITLE>
  <META NAME="Generator" CONTENT="EditPlus">
  <META NAME="Author" CONTENT="">
  <META NAME="Keywords" CONTENT="">
  <META NAME="Description" CONTENT="">
 
 </HEAD>

 <BODY>
 <form name="form" action="test1.php" method="post" onSubmit="return verify()">
<table width="200" border="0">
 <tr>
   <td>Name : </td>
   <td><input type="text" name="name"><br></td>
 </tr>
 <tr>
   <td>Comp. Name : </td>
   <td><input type="text" name="companyname"><br></td>
 </tr>
 <tr>
   <td>Address : </td>
   <td><input type="text" name="address"><br></td>
 </tr>
 <tr>
   <td>Country : </td>
   <td><input type="text" name="country"><br></td>
 </tr>
 <tr>
   <td>Email : </td>
   <td><input type="text" name="email"><br></td>
 </tr>
 <tr>
   <td>Phone : </td>
   <td><input type="text" name="phone"><br></td>
 </tr>
 <tr>
   <td>Enquiry : </td>
   <td><input type="text" name="enquiry"><br></td>
 </tr>
 <tr>
   <td>Details : </td>
   <td><input type="text" name="details"><br></td>
 </tr>
 <tr>
   <td><INPUT class="button" type="submit" name="submit" value="Submit"></td>
   <td> </td>
 </tr>
</table>

</form>
<script>
function verify(){
       var ret = true;
       var f = document.forms[0].elements;
	   var a=0;
       for(var i = 0; i < f.length; i++){
               if(f[i].value == "") {
                       a++;
                       
				}
		}
		if(a>0)
				{
				alert("Please Fill The Form Correctly");
				ret = ret && false;
				}
       return ret;
}
</script>
 </BODY>
</HTML>

test1.php

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
 <HEAD>
  <TITLE> New Document </TITLE>
  <META NAME="Generator" CONTENT="EditPlus">
  <META NAME="Author" CONTENT="">
  <META NAME="Keywords" CONTENT="">
  <META NAME="Description" CONTENT="">
 </HEAD>

 <BODY>
<?php
if( ($_POST['name']) != NULL && ($_POST['companyname']) != NULL && ($_POST['address']) != NULL&& ($_POST['country']) != NULL &&
	($_POST['email']) != NULL && ($_POST['phone']) != NULL &&
	($_POST['enquiry'])  != NULL&& ($_POST['details'])  != NULL)
	{
    $msg = "<b>Name</b> : ". $_POST['name'] . "<br><b>Company Name</b> : " . $_POST['companyname'] . "<br><b>Address</b> : " . $_POST['address']."<br><b>Country</b>:".$_POST['country']."<br><b>Email</b>:".$_POST['email']."<br><b>Phone</b>:".$_POST['phone']."<br><b>Enquiry for</b>:".$_POST['enquiry']."<br><b>Details</b>:".$_POST['details'];
	$mailSent = sendMail("sundar_a1984@yahoo.com",$_POST['name'],$_POST['email'],$msg,"Enquiry Details");
}

else
{
	echo '<script type="text/javascript">';
	echo "alert('Mail has not been succesfully passed to us.. sorry ...')";
	echo "</script>";
	echo "<p><a href='test1.htm'>click here</a> to go back....</p>";
}
function sendMail($to, $fromname, $fromemail, $msg, $subject){
	$headers  = "MIME-Version: 1.0\r\n";
   	$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
   	$headers .= "From: ".$fromname." <".$fromemail.">\r\n";
	$msg = stripslashes($msg);
	if ( mail($to,$subject,$msg,$headers) )
	{
		echo '<script type="text/javascript">';
		echo "alert('Mail has been succesfully passed to us.. Thank You...')";
		echo "</script>";
		echo "<p><a href='test1.htm'>click here</a> to go back....</p>";
	}
}
?>

</BODY>
</HTML>

Have a great day....
:)

sunaruna84, I have solved your question also in my code just check it...

I have used javascript in both pages for you...

m i correct nav33n?

m i correct nav33n?

Didn't test, but seems good to me. :)

hummm... but it is working best on my machine....

sunaruna84, u just create two pages like me...

ok harsh Thanks a lot. i will use ur model...

yeah thanks...

Hi harsh and nav33n and other friends,

i think better the " Enquiry posted successfully" alert message will display in enquiry page.after that the page redirect to usermail. please let me know ur suggestion.

http://softsquare.biz/model6/enquiry.php


with regards
sundar

use this...

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
 <HEAD>
  <TITLE> New Document </TITLE>
  <META NAME="Generator" CONTENT="EditPlus">
  <META NAME="Author" CONTENT="">
  <META NAME="Keywords" CONTENT="">
  <META NAME="Description" CONTENT="">
 </HEAD>

 <BODY>
<?php
if( ($_POST['name']) != NULL && ($_POST['companyname']) != NULL && ($_POST['address']) != NULL&& ($_POST['country']) != NULL &&
	($_POST['email']) != NULL && ($_POST['phone']) != NULL &&
	($_POST['enquiry'])  != NULL&& ($_POST['details'])  != NULL)
	{
    $msg = "<b>Name</b> : ". $_POST['name'] . "<br><b>Company Name</b> : " . $_POST['companyname'] . "<br><b>Address</b> : " . $_POST['address']."<br><b>Country</b>:".$_POST['country']."<br><b>Email</b>:".$_POST['email']."<br><b>Phone</b>:".$_POST['phone']."<br><b>Enquiry for</b>:".$_POST['enquiry']."<br><b>Details</b>:".$_POST['details'];
	$mailSent = sendMail("sundar_a1984@yahoo.com",$_POST['name'],$_POST['email'],$msg,"Enquiry Details");
}

else
{
	echo '<script type="text/javascript">';
	echo "alert('Mail has not been succesfully passed to us.. sorry ...')";
	echo "</script>";
	echo "<p><a href='test1.htm'>click here</a> to go back....</p>";
}
function sendMail($to, $fromname, $fromemail, $msg, $subject){
	$headers  = "MIME-Version: 1.0\r\n";
   	$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
   	$headers .= "From: ".$fromname." <".$fromemail.">\r\n";
	$msg = stripslashes($msg);
	if ( mail($to,$subject,$msg,$headers) )
	{
		echo "Thanks! Your enquiry posted successfully...";
		 
	}
}
?>

</BODY>
</HTML>

And now please let you start a new thread if you have anymore questions... k ?

Have a nice day :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.