Help Sending Email Form

Page 1 of 1

3 Replies - 2527 Views - Last Post: 04 February 2006 - 11:45 PM

#1 cssulliv  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 24-January 06

Help Sending Email Form

Posted 04 February 2006 - 10:02 PM

The following code fails to deliver an e-mail form. Does anyone have any clue as to why this is happening?

<script>
	function CheckMail() {

  if(document.je.u_name.value=="")
  {
 	 alert('Enter your name, please!');
 	 document.je.u_name.focus();
 	 return false;
  }

  if(document.je.u_email.value=="")
  {
 	 alert('Enter your email, please!');
 	 document.je.u_email.focus();
 	 return false;
  }

  if(document.je.subject.value=="")
  {
 	 alert('Enter the subject, please!');
 	 document.je.subject.focus();
 	 return false;
  }

  if(document.je.message.value=="")
  {
 	 alert('Enter your message, please!');
 	 document.je.message.focus();
 	 return false;
  }

	}
</script>

<br><br>
	<form method=post onsubmit="send CheckMail();" name=je>
	<table width=340 align=center border=0>
	<caption align=center><span style="font-size:11; font-family:verdana; color:black; font-weight:bold">Use this form to contact <?=$AgentName?></span></caption>

	<tr>
  <td>Name:</td>
  <td><input type=text name="u_name" size=42 class="mtext"></td>
	</tr>

	<tr>
  <td>Email:</td>
  <td><input type=text name=u_email size=42 class="mtext"></td>
	</tr>

	<tr>
  <td>Subject:</td>
  <td><input type=text name=subject size=42 class="mtext" value="<?=$SubjectLine?>"></td>
	</tr>

	<tr>
  <td valign=top>Message:</td>
  <td><textarea rows=6 cols=41 name=message class="mtext"><?=$_POST[message]?></textarea></td>
	</tr>

	<tr>
  <td>&nbsp;</td>

  <td>
 	 <input type=submit name=s1 value="Send" class="sub1">
  </td>
	</tr>

	</table>
	</form>


Is This A Good Question/Topic? 0
  • +

Replies To: Help Sending Email Form

#2 Amadeus  Icon User is offline

  • g+ + -o drink whiskey.cpp
  • member icon

Reputation: 248
  • View blog
  • Posts: 13,506
  • Joined: 12-July 02

Re: Help Sending Email Form

Posted 04 February 2006 - 10:19 PM

Yes, it is because there is no code anywhere in the code you posted that would send email anywhere. All you have is a function to validate the fields in the form. Presumable, the code to actually send the message is on the page to which the form you have provided submits, or there is another function that has not been provided. Can you post that code instead?

You appear to be using PHP as a server side scripting language...can I presume from that that you are using the mail() function somehwere? Have you ensured that the settings for mail are correct?
Was This Post Helpful? 0
  • +
  • -

#3 cssulliv  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 24-January 06

Re: Help Sending Email Form

Posted 04 February 2006 - 10:36 PM

Here is the PHP. What settings should I check on my mail server?

<?
require_once("conn.php");
require_once("includes.php");

//get the agent info
$q1 = "select * from re2_agents where AgentID = '$_GET[AgentID]' ";
$r1 = mysql_query($q1) or die(mysql_error());
$a1 = mysql_fetch_array($r1);

$q12 = "select * from re2_listings where ListingID = '$_GET[ListingID]'";
$r12 = mysql_query($q12) or die(mysql_error());
$a12 = mysql_fetch_array($r12);



if(isset($_POST[s1]))
{
          $to = $a1[email];
	$subject = $_POST[subject];
	$message = $_POST[message];
	$message .= "\n\nContact for Property:\n$site_url/info.php?id=$_GET[ListingID]\n\n";

	$headers = "MIME-Version: 1.0\n"; 
	$headers .= "Content-type: text/plain; charset=iso-8859-1\n";
	$headers .= "Content-Transfer-Encoding: 8bit\n"; 
	$headers .= "From: $_POST[u_name] <$_POST[u_email]>\n"; 
	$headers .= "X-Priority: 1\n"; 
	$headers .= "X-MSMail-Priority: High\n"; 
	$headers .= "X-Mailer: PHP/" . phpversion()."\n"; 

	mail($to, $subject, $message, $headers);
	$thankyou = "<center><b><br><br><br>Thank you for your message!<br><br><a class=RedLink href=\"$site_url/info.php?id=$_GET[ListingID]\">back to the property details</a></center>";


	//get the templates
	require_once("templates/HeaderTemplate.php");
	require_once("templates/EmailThankyouTemplate.php");
	require_once("templates/FooterTemplate.php");

}


$AgentName = "$a1[FirstName] $a1[LastName]";


$SubjectLine = "Buyer Contact: $a12[address]";



//get the templates
require_once("templates/HeaderTemplate.php");
require_once("templates/EmailTemplate.php");
require_once("templates/FooterTemplate.php");

?>

Was This Post Helpful? 0
  • +
  • -

#4 snoj  Icon User is offline

  • Married Life
  • member icon

Reputation: 84
  • View blog
  • Posts: 3,564
  • Joined: 31-March 03

Re: Help Sending Email Form

Posted 04 February 2006 - 11:45 PM

Don't double post about the same problem.

Topic closed.

Go here to read more about what happens
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1