我的联系人表单php脚本不工作
您好,我已经为我的网站编写了以下代码,用于与joomla一起创建的联系我们表单。表格会显示在网站上,但我有两个问题 1.“消息部分”的标题位于文本区域框的底部,而不是顶部 2.我不是一个专业的程序员,特别是在PHP方面。当我键入并按submit时,什么也没有发生。我假设我的php不工作我的联系人表单php脚本不工作,php,html,css,joomla,Php,Html,Css,Joomla,您好,我已经为我的网站编写了以下代码,用于与joomla一起创建的联系我们表单。表格会显示在网站上,但我有两个问题 1.“消息部分”的标题位于文本区域框的底部,而不是顶部 2.我不是一个专业的程序员,特别是在PHP方面。当我键入并按submit时,什么也没有发生。我假设我的php不工作 <form id="contact-form" method="post"> <label for="name">اسم</label>
<form id="contact-form" method="post">
<label for="name">اسم</label>
<input type="text" name="name" id="name" value=""/> <br>
<label for="email">ایمیل</label>
<input type="text" name="email" id="email" value="" /><br>
<label for="message">پیام</label>
<textarea name="message" id="message" cols="20" row="50" ></textarea> <br>
<input type="submit" name="submit" value="Submit" id="submit" />
</form>
<style type="text/css">
form
{
display: inline-block;
text-align: center;
font-family: "arial";
border:2px solid gray;
margin: 0px auto;
width: 900px;
height: 550px;
background: #580000;}
input
{
border: 1px solid black;
margin: 10px;
font-size: 15px;
}
textarea
{
border: 1px solid black;
margin: 10px;
font-size: 15px;
resize: none;
width: 200px;
height: 250px;
background: #fff;
}
#submit {
background-color: #000;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
border-radius:6px;
color: #000;
font-family: 'Oswald';
font-size: 15px;
text-decoration: none;
cursor: poiner;
border:none;
}
#submit:hover {
border: none;
background:grey;
box-shadow: 0px 0px 1px #777;
}
</style>
<?php
$ToEmail = 'evelina@jfaproduction.com';
$EmailSubject = 'Site contact form';
$mailheader = "From: ".$_POST["email"]."\r\n";
$mailheader .= "Reply-To: ".$_POST["email"]."\r\n";
$mailheader .= "Content-type: text/html; charset=iso-8859-1\r\n";
$MESSAGE_BODY = "Name: ".$_POST["name"]."";
$MESSAGE_BODY .= "Email: ".$_POST["email"]."";
$MESSAGE_BODY .= "Message: ".nl2br($_POST["message"])."";
mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader) or die ("Failure");
?>
اسم
ایمیل
پیام
形式
{
显示:内联块;
文本对齐:居中;
字体系列:“arial”;
边框:2倍纯色灰色;
保证金:0px自动;
宽度:900px;
高度:550px;
背景:#580000;}
输入
{
边框:1px纯黑;
利润率:10px;
字体大小:15px;
}
文本区
{
边框:1px纯黑;
利润率:10px;
字体大小:15px;
调整大小:无;
宽度:200px;
高度:250px;
背景:#fff;
}
#提交{
背景色:#000;
-moz边界半径:5px;
-webkit边界半径:5px;
边界半径:6px;
颜色:#000;
字体系列:“Oswald”;
字体大小:15px;
文字装饰:无;
光标:poiner;
边界:无;
}
#提交:悬停{
边界:无;
背景:灰色;
盒影:0px 0px 1px#777;
}
这是一个使用Joomla编码标准的模型。我只是以这种方式向您展示,因为您似乎非常热衷于坚持使用Sourcerer
HTML:
<form action="" id="contact-form" method="post">
<label for="name">اسم</label>
<input type="text" name="name" id="name" value=""/> <br>
<label for="email">ایمیل</label>
<input type="text" name="email" id="email" value="" /><br>
<label for="message">پیام</label>
<textarea name="message" id="message" cols="20" row="50" ></textarea> <br>
<input type="submit" name="submit" value="Submit" id="submit" />
</form>
<?php
$mailer = JFactory::getMailer();
$input = JFactory::getApplication()->input;
$post = $input->post;
$submit = $post->get('submit');
if(isset($submit) {
$mailer->setSender($post->get('email'));
$mailer->addRecipient('evelina@jfaproduction.com');
$body = 'Name: ' . $post->get('name');
$body .= 'Email: ' . $post->get('email');
$body .= 'Message: ' . $post->get('message');
$mailer->setSubject('Site contact form');
$mailer->setBody($body);
$send = $mailer->Send();
if ( $send !== true ) {
echo 'Error sending email';
}
else {
echo 'Success!';
}
}
?>
اسم
ایمیل
پیام
PHP:
<form action="" id="contact-form" method="post">
<label for="name">اسم</label>
<input type="text" name="name" id="name" value=""/> <br>
<label for="email">ایمیل</label>
<input type="text" name="email" id="email" value="" /><br>
<label for="message">پیام</label>
<textarea name="message" id="message" cols="20" row="50" ></textarea> <br>
<input type="submit" name="submit" value="Submit" id="submit" />
</form>
<?php
$mailer = JFactory::getMailer();
$input = JFactory::getApplication()->input;
$post = $input->post;
$submit = $post->get('submit');
if(isset($submit) {
$mailer->setSender($post->get('email'));
$mailer->addRecipient('evelina@jfaproduction.com');
$body = 'Name: ' . $post->get('name');
$body .= 'Email: ' . $post->get('email');
$body .= 'Message: ' . $post->get('message');
$mailer->setSubject('Site contact form');
$mailer->setBody($body);
$send = $mailer->Send();
if ( $send !== true ) {
echo 'Error sending email';
}
else {
echo 'Success!';
}
}
?>
请参阅Joomla文档。不想让你失望,但你做的都是错的。Joomla应该遵守一些编码标准和特定方法。如果您不是一名经验丰富的程序员,那么可以在Joomla Extensions目录中查找联系人表单,因为有几十个;)我试过了,它还在工作。当你按submit时,它显示它已提交,但我没有收到任何电子邮件。我知道我不是一个好的程序员,但我使用了一个名为sourcer的扩展,它允许您在文章中键入html、css、php和JavaScript并发布。这就是我所做的,它显示正确。我所需要的就是让我的php工作。你在你当地的环境中运行它吗?可能是因为您的web服务器的任何SMTP设置。。。因为我在自己的服务器上尝试过,邮件已经发送。它不是本地的,我正在Rackspace服务器上运行