在表单中使用带有PHP HTML的SendMail [英] Using SendMail in Forms w/PHP HTML

查看:58
本文介绍了在表单中使用带有PHP HTML的SendMail的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有在线教程通过表格发送电子邮件?我可以发送电子邮件以及从家里写入我的MySQL数据库并使用

代码但不在工作中。我想可能会有一些东西我不会在标题方面丢失,这使我无法在我的工作中完成这项工作

系统。我正在使用Apache 1.3,PHP 4.1(尽管我在家里使用5.x,但最好的IT人员可以做到b $ b)和MySQL作为数据库。非常感谢
很多任何帮助或指向一个好的教程。我正在努力为b $ b提供一个写入数据库的输入表单以及电子邮件

收件人让他们知道有活动。谢谢,John


我的表格PHP代码如下:

输入表格1:

< html> ;

< body>

< form method =" post" action =" messaging2.php">

< input type =" hidden"名称= QUOT; ID" value =" NULL">

< center>

< table border =" 8">

< tr> ;

< td>日期:< / td>

< td align =" left">< input type =" text"名称= QUOT;日期" size =" 14"

maxlength =" 16"值= QUOT;< ;? print strftime(%m /%d /%Y%H:%M); ?>">< /

td>

< / tr>

< tr>

< td>您的姓名:< font color = red> *< / font>< / td>< td align =" left">< input

类型= QUOT;文本"命名= QUOT;名称"大小= QUOT; 14'; MAXLENGTH = QUOT; 20" value ="">< / td>

< / tr>

< tr>

< td>主题:< font color = red> *< / font>< / td>< td align =" left">< input

type =" text"命名= QUOT受试者QUOT;大小= QUOT; 14'; MAXLENGTH = QUOT; 20" value ="">< / td>

< / tr>

< tr>

< td>消息:< font color = red> *< / font>< / td>

< td>< select name =" to" style =''width:110px;''>

< option value ="">< / option>

< option value =" ; jo *@lycos.com"> Joe< / option>

< option value =" ra *** @ gmail.com"> Randy< / option>

< / td>

< / tr>

< tr>

< td nowrap>

消息:< font color = red> *< / font>< / div>

< / td>

< td>

< textarea type =" text"命名= QUOT;文本" COLS = QUOT 35 QUOT; rows =" 5">< / textarea>

< / tr>

< / td>

< tr> ;

< td colspan =" 2" align =" center">< input type =" submit" value =" Enter">< /

td>

< / tr>

< / table>

< / form>

< / center>< p>

< / body>

< / html>


输入表格2:

< html>

< font color ="#990099" size =" + 1">< span

style =" font-size:18">< p>

< TABLE cellSpacing = 0 cellPadding = 10 width =" 95%"

align = center border = 8">

< TBODY>< TR>< TD vAlign = top align = left>< P>< FONT

face = arial color = bright white>< b>

<?php

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)或die( 无法连接

到数据库;); //建立与数据库的连接

mysql_select_db($ DBName)或死(无法选择数据库

$ DBName); //选择数据库

$ 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: ad *** @ work.com ");

}


mysql_close();

print"< center>< table border = \" 0 \" width = \" 500 \">< tr>< td>" ;;

print"< p>< font face = \" verdana \\ \\" size = \" + 0 \">

< center>您刚刚将此信息输入

数据库< p>< blockquote>" ;;

打印日期:$ date< p>您的姓名:$ name< p>消息:$ to< p>主题:

$ subject< p> ;消息:$ text< / blockquote>< / td>< / tr>< / table>

< / CENTER>

< / html> " ;;

?>


< / FONT>< / CENTER>< / b>

< ; / H3>< / TD>< / TR>< / TBODY>< / TABLE>

< / html>< p>


处理邮件配置的php.ini文件部分:


[邮件功能]

;仅适用于Win32。

SMTP = mail.work.com

smtp_port = 25

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:
<html>
<body>
<form method="post" action="messaging2.php">
<input type="hidden" name="id" value="NULL">
<center>
<table border="8">
<tr>
<td>Date:</td>
<td align="left"><input type="text" name="date" size="14"
maxlength="16" value="<? print strftime("%m/%d/%Y %H:%M"); ?>"></
td>
</tr>
<tr>
<td>Your Name:<font color=red>*</font></td><td align="left"><input
type="text" name="name" size="14" maxlength="20" value=""></td>
</tr>
<tr>
<td>Subject:<font color=red>*</font></td><td align="left"><input
type="text" name="subject" size="14" maxlength="20" value=""></td>
</tr>
<tr>
<td>Message For:<font color=red>*</font></td>
<td><select name="to" style=''width: 110px;''>
<option value = ""></option>
<option value ="jo*@lycos.com">Joe</option>
<option value ="ra***@gmail.com">Randy</option>
</td>
</tr>
<tr>
<td nowrap>
Message:<font color=red>*</font></div>
</td>
<td>
<textarea type="text" name="text" cols="35" rows="5"></textarea>
</tr>
</td>
<tr>
<td colspan="2" align="center"><input type="submit" value="Enter"></
td>
</tr>
</table>
</form>
</center><p>
</body>
</html>

Input form 2:
<html>
<font color="#990099" size="+1"><span
style="font-size:18"><p>
<TABLE cellSpacing=0 cellPadding=10 width="95%"
align=center border=8">
<TBODY><TR><TD vAlign=top align=left><P><FONT
face=arial color=bright white><b>
<?php
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: ad***@work.com");
}

mysql_close();
print "<center><table border=\"0\" width=\"500\"><tr><td>";
print "<p><font face=\"verdana\" size=\"+0\">
<center>You Just Entered This Information into the
Database<p><blockquote>";
print "Date: $date<p>Your Name: $name<p>Message For:$to<p>Subject:
$subject<p>Message:$text</blockquote></td></tr></table>
</CENTER>
</html>";
?>

</FONT></CENTER></b>
</H3></TD></TR></TBODY></TABLE>
</html><p>

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

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

推荐答案

DBName =" messages";
DBName = "messages";


table =" messages_tbl";

table = "messages_tbl";


id =


这篇关于在表单中使用带有PHP HTML的SendMail的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆