Using SendMail in Forms w/PHP HTML

Using SendMail in Forms w/PHP HTML

am 22.04.2007 01:23:08 von jcage

Is there any tutorials online for sending email through forms? I can
send an email as well as write to my MySQL database from home with the
following code but not at work. I think there might be something I'm
missing header-wise that keeps me from making this work on my work
system. I'm using Apache 1.3, PHP 4.1 (best the IT guys could do
though I'm using 5.x at home), and MySQL as the database. Thanks VERY
much for any help or pointers to a good tutorial. I'm trying to
provide an input form that writes to the database as well as emails
the recipient letting them know there's been activity. Thanks, John

My form PHP code is as follows:

Input form 1:

























Date: maxlength="16" value=""> td>
Your Name:* type="text" name="name" size="14" maxlength="20" value="">
Subject:* type="text" name="subject" size="14" maxlength="20" value="">
Message For:*

Message:*


td>






Input form 2:

style="font-size:18">


align=center border=8">

face=arial color=bright white>
require_once('generic_connect.php');
$DBName = "messages";
$table = "messages_tbl";

$id = $_POST['id'];
$date = $_POST['date'];
$name = $_POST['name'];
$subject = $_POST['subject'];
$to = $_POST['to'];
$text = $_POST['text'];

mysql_connect($DBhost,$DBuser,$DBpass) or die("Unable to connect
to database"); // make connection to database
mysql_select_db($DBName) or die("Unable to select database
$DBName"); // select database
$sqlquery = "INSERT INTO $table VALUES('$id', '$date', '$name',
'$subject', '$to', '$text')";
if ($results = mysql_query($sqlquery)) {

$to = stripslashes($to)."\r\n";
$subject = stripslashes($subject);
$text = stripslashes($text);
mail($to, $subject, $text, "From: admin@work.com");
}

mysql_close();
print "

";
print "


You Just Entered This Information into the
Database

";
print "Date: $date

Your Name: $name

Message For:$to

Subject:
$subject

Message:$text



";
?>





portion of php.ini file that deals with mail configuration:

[mail function]
; For Win32 only.
SMTP = mail.work.com
smtp_port = 25