Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PHP - Include function 1

Status
Not open for further replies.

kizmar2

Programmer
May 25, 2004
164
US
I have the following code:

Code:
<?php
	// Receiving POST from infoReq.php form
	// Pull variables and send e-mail.
	
	$FName = $_POST['txtFName'];
	$LName = $_POST['txtLName'];
	
	// Use method for sending mail
	include './includes/sendMail.php';

	// Set up mail variables
	$to = 'test@test.com';
	$subject = 'Information Request Form';
	
	// Add needed headers
	$headers = "From: test@test.com\n";
	$headers .= "MIME-Version: 1.0\n";

	// Build message body
	$body = 'Message to ' . $FName . ' ' .  $LName;
	
	// Send user to this page to confirm mail has been sent
	// location path starts at root web folder
	$e = 'index.php';

	send_mail($to,$subject,$body,$headers,$e);

?>

The file that's being "included" in that code is this:

Code:
<?php
	// Send mail function
	// $e = destination once mail is succesfully sent.
	
	function send_mail($to,$subject,$body,$headers,$e) {
		$message =& Mail::factory('mail');

		$message->send($to,$subject,$body,$headers);
		
		// Send message
//		mail($to,$subject,$body);
		
		// Send user to destination URL
		header('Location: ' . $e);
	}
?>

When I end up running the page with the include statement, it keep getting a "Fatal error: Call to undefined function: send_mail() in c:\hosting\webhost4life\member\maxtex\maximizetech\dev\vwp\includes\infoReqSend.php on line 37" error.

If I copy and paste the contents of the file being included into the original file it works fine.

Arruuu?

KizMar
------------
 
What's your error reporting set to? Are you sure your file is being included? Try changing the include statement to require, to see if the script fails after the file is required.
 
try
include 'sendMail.php';

since your file recides in the same directory as inforeqsend.php

;)


 
wow already a star and I didn't even had to put my brain into the gear for this one :) ;)

friday bad php day I suppose ;)

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top