0

Hi'
I learnt that in order for the error messages to a form to be displayed on the same window with the form one method is to post it to itself ie the action attribute...
Initially my action attribute for "contacts.php" was pointing to "mailer.php". The problem was that my error messages were being displayed on a separate page/window. I dont want to go the javascript way for now. Am not sure how these two files can be merged so that the error messages can appear on the same page. Anyone who can do that for me.

Here are the two files
contacts.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<!-- @(#) $Id$ -->
<head>
	<title>Jiomoe Foundation</title>
	<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
	<meta name="Keywords" content= "jiomoe, jiomoe foundation, youth, youth organization"/>
	<meta name="Description" content="" />

	<meta http-equiv="pragma" content="no-cache" />
	<meta http-equiv="cache-control" content="no-cache" />

	<link rel="shortcut icon" href="./images/jiomoe-logo.jpg" type="image/x-icon" />
	<link rel="stylesheet" type="text/css" href="./css/style.css" />
	<link rel="stylesheet" type="text/css" href="./css/customize.css" />
	<link rel="stylesheet" type="text/css" href="./css/layout.css" />


</head> 

<body>
<div id="wrap">
	<div id="header"> 
		<?php
			include("logo.php");
			?>
			</div>
		<div id="breadcrumb">
	
				<ul>
						<li><a href="index.php" class="">Home</a></li>
						<li><a href="aboutus.php" class="">About Us</a></li>
						<li><a href="programs.php" class="">Our Programs</a></li>
						<li><a href="members.php" class="">Membership</a></li>
						<li><a href="careers.php" class="">Careers</a></li>
						<li><a href="contacts.php" class="active">Contacts</a></li>
				</ul>
		</div>

<div id="main-body">
	<div id="content"> 
		<div class="inside">
			<form method="POST" action="contacts.php" form name="contacts">
                        <p>The fields marked with an asterik must be filled</p>
			<label for="first_name">First Name:*</label><br/>
			   <input type="text" name="first_name" size="19"/><br/>
			   <br/>
                         <label for="Last_name">Last Name:*</label><br/>
			   <input type="text" name="last_name" size="19"/><br/>
			   <br/>
                           <label for="telephone">Telephone Number:</label><br/>
			   <input type="text" name="telephone" size="19"/><br/>
			   <br/>


			   <label for="email">Email:*</label><br/>
			   <input type="text" name="email" size="19"/><br/>
			   <br/>
			   <label for="comments">Message:*</label><br/>
			   <textarea rows="9" name="comments" cols="30"></textarea>
			   <br/>
			   <br/>
			   <input type="submit" value="Submit" name="submit"/>
			</form>
		</div>
	</div>

<div id="sidebar"> 
	<div class="inside">
		<div class="border">
			<p>Jiomoe Foundation is a Volunteer, Community based Youth initiative
			founded by the Kenyan Youth to eradicate poverty,
			create employment opportunities, market and empower the Youth.</p>
			</div>
			<div class="border">
				<div class="info">Information</div>
					Founded<br/> 2008
			</div>
			<div class="border">
				<div class="info">Links</div>
					<a href="http://www.jiomoeclub.net">www.jiomoeclub.net</a><br/>
					<a href="http://www.jamhurisoftware.com">www.jamhurisoftware</a><br/>
					<a href="http://www.fashtechcomputers.com">www.fashtechcomputers</a><br/>
			</div> 
	</div>
</div>

</div> <!--end of main-body-->

<div id="sidebar-2"> 
	<div class="inside"> 
		<div class="advertisement">
			Contact details
		</div>
		<img src="./images/contact_us.jpg"/><br/>
		<strong>Email: info@jiomoe.org<br/>
		Tel: +254723169577<br/>
		+254734297258</strong>
		<div class="advertisement">
			Find Us
		</div>
			<a href="http://www.facebook.com/groups.php?ref=sb#/group.php?gid=98375464670"><img src="./images/facebook_badge.gif" border="0"/></a>
	</div>
</div>
		<?php
		include("./include/footer.php");
		?>
</div> <!--end of wrap-->

</body> </html>

mailer.php

<?php
if(isset($_POST['email'])) {
 
	// EDIT THE 2 LINES BELOW AS REQUIRED
	$email_to = "info@jiomoe.org, matotien@gmail.com, nellynellbig@gmail.com,matotien@yahoo.com,jiomoeclub@yahoo.com,info@jiomoeclub.net";
	$email_subject = "Web Inquiries";
 
 
	function died($error) {
		// your error code can go here
		echo "We are very sorry, but there were error(s) found with the form your submitted. ";
		echo "These errors appear below.<br /><br />";
		echo $error."<br /><br />";
		echo "Please go back and fix these errors.<br /><br />";
		die();
	}
 
	// validation expected data exists
	if(!isset($_POST['first_name']) ||
		!isset($_POST['last_name']) ||
		!isset($_POST['email']) ||
		//!isset($_POST['telephone']) ||
		!isset($_POST['comments'])) {
		died('We are sorry, but there appears to be a problem with the form your submitted.');		
	}
 
	$first_name = $_POST['first_name']; // required
	$last_name = $_POST['last_name']; // required
	$email_from = $_POST['email']; // required
	//$telephone = $_POST['telephone']; // not required
	$comments = $_POST['comments']; // required
 
	$error_message = "";
	$email_exp = "^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$";
  if(!eregi($email_exp,$email_from)) {
  	$error_message .= 'The Email Address you entered does not appear to be valid.<br />';
  }
	$string_exp = "^[a-z .'-]+$";
  if(!eregi($string_exp,$first_name)) {
  	$error_message .= 'The First Name you entered does not appear to be valid.<br />';
  }
  if(!eregi($string_exp,$last_name)) {
  	$error_message .= 'The Last Name you entered does not appear to be valid.<br />';
  }
  if(strlen($comments) < 2) {
  	$error_message .= 'The Comments you entered do not appear to be valid.<br />';
  }
 /* $string_exp = "^[0-9 .-]+$";
  if(!eregi($string_exp,$telephone)) {
  	$error_message .= 'The Telphone Number you entered does not appear to be valid.<br />';
  }*/
  if(strlen($error_message) > 0) {
  	died($error_message);
  }
	$email_message = "Form details below.\n\n";
 
	function clean_string($string) {
	  $bad = array("content-type","bcc:","to:","cc:","href");
	  return str_replace($bad,"",$string);
	}
 
	$email_message .= "First Name: ".clean_string($first_name)."\n";
	$email_message .= "Last Name: ".clean_string($last_name)."\n";
	$email_message .= "Email: ".clean_string($email_from)."\n";
	$email_message .= "Telephone: ".clean_string($telephone)."\n";
	$email_message .= "Comments: ".clean_string($comments)."\n";
 
 
// create email headers
$headers = 'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_subject, $email_message, $headers);  
?>
 
<!-- include your own success html here -->
 
 
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<!-- @(#) $Id$ -->
<head>
	<title>Jiomoe Foundation</title>
	<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
	<meta name="Keywords" content= "jiomoe, jiomoe foundation, youth, youth organization"/>
	<meta name="Description" content="Jiomoe Foundation is a volunteer community based youth initiative." />
 
	<meta http-equiv="pragma" content="no-cache" />
	<meta http-equiv="cache-control" content="no-cache" />
 
	<link rel="shortcut icon" href="./images/jiomoe-logo.jpg" type="image/x-icon" />
	<link rel="stylesheet" type="text/css" href="./css/style.css" />
	<link rel="stylesheet" type="text/css" href="./css/customize.css" />
	<link rel="stylesheet" type="text/css" href="./css/layout.css" />
 
 
</head> 
 
<body>
<div id="wrap">
	<div id="header"> 
		<?php
			include("logo.php");
			?>
			</div>
		<div id="breadcrumb">
 
				<ul>
						<li><a href="index.php" class="">Home</a></li>
						<li><a href="aboutus.php" class="active">About Us</a></li>
						<li><a href="programs.php" class="">Our Programs</a></li>
						<li><a href="members.php" class="">Membership</a></li>
						<li><a href="careers.php" class="">Careers</a></li>
						<li><a href="contacts.php" class="">Contacts</a></li>
				</ul>
		</div>
 
<div id="main-body">
	<div id="content"> 
		<div class="inside">
 
<p><b>Your message was sent</b></p>
 
<p>Your message was successfully sent!
Thank you for contacting us, we will reply
to your inquiry as soon as possible!</p>
<a href="contacts.php"><input type="submit" value="Back"/></a>
 
	</div>
	</div>
 
<div id="sidebar"> 
	<div class="inside">
		<div class="border">
			<p>Jiomoe Foundation is a Volunteer, Community based Youth initiative
			founded by the Kenyan Youth to eradicate poverty,
			create employment opportunities, market and empower the Youth.</p>
			</div>
			<div class="border">
				<div class="info">Information</div>
					Founded<br/> 2008
			</div>
			<div class="border">
				<div class="info">Links</div>
					<a href="http://www.jiomoeclub.net">www.jiomoeclub.net</a><br/>
					<a href="http://www.jamhurisoftware.com">www.jamhurisoftware</a><br/>
					<a href="http://www.fashtechcomputers.com">www.fashtechcomputers</a><br/>
			</div> 
	</div>
</div>
 
</div> <!--end of main-body-->
 
<div id="sidebar-2"> 
	<div class="inside"> 
		<div class="advertisement">
			Advertisements
		</div>
		<div class="advertisement">
			Find Us
		</div>
			<a href="#"><img src="./images/facebook_badge.gif" border="0"/></a>
	</div>
</div>
		<?php
		include("./include/footer.php");
		?>
</div> <!--end of wrap-->
 
</body> </html>
 
 
<?
}
?>

The merged file gave me a error message
"Parse error: syntax error, unexpected $end in C:\wamp\www\juhudi\contacts.php on line 288"
my merged file

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<!-- @(#) $Id$ -->
<head>
	<title>Jiomoe Foundation</title>
	<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
	<meta name="Keywords" content= "jiomoe, jiomoe foundation, youth, youth organization"/>
	<meta name="Description" content="" />

	<meta http-equiv="pragma" content="no-cache" />
	<meta http-equiv="cache-control" content="no-cache" />

	<link rel="shortcut icon" href="./images/jiomoe-logo.jpg" type="image/x-icon" />
	<link rel="stylesheet" type="text/css" href="./css/style.css" />
	<link rel="stylesheet" type="text/css" href="./css/customize.css" />
	<link rel="stylesheet" type="text/css" href="./css/layout.css" />


</head> 

<body>
<div id="wrap">
	<div id="header"> 
		<?php
			include("logo.php");
			?>
			</div>
		<div id="breadcrumb">
	
				<ul>
						<li><a href="index.php" class="">Home</a></li>
						<li><a href="aboutus.php" class="">About Us</a></li>
						<li><a href="programs.php" class="">Our Programs</a></li>
						<li><a href="members.php" class="">Membership</a></li>
						<li><a href="careers.php" class="">Careers</a></li>
						<li><a href="contacts.php" class="active">Contacts</a></li>
				</ul>
		</div>

<div id="main-body">
	<div id="content"> 
		<div class="inside">
			<form method="POST" action="contacts.php" form name="contacts">
                        <p>The fields marked with an asterik must be filled</p>
			<label for="first_name">First Name:*</label><br/>
			   <input type="text" name="first_name" size="19"/><br/>
			   <br/>
                         <label for="Last_name">Last Name:*</label><br/>
			   <input type="text" name="last_name" size="19"/><br/>
			   <br/>
                           <label for="telephone">Telephone Number:</label><br/>
			   <input type="text" name="telephone" size="19"/><br/>
			   <br/>


			   <label for="email">Email:*</label><br/>
			   <input type="text" name="email" size="19"/><br/>
			   <br/>
			   <label for="comments">Message:*</label><br/>
			   <textarea rows="9" name="comments" cols="30"></textarea>
			   <br/>
			   <br/>
			   <input type="submit" value="Submit" name="submit"/>
			</form>
		</div>
	</div>

<div id="sidebar"> 
	<div class="inside">
		<div class="border">
			<p>Jiomoe Foundation is a Volunteer, Community based Youth initiative
			founded by the Kenyan Youth to eradicate poverty,
			create employment opportunities, market and empower the Youth.</p>
			</div>
			<div class="border">
				<div class="info">Information</div>
					Founded<br/> 2008
			</div>
			<div class="border">
				<div class="info">Links</div>
					<a href="http://www.jiomoeclub.net">www.jiomoeclub.net</a><br/>
					<a href="http://www.jamhurisoftware.com">www.jamhurisoftware</a><br/>
					<a href="http://www.fashtechcomputers.com">www.fashtechcomputers</a><br/>
			</div> 
	</div>
</div>

</div> <!--end of main-body-->

<div id="sidebar-2"> 
	<div class="inside"> 
		<div class="advertisement">
			Contact details
		</div>
		<img src="./images/contact_us.jpg"/><br/>
		<strong>Email: info@jiomoe.org<br/>
		Tel: +254723169577<br/>
		+254734297258</strong>
		<div class="advertisement">
			Find Us
		</div>
			<a href="http://www.facebook.com/groups.php?ref=sb#/group.php?gid=98375464670"><img src="./images/facebook_badge.gif" border="0"/></a>
	</div>
</div>
		<?php
		include("./include/footer.php");
		?>
</div> <!--end of wrap-->

</body> </html>

<?php
if(isset($_POST['email'])) {
 
	// EDIT THE 2 LINES BELOW AS REQUIRED
	$email_to = "info@jiomoe.org, matotien@gmail.com, nellynellbig@gmail.com,matotien@yahoo.com,jiomoeclub@yahoo.com,info@jiomoeclub.net";
	$email_subject = "Web Inquiries";
 
 
	function died($error) {
		// your error code can go here
		echo "We are very sorry, but there were error(s) found with the form your submitted. ";
		echo "These errors appear below.<br /><br />";
		echo $error."<br /><br />";
		echo "Please go back and fix these errors.<br /><br />";
		die();
	}
 
	// validation expected data exists
	if(!isset($_POST['first_name']) ||
		!isset($_POST['last_name']) ||
		!isset($_POST['email']) ||
		//!isset($_POST['telephone']) ||
		!isset($_POST['comments'])) {
		died('We are sorry, but there appears to be a problem with the form your submitted.');		
	}
 
	$first_name = $_POST['first_name']; // required
	$last_name = $_POST['last_name']; // required
	$email_from = $_POST['email']; // required
	//$telephone = $_POST['telephone']; // not required
	$comments = $_POST['comments']; // required
 
	$error_message = "";
	$email_exp = "^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$";
  if(!eregi($email_exp,$email_from)) {
  	$error_message .= 'The Email Address you entered does not appear to be valid.<br />';
  }
	$string_exp = "^[a-z .'-]+$";
  if(!eregi($string_exp,$first_name)) {
  	$error_message .= 'The First Name you entered does not appear to be valid.<br />';
  }
  if(!eregi($string_exp,$last_name)) {
  	$error_message .= 'The Last Name you entered does not appear to be valid.<br />';
  }
  if(strlen($comments) < 2) {
  	$error_message .= 'The Comments you entered do not appear to be valid.<br />';
  }
 /* $string_exp = "^[0-9 .-]+$";
  if(!eregi($string_exp,$telephone)) {
  	$error_message .= 'The Telphone Number you entered does not appear to be valid.<br />';
  }*/
  if(strlen($error_message) > 0) {
  	died($error_message);
  }
	$email_message = "Form details below.\n\n";
 
	function clean_string($string) {
	  $bad = array("content-type","bcc:","to:","cc:","href");
	  return str_replace($bad,"",$string);
	}
 
	$email_message .= "First Name: ".clean_string($first_name)."\n";
	$email_message .= "Last Name: ".clean_string($last_name)."\n";
	$email_message .= "Email: ".clean_string($email_from)."\n";
	$email_message .= "Telephone: ".clean_string($telephone)."\n";
	$email_message .= "Comments: ".clean_string($comments)."\n";
 
 
// create email headers
$headers = 'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_subject, $email_message, $headers);  
?>
 
<!-- include your own success html here -->
 
 
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<!-- @(#) $Id$ -->
<head>
	<title>Jiomoe Foundation</title>
	<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
	<meta name="Keywords" content= "jiomoe, jiomoe foundation, youth, youth organization"/>
	<meta name="Description" content="Jiomoe Foundation is a volunteer community based youth initiative." />
 
	<meta http-equiv="pragma" content="no-cache" />
	<meta http-equiv="cache-control" content="no-cache" />
 
	<link rel="shortcut icon" href="./images/jiomoe-logo.jpg" type="image/x-icon" />
	<link rel="stylesheet" type="text/css" href="./css/style.css" />
	<link rel="stylesheet" type="text/css" href="./css/customize.css" />
	<link rel="stylesheet" type="text/css" href="./css/layout.css" />
 
 
</head> 
 
<body>
<div id="wrap">
	<div id="header"> 
		<?php
			include("logo.php");
			?>
			</div>
		<div id="breadcrumb">
 
				<ul>
						<li><a href="index.php" class="">Home</a></li>
						<li><a href="aboutus.php" class="active">About Us</a></li>
						<li><a href="programs.php" class="">Our Programs</a></li>
						<li><a href="members.php" class="">Membership</a></li>
						<li><a href="careers.php" class="">Careers</a></li>
						<li><a href="contacts.php" class="">Contacts</a></li>
				</ul>
		</div>
 
<div id="main-body">
	<div id="content"> 
		<div class="inside">
 
<p><b>Your message was sent</b></p>
 
<p>Your message was successfully sent!
Thank you for contacting us, we will reply
to your inquiry as soon as possible!</p>
<a href="contacts.php"><input type="submit" value="Back"/></a>
 
	</div>
	</div>
 
<div id="sidebar"> 
	<div class="inside">
		<div class="border">
			<p>Jiomoe Foundation is a Volunteer, Community based Youth initiative
			founded by the Kenyan Youth to eradicate poverty,
			create employment opportunities, market and empower the Youth.</p>
			</div>
			<div class="border">
				<div class="info">Information</div>
					Founded<br/> 2008
			</div>
			<div class="border">
				<div class="info">Links</div>
					<a href="http://www.jiomoeclub.net">www.jiomoeclub.net</a><br/>
					<a href="http://www.jamhurisoftware.com">www.jamhurisoftware</a><br/>
					<a href="http://www.fashtechcomputers.com">www.fashtechcomputers</a><br/>
			</div> 
	</div>
</div>
 
</div> <!--end of main-body-->
 
<div id="sidebar-2"> 
	<div class="inside"> 
		<div class="advertisement">
			Advertisements
		</div>
		<div class="advertisement">
			Find Us
		</div>
			<a href="#"><img src="./images/facebook_badge.gif" border="0"/></a>
	</div>
</div>
		<?php
		include("./include/footer.php");
		?>
</div> <!--end of wrap-->
 
</body> </html>
 
 
<?
}
?>
3
Contributors
6
Replies
7
Views
7 Years
Discussion Span
Last Post by network18
0

I think there is not problem in keeping 2 separate files especially when you code is so lengthy. I am not able to understand that what problem you are facing with 2 separate files.
In your merged file there is some problem with php braces{} one end brace is missing. so better you resolve your problem without merging.

0

By observing your code, it seems that you just need to change the sequence PHP appears on your script.
Instead of checking isset() for email textfield , check it for submit button.

Edit: your code improved in some way below-

<?php
$mail_return = '';
if(isset($_POST['submit']) && $_POST['submit']!='')
{
		// EDIT THE 2 LINES BELOW AS REQUIRED
		$email_to = "info@jiomoe.org, matotien@gmail.com, nellynellbig@gmail.com,matotien@yahoo.com,jiomoeclub@yahoo.com,info@jiomoeclub.net";
		$email_subject = "Web Inquiries";
	 
	 
		function died($error) {
			// your error code can go here
			echo "We are very sorry, but there were error(s) found with the form your submitted. ";
			echo "These errors appear below.<br /><br />";
			echo $error."<br /><br />";
			echo "Please go back and fix these errors.<br /><br />";
			die();
		}
	 
		// validation expected data exists
		if(!isset($_POST['first_name']) ||
			!isset($_POST['last_name']) ||
			!isset($_POST['email']) ||
			//!isset($_POST['telephone']) ||
			!isset($_POST['comments'])) {
			died('We are sorry, but there appears to be a problem with the form your submitted.');		
		}
	 
		$first_name = $_POST['first_name']; // required
		$last_name = $_POST['last_name']; // required
		$email_from = $_POST['email']; // required
		//$telephone = $_POST['telephone']; // not required
		$comments = $_POST['comments']; // required
	 
		$error_message = "";
		$email_exp = "^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$";
	  if(!eregi($email_exp,$email_from)) {
		$error_message .= 'The Email Address you entered does not appear to be valid.<br />';
	  }
		$string_exp = "^[a-z .'-]+$";
	  if(!eregi($string_exp,$first_name)) {
		$error_message .= 'The First Name you entered does not appear to be valid.<br />';
	  }
	  if(!eregi($string_exp,$last_name)) {
		$error_message .= 'The Last Name you entered does not appear to be valid.<br />';
	  }
	  if(strlen($comments) < 2) {
		$error_message .= 'The Comments you entered do not appear to be valid.<br />';
	  }
	 /* $string_exp = "^[0-9 .-]+$";
	  if(!eregi($string_exp,$telephone)) {
		$error_message .= 'The Telphone Number you entered does not appear to be valid.<br />';
	  }*/
	  if(strlen($error_message) > 0) {
		died($error_message);
	  }
		$email_message = "Form details below.\n\n";
	 
		function clean_string($string) {
		  $bad = array("content-type","bcc:","to:","cc:","href");
		  return str_replace($bad,"",$string);
		}
	 
		$email_message .= "First Name: ".clean_string($first_name)."\n";
		$email_message .= "Last Name: ".clean_string($last_name)."\n";
		$email_message .= "Email: ".clean_string($email_from)."\n";
		$email_message .= "Telephone: ".clean_string($telephone)."\n";
		$email_message .= "Comments: ".clean_string($comments)."\n";
	 
	 
	// create email headers
	$headers = 'From: '.$email_from."\r\n".
	'Reply-To: '.$email_from."\r\n" .
	'X-Mailer: PHP/' . phpversion();
	
	$mail_return = @mail($email_to, $email_subject, $email_message, $headers);  
}
else { $mail_return ='';}
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<!-- @(#) $Id$ -->
<head>
	<title>Jiomoe Foundation</title>
	<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
	<meta name="Keywords" content= "jiomoe, jiomoe foundation, youth, youth organization"/>
	<meta name="Description" content="" />

	<meta http-equiv="pragma" content="no-cache" />
	<meta http-equiv="cache-control" content="no-cache" />

	<link rel="shortcut icon" href="./images/jiomoe-logo.jpg" type="image/x-icon" />
	<link rel="stylesheet" type="text/css" href="./css/style.css" />
	<link rel="stylesheet" type="text/css" href="./css/customize.css" />
	<link rel="stylesheet" type="text/css" href="./css/layout.css" />


</head> 

<body>
<div id="wrap">
	<div id="header"> 
		<?php
			include("logo.php");
			?>
			</div>
		<div id="breadcrumb">
	
				<ul>
						<li><a href="index.php" class="">Home</a></li>
						<li><a href="aboutus.php" class="">About Us</a></li>
						<li><a href="programs.php" class="">Our Programs</a></li>
						<li><a href="members.php" class="">Membership</a></li>
						<li><a href="careers.php" class="">Careers</a></li>
						<li><a href="contacts.php" class="active">Contacts</a></li>
				</ul>
		</div>

<div id="main-body">
	<div id="content"> 
		<div class="inside">
			<form method="POST" action="" name="contacts">
                        <p>The fields marked with an asterik must be filled</p>
			<label for="first_name">First Name:*</label><br/>
			   <input type="text" name="first_name" size="19"/><br/>
			   <br/>
                         <label for="Last_name">Last Name:*</label><br/>
			   <input type="text" name="last_name" size="19"/><br/>
			   <br/>
                           <label for="telephone">Telephone Number:</label><br/>
			   <input type="text" name="telephone" size="19"/><br/>
			   <br/>


			   <label for="email">Email:*</label><br/>
			   <input type="text" name="email" size="19"/><br/>
			   <br/>
			   <label for="comments">Message:*</label><br/>
			   <textarea rows="9" name="comments" cols="30"></textarea>
			   <br/>
			   <br/>
			   <input type="submit" value="Submit" name="submit"/>
			</form>
		</div>
	</div>

<div id="sidebar"> 
	<div class="inside">
		<div class="border">
			<p>Jiomoe Foundation is a Volunteer, Community based Youth initiative
			founded by the Kenyan Youth to eradicate poverty,
			create employment opportunities, market and empower the Youth.</p>
			</div>
			<div class="border">
				<div class="info">Information</div>
					Founded<br/> 2008
			</div>
			<div class="border">
				<div class="info">Links</div>
					<a href="http://www.jiomoeclub.net">www.jiomoeclub.net</a><br/>
					<a href="http://www.jamhurisoftware.com">www.jamhurisoftware</a><br/>
					<a href="http://www.fashtechcomputers.com">www.fashtechcomputers</a><br/>
			</div> 
	</div>
</div>

</div> <!--end of main-body-->

<div id="sidebar-2"> 
	<div class="inside"> 
		<div class="advertisement">
			Contact details
		</div>
		<img src="./images/contact_us.jpg"/><br/>
		<strong>Email: info@jiomoe.org<br/>
		Tel: +254723169577<br/>
		+254734297258</strong>
		<div class="advertisement">
			Find Us
		</div>
			<a href="http://www.facebook.com/groups.php?ref=sb#/group.php?gid=98375464670"><img src="./images/facebook_badge.gif" border="0"/></a>
	</div>
</div>
		<?php
		include("./include/footer.php");
		?>
</div> <!--end of wrap-->

</body> </html>

 
<!-- include your own success html here -->
<?php
//include your own success html here only if the $mail_return is set
if(isset($mail_return) && $mail_return!='' && $mail_return ===TRUE)
{ 
 ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<!-- @(#) $Id$ -->
<head>
	<title>Jiomoe Foundation</title>
	<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
	<meta name="Keywords" content= "jiomoe, jiomoe foundation, youth, youth organization"/>
	<meta name="Description" content="Jiomoe Foundation is a volunteer community based youth initiative." />
 
	<meta http-equiv="pragma" content="no-cache" />
	<meta http-equiv="cache-control" content="no-cache" />
 
	<link rel="shortcut icon" href="./images/jiomoe-logo.jpg" type="image/x-icon" />
	<link rel="stylesheet" type="text/css" href="./css/style.css" />
	<link rel="stylesheet" type="text/css" href="./css/customize.css" />
	<link rel="stylesheet" type="text/css" href="./css/layout.css" />
 
 
</head> 
 
<body>
<div id="wrap">
	<div id="header"> 
		<?php
			include("logo.php");
			?>
			</div>
		<div id="breadcrumb">
 
				<ul>
						<li><a href="index.php" class="">Home</a></li>
						<li><a href="aboutus.php" class="active">About Us</a></li>
						<li><a href="programs.php" class="">Our Programs</a></li>
						<li><a href="members.php" class="">Membership</a></li>
						<li><a href="careers.php" class="">Careers</a></li>
						<li><a href="contacts.php" class="">Contacts</a></li>
				</ul>
		</div>
 
<div id="main-body">
	<div id="content"> 
		<div class="inside">
 
<p><b>Your message was sent</b></p>
 
<p>Your message was successfully sent!
Thank you for contacting us, we will reply
to your inquiry as soon as possible!</p>
<a href="contacts.php"><input type="submit" value="Back"/></a>
 
	</div>
	</div>
 
<div id="sidebar"> 
	<div class="inside">
		<div class="border">
			<p>Jiomoe Foundation is a Volunteer, Community based Youth initiative
			founded by the Kenyan Youth to eradicate poverty,
			create employment opportunities, market and empower the Youth.</p>
			</div>
			<div class="border">
				<div class="info">Information</div>
					Founded<br/> 2008
			</div>
			<div class="border">
				<div class="info">Links</div>
					<a href="http://www.jiomoeclub.net">www.jiomoeclub.net</a><br/>
					<a href="http://www.jamhurisoftware.com">www.jamhurisoftware</a><br/>
					<a href="http://www.fashtechcomputers.com">www.fashtechcomputers</a><br/>
			</div> 
	</div>
</div>
 
</div> <!--end of main-body-->
 
<div id="sidebar-2"> 
	<div class="inside"> 
		<div class="advertisement">
			Advertisements
		</div>
		<div class="advertisement">
			Find Us
		</div>
			<a href="#"><img src="./images/facebook_badge.gif" border="0"/></a>
	</div>
</div>
		<?php
		include("./include/footer.php");
		?>
</div> <!--end of wrap-->
 
</body> </html>
 
 
<?
}
?>

Edited by network18: code attachment

0

The previous style of merging the 2 files does not seem to work for me. I have therefore embarked on javascript and successfully validated this file:
contacts.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<!-- @(#) $Id$ -->
<head>
	<title>Jiomoe Foundation</title>
	<script type="text/javascript">

<!--

function validate_form ( )
{
	valid = true;

        if ( document.contacts.first_name.value == "" )
        {
                alert ( "Please fill in the 'first Name' box." );
                valid = false;
        }
        
        if ( document.contacts.last_name.value == "" )
        {
                alert ( "Please fill in the 'last Name' box." );
                valid = false;
        }
        
        if ( document.contacts.comments.value == "" )
        {
                alert ( "Please enter your 'message' box." );
                valid = false;
        }
        
  var emailID=document.contacts.email
	
	if ((emailID.value==null)||(emailID.value=="")){
		alert("Please Enter your Email ID")
		emailID.focus()
		valid=false
	}
	if (echeck(emailID.value)==false){
		emailID.value=""
		emailID.focus()
		valid=false
		}
        
        return valid;
}

function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Invalid E-mail ID")
		   valid=false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail ID")
		   valid=false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail ID")
		    valid=false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail ID")
		    valid=false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail ID")
		    valid=false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail ID")
		    valid=false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail ID")
		    valid=false
		 }

 		 valid=true					
	}



//-->

</script>

	<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
	<meta name="Keywords" content= "jiomoe, jiomoe foundation, youth, youth organization"/>
	<meta name="Description" content="" />

	<meta http-equiv="pragma" content="no-cache" />
	<meta http-equiv="cache-control" content="no-cache" />

	<link rel="shortcut icon" href="./images/jiomoe-logo.jpg" type="image/x-icon" />
	<link rel="stylesheet" type="text/css" href="./css/style.css" />
	<link rel="stylesheet" type="text/css" href="./css/customize.css" />
	<link rel="stylesheet" type="text/css" href="./css/layout.css" />


</head> 

<body>
<div id="wrap">
	<div id="header"> 
		<?php
			include("logo.php");
			?>
			</div>
		<div id="breadcrumb">
	
				<ul>
						<li><a href="index.php" class="">Home</a></li>
						<li><a href="aboutus.php" class="">About Us</a></li>
						<li><a href="programs.php" class="">Our Programs</a></li>
						<li><a href="members.php" class="">Membership</a></li>
						<li><a href="careers.php" class="">Careers</a></li>
						<li><a href="contacts.php" class="active">Contacts</a></li>
				</ul>
		</div>

<div id="main-body">
	<div id="content"> 
		<div class="inside">
					<form name="contacts" method="post" action="mailer.php" onSubmit="return validate_form ( );">
                        <p>The fields marked with an asterik must be filled</p>
			<label for="first_name">First Name:*</label><br/>
			   <input type="text" name="first_name" size="19"/><br/>
			   <br/>
                         <label for="Last_name">Last Name:*</label><br/>
			   <input type="text" name="last_name" size="19"/><br/>
			   <br/>
                           <label for="telephone">Telephone Number:</label><br/>
			   <input type="text" name="telephone" size="19"/><br/>
			   <br/>


			   <label for="email">Email:*</label><br/>
			   <input type="text" name="email" size="19"/><br/>
			   <br/>
			   <label for="comments">Message:*</label><br/>
			   <textarea rows="9" name="comments" cols="30"></textarea>
			   <br/>
			   <br/>
			   <input type="submit" value="Submit" name="submit"/>
			</form>
		</div>
	</div>

<div id="sidebar"> 
	<div class="inside">
		<div class="border">
			<p>Jiomoe Foundation is a Volunteer, Community based Youth initiative
			founded by the Kenyan Youth to eradicate poverty,
			create employment opportunities, market and empower the Youth.</p>
			</div>
			<div class="border">
				<div class="info">Information</div>
					Founded<br/> 2008
			</div>
			<div class="border">
				<div class="info">Links</div>
					<a href="http://www.jiomoeclub.net">www.jiomoeclub.net</a><br/>
					<a href="http://www.jamhurisoftware.com">www.jamhurisoftware</a><br/>
					<a href="http://www.fashtechcomputers.com">www.fashtechcomputers</a><br/>
			</div> 
	</div>
</div>

</div> <!--end of main-body-->

<div id="sidebar-2"> 
	<div class="inside"> 
		<div class="advertisement">
			Contact details
		</div>
		<img src="./images/contact_us.jpg"/><br/>
		<strong>Email: info@jiomoe.org<br/>
		Tel: +254723169577<br/>
		+254734297258</strong>
		<div class="advertisement">
			Find Us
		</div>
			<a href="http://www.facebook.com/groups.php?ref=sb#/group.php?gid=98375464670"><img src="./images/facebook_badge.gif" border="0"/></a>
	</div>
</div>
		<?php
		include("./include/footer.php");
		?>
</div> <!--end of wrap-->

</body> </html>

Could someone give me code that would send the form details to an email. I tried using this code but it sent a blank message to my email. The thank you page also loads automatically so long as you press the submit button. Yes it will give the error messages but when they are finished it will load the "message sent" page.

<?php
if(isset($_POST['email'])) 
{
 
	// EDIT THE 2 LINES BELOW AS REQUIRED
	$email_to = "info@jiomoe.org, matotien@gmail.com, nellynellbig@gmail.com,matotien@yahoo.com,jiomoeclub@yahoo.com,info@jiomoeclub.net";
	$email_subject = "Web Inquiries";
 
 
	function died($error) 
	{
		// your error code can go here
		echo "We are very sorry, but there were error(s) found with the form your submitted. ";
		echo "These errors appear below.<br /><br />";
		echo $error."<br /><br />";
		echo "Please go back and fix these errors.<br /><br />";
		die();
	}
	
 
// create email headers
$headers = 'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_subject, $email_message, $headers);  
}
?>
 
<!-- include your own success html here -->
 
 
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<!-- @(#) $Id$ -->
<head>
	<title>Jiomoe Foundation</title>
	<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
	<meta name="Keywords" content= "jiomoe, jiomoe foundation, youth, youth organization"/>
	<meta name="Description" content="Jiomoe Foundation is a volunteer community based youth initiative." />
 
	<meta http-equiv="pragma" content="no-cache" />
	<meta http-equiv="cache-control" content="no-cache" />
 
	<link rel="shortcut icon" href="./images/jiomoe-logo.jpg" type="image/x-icon" />
	<link rel="stylesheet" type="text/css" href="./css/style.css" />
	<link rel="stylesheet" type="text/css" href="./css/customize.css" />
	<link rel="stylesheet" type="text/css" href="./css/layout.css" />
 
 
</head> 
 
<body>
<div id="wrap">
	<div id="header"> 
		<?php
			include("logo.php");
			?>
			</div>
		<div id="breadcrumb">
 
				<ul>
						<li><a href="index.php" class="">Home</a></li>
						<li><a href="aboutus.php" class="active">About Us</a></li>
						<li><a href="programs.php" class="">Our Programs</a></li>
						<li><a href="members.php" class="">Membership</a></li>
						<li><a href="careers.php" class="">Careers</a></li>
						<li><a href="contacts.php" class="">Contacts</a></li>
				</ul>
		</div>
 
<div id="main-body">
	<div id="content"> 
		<div class="inside">
 
<p><b>Your message was sent</b></p>
 
<p>Your message was successfully sent!
Thank you for contacting us, we will reply
to your inquiry as soon as possible!</p>
<a href="contacts.php"><input type="submit" value="Back"/></a>
 
	</div>
	</div>
 
<div id="sidebar"> 
	<div class="inside">
		<div class="border">
			<p>Jiomoe Foundation is a Volunteer, Community based Youth initiative
			founded by the Kenyan Youth to eradicate poverty,
			create employment opportunities, market and empower the Youth.</p>
			</div>
			<div class="border">
				<div class="info">Information</div>
					Founded<br/> 2008
			</div>
			<div class="border">
				<div class="info">Links</div>
					<a href="http://www.jiomoeclub.net">www.jiomoeclub.net</a><br/>
					<a href="http://www.jamhurisoftware.com">www.jamhurisoftware</a><br/>
					<a href="http://www.fashtechcomputers.com">www.fashtechcomputers</a><br/>
			</div> 
	</div>
</div>
 
</div> <!--end of main-body-->
 
<div id="sidebar-2"> 
	<div class="inside"> 
		<div class="advertisement">
			Advertisements
		</div>
		<div class="advertisement">
			Find Us
		</div>
			<a href="#"><img src="./images/facebook_badge.gif" border="0"/></a>
	</div>
</div>
		<?php
		include("./include/footer.php");
		?>
</div> <!--end of wrap-->
 
</body> </html>
0

Here is the css incase one would want to look at how the file behaves

/*JBC Design style.css file */


#body
{
	width:100%;
	height:100%;
	background-color:#000000;
	text-align:center; /*center hack*/ 
}

#wrap 
{
	width:80%; /*center hack*/
	margin:0 auto; /*center hack*/
	text-align:left;
	height:auto;
} 

#header
{
	width:100%;
	background: #e1e6ee;	
} 

#main-body 
{ 
	float:left; 
	width:73%; 
	overflow:hidden;
} 

#main-body2
{
	float:left; 
	width:75%; 
	overflow:hidden;
}

#sidebar-2 
{ 
	float:right; 
	margin-left:-3px;
	overflow:hidden;
	border-left: 3px solid #ccc;
}

#content 
{ 
	float:right;
 	width:66.5%; 
 	overflow:hidden;
} 



#sidebar 
{ 
	float:left;
 	width:33.5%;
 	overflow:hidden; 
 }

#footer 
{
	clear:both;
	width:100%;
	height: 50px;
	padding-bottom: 15px; 
	padding-top: 20px; 
	text-align: center;
	border-top: 1px solid #336699; 
} 

/******************************classes****************************************/

.inside 
{
	padding:10px;
} 

.product_img
{
	float: left;
	width: 45%;
	height:125px;
	padding-left:9%;
	padding-top:2%;
}

.product_details
{
	float: left;
	width: 45%;
	height:125px;
	padding-top:2%;
}

 .product_img p
{
	text-align: center;
	font-weight:bold;
}

.product_details p
{
	text-align: center;
	font-weight:bold;
}

.subheading 
{
	color: #000066;
	font: 1.5em, trebuchet MS;
	line-height: 1.3em;	
}

.border
{
	border-top: 1px solid #e1e6ee;
	border-left: 1px solid #e1e6ee;
	border-bottom: 1px solid #e1e6ee;
	border-right: 1px solid #e1e6ee;
	padding: 5px 5px 5px 5px;
}

.content_headings
{
	font-weight: bold;
	color: #5b75ab;
	font: calibri;	
}

.info
{
	color: #000000; 
	background-color: #e1e6ee;
	font-weight: bold;
	padding-left: 10px;
}

.advertisement
{
	border-bottom: 1px solid #ccc;
	font-weight: bold;
	color: #5b75ab;
	font: calibri;
}
/*jbc Customize.css file */
/*****************************html***********************************************/
*{
	margin:0;
	padding:0;
}

h1,h2,h3,h4,h5,h6,p,blockquote,form,label,ul,ol,dl,fieldset,address 
{
	margin: 0.5em 0; 
}

li,dd 
{ 
	margin-left:1em;
}

fieldset 
{ 
	padding:.5em; 
}

	a {
		color:#8496bd;
		text-decoration:none;
	}
	a:hover {
		text-decoration:none;
	}
	h1, h2, h3 {
		margin:.8em 0 .2em 0;
		padding:0;
	}
	p {
		margin:.4em 0 .8em 0;
		padding:0;
	}

body 
{
	font-size:76.1%;
	font-family:Trebuchet MS,Verdana,Lucida Grande,Georgia; 
	line-height:1.3em;
	background-color:#e1e6ee;
	border-top: 30px #5b75ab solid;
}

/*****************************ids***********************************************/
#breadcrumb
{
	clear: both;
	float:right;
	width:100%;
	border-bottom: 2px solid #000046;
}

#wrap 
{
	background: #fff;
	color: #555;
}
	
#breadcrumb ul 
{
		clear:left;
		float:left;
		width:100%;
		list-style:none;
		margin:10px 0 0 0;
		padding:0;
}

#breadcrumb ul li 
{
		display:inline;
		list-style:none;
		margin:0;
		padding:0;
}

#breadcrumb ul li a 
{
		display:block;
		float:left;
		margin:0 0 0 1px;
		padding:3px 10px;
		text-align:right;
		background:#bfcade;
		color:#5b75ab;
		text-decoration:none;
		position:relative;
		left:15px;
		line-height:1.3em;
		font-weight:bold;
}

#breadcrumb ul li a:hover 
{
	color:#fff;
	background-color: #5b75ab;
}

#breadcrumb ul li a.active,
#breadcrumb ul li a.active:hover 
{
	color:#000;
	font-weight:bold;
	background-color: #fff;
}

#breadcrumb ul li a span 
{
		display:block;
}
	
#product_img_details
{
	height: 150px;
	width: 100%;	
}

/************************************Classes************************************/

.comment-link
{
color:#005E2F;
text-decoration:none;
font-weight:bold
}

a.comment-link:hover
{
	text-decoration:underline
}
/*JBC layout.css CSS file*/
body {
	text-align:center; /*center hack*/
}

/**************************ids***********************************************/
#wrap {
	width:80%; /*center hack*/
	margin:0 auto; /*center hack*/
	text-align:left;
}

#footer 
{
	clear:both;
}

#main-body 
{
	float:left;
	width:75%;
}

#sidebar-2 
{
	float:right;
	width:25%;
	overflow:hidden;
	margin-left:-3px;
}

#content 
{
	float:right;
	width:66.5%;
	overflow:hidden;
}

#sidebar 
{
	float:left;
	width:33.5%;
	overflow:hidden;
}

/**************************classes***********************************************/

.inside 
{
	padding:10px;
}

.logo
{
	float: left;
}

.jiomoetext
{
	float: left;
	font-weight:bold;
	font: 18px "verdana";
	color: #ff0000;
	margin: 5px 0 0 5px;
}
0

css got nothing to do with email functionality, css decides the look of the html presented on the client.

your structure should be this way -
if you want to put the email code to some other page then you need to provide that page in the action of the previous form.
And that second page will check if those post variables are set email will be sent.
HTML Page -

<form action='sendmail.php' >
Email Address<input type='text'  />
Name <input type='text'  />
<input type='submit' >
</form>

and the sendmail.php below -

<?php 
if(isset(post vars)
{
//send mail
$success = mail();
if($success) header(Location:success.php");
else {echo some error and redirect to the previous page only )
}
?>

or else you can have both in the same page and the after success you can redirect it to the succes.php , but this page will be like -

<?php 
if(isset($_POST['btn']) )
{
$email_id = get id from the text field;
$name = get name from the text field;
//send mail
$success = mail();
if($success)header(Location:success.php");
else {same page}
}
<form action='sendmail.php' >
Email Address<input type='text'  />
Name <input type='text'  />
<input type='submit' name='btn'>
</form>

Edited by network18: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.