Hi guys...
I've started playing with php and I'm having a problem with the mail() function. I'm a novice at this so any help would be much appreciated. If anyone knnows a solution please be patient and explain it using non- gobbledy gook please as I'm thick 😕
OK here goes. I have a form as follows:feedback.htm
<html>
<head>
<title>Bob's Auto Parts - Customer Feedback</title>
</head>
<body>
<h1>Customer Feedback</h1>
<p>Please tell us what you think.</p>
<form method=post action="processfeedback.php">
Your name: <br />
<input type=text name="name" size=40><br />
Your email address: <br />
<input type=text name="email" size=40><br />
Your feedback:<br />
<textarea name="feedback" rows=5 cols=30>
</textarea><br />
<input type=submit value="Send feedback">
</form>
</body>
</html>
I then have a file entitled processfeedback.php
<?php
// CREATE SHORT VARIABLE NAME
$name = $HTTP_POST_VARS['name'];
$email = $HTTP_POST_VARS['email'];
$feedback = $HTTP_POST_VARS['feedback'];
$toaddress = 'me@localhost.com';
$subject = 'Feedback from website';
$mailcontent = 'Customer name : '.$name."\n"
.'Customer email : '.$email."\n"
."Customer comments : \n".$feedback."\n";
$fromaddress = 'From : me@localhost.com';
mail($toaddress, $subject, $mailcontent, $fromaddress);
?>
<html>
<head>
<title>Bob's Auto parts - Feedback submitted</title>
</head>
<body>
<h1>Feedback submitted</h1>
<p>Your feedback has been sent.</p>
</body>
</html>
OK so far so good...
When I click the submit button on the form I get the following:
Warning: Failed to Connect in c:\program files\apache group\apache\htdocs\processfeedback.php on line 18
Feedback submitted
Your feedback has been sent.
I have looked at some postings in this forum and it suggests looking at the php.ini file. This is what I have:
; php.ini for PEAR tests
include_path=..
[mail function]
SMTP= localhost ; for Win32 only
sendmail_from= me@localhost.com ; for Win32 only
[Session]
session.save_path= C:\PHP\sessiondata ; argument passed to save_handler
error_reporting= E_ALL; display all errors, warnings and notices
I am using my local pc to learn on. The example above is taken from a book that suggests that if it doesnt work you have to set it up to point at your mail-sending program. I use outlook express. I imagine it'll be something really simple but i'm going round in circles with it. Any help would be much appreciated..
Thanks Dave...