[英]PHP /HTML BOOTSTRAP 4 Contact Us Web form
Hi I am learner and i want to use dynamic contact us form on my site but facing issue when trying to make it dynamic using HTML/PHP/ PEAR I am confused here how to write php script for actual form that work with Mochahost嗨,我是学习者,我想在我的网站上使用动态联系我们表单,但在尝试使用 HTML/PHP/PEAR 使其动态化时遇到问题我在这里很困惑如何为与 Mochahost 一起使用的实际表单编写 php 脚本
Test is working perfectly on the server but my issue is i don't know how to write the php script to make it dynamic ( actual message getting from web page )测试在服务器上运行良好,但我的问题是我不知道如何编写 php 脚本以使其动态(实际消息来自 web 页面)
<?php
error_reporting(E_ALL ^ E_NOTICE ^ E_DEPRECATED ^ E_STRICT);
require_once "Mail/Mail-1.4.1/Mail.php";
$host = "mail.example.com";
$username = "siri@example.com";
$password = "********";
$port = "2525";
$to = "?";
$email_from = " how dynamical i can see the emails here ?";
$email_subject = "how i can get the subject from my email form that user fielded? " ;
$email_body = "want to see the message user types in my inbox ?" ;
$email_address = "?";
$headers = array ('From' => $email_from, 'To' => $to, 'Subject' => $email_subject, 'Reply-To' => $email_address);
$smtp = Mail::factory('smtp', array ('host' => $host, 'port' => $port, 'auth' => true, 'username' => $username, 'password' => $password));
$mail = $smtp->send($to, $headers, $email_body);
if (PEAR::isError($mail)) {
echo("<p>" . $mail->getMessage() . "</p>");
} else {
echo("<p>Message successfully sent!</p>");
}
?>
What you want to do is create an HTML "Contact Us" page with a <form>
element, giving it a path and a method to your PHP page where you will handle all the information they put in, here is a tiny example to get you started您要做的是创建一个带有
<form>
元素的 HTML“联系我们”页面,为其提供 PHP 页面的路径和方法,您将在其中处理他们输入的所有信息,这是一个小例子你开始了
contactUs.html:联系我们。html:
<form action="contactUs.php" method="POST">
<input type="text" name="username" />
<input type="password" name="userPassword" />
<input type="email" name="userEmail" />
</form>
contactUs.php:联系我们。php:
<?php
$username = $_POST["userName"]; //We access the name attributes from our HTML form here
$password = $_POST["userPassword"];
$email = $_POST["userEmail"];
?>
And so forth, of course on your HTML page you want to style the form, and add any other information that you are asking from your visitor, and on your PHP page you want to add a "Thank you" message or some message that tells your visitor that their request was successful since it will redirect them away from your contactUs.html page and to your contactUs.php page, although there are ways of accomplishing the same task while staying on the same page.依此类推,当然在 HTML 页面上,您要设置表单样式,并添加您向访问者询问的任何其他信息,在 PHP 页面上,您要添加“谢谢”消息或一些告诉您的访问者他们的请求是成功的,因为它会将他们从您的contactUs.html页面重定向到您的contactUs.php页面,尽管有一些方法可以在保持在同一页面上的同时完成相同的任务。
<?php
error_reporting(E_ALL ^ E_NOTICE ^ E_DEPRECATED ^ E_STRICT);
require_once "Mail/Mail-1.4.1/Mail.php";
$name = $_POST["Full_Name"];
$email = $_POST["email"];
$subject = $_POST["subject"];
$message = $_POST["message"];
$host = "mail.example.com";
$username = "xyz@example.com";
$password = "abc";
$port = "25";
$to = "xyz@example.com";
$reply_to = "xyz@example.com";
$headers = array ('From' => $email, 'To' => $to, 'Subject' => $subject, 'Reply-To' => $reply_to);
$smtp = Mail::factory('smtp', array ('host' => $host, 'port' => $port, 'auth' => true, 'username' => $username, 'password' => $password));
$mail = $smtp->send($to, $headers, $message);
if (PEAR::isError($mail)) {
echo("<p>" . $mail->getMessage() . "</p>");
} else {
echo("<p>Message successfully sent!</p>");
}
?>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.