【发布时间】:2019-10-27 01:53:35
【问题描述】:
我一直在网上搜索以寻找答案,我已经能够拼凑起来,但是我正在尝试创建一个 HTML/PHP 页面,供用户通过网站提交参赛作品链接或附加图片/视频。我还有一个下拉菜单可以选择它的类别。
我想做的是在电子邮件正文及其网站链接中包含下拉菜单选择。不幸的是,我不知道如何做到这一点。我在 HTML 方面做得很好,但是我只对 PHP 有一个基本的了解。我找到了一个 HTML 和 PHP 的电子邮件表单模板,它允许附加附件,但我无法弄清楚如何将下拉列表中的选择添加到我添加到 HTML 代码的电子邮件正文中。
有人可以帮忙吗?
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>HTML5 Contact Form With File Upload - reusable form</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<link href="https://fonts.googleapis.com/css?family=Montserrat" rel="stylesheet">
<link rel="stylesheet" href="form.css" >
<script src="form.js"></script>
</head>
<body >
<div class="container">
<div id="form-main">
<div id="form-div">
<form class="montform" enctype=""multipart/form-data"" id="reused_form">
<p class="name"><input class="feedback-input" id="name" name="name" placeholder="Name" required="" type="text" /></p>
<p class="email"><input class="feedback-input" id="email" name="email" placeholder="Email" required="" type="text" /></p>
<p><select name="category">
<option selected="selected" value="Best Static">Best Static</option>
<option value="Best Animatronic">Best Animatronic</option>
<option value="Best Display">Best Display</option>
<option value="Best Walk Through">Best Walkthrough</option>
<option value="Best Hauntcycled">Best Hauntcycled</option></select></p>
<p class="text"><textarea class="feedback-input" id="comment" name="message" placeholder="Message"></textarea></p>
<p class="file"><input class="feedback-input" id="file" name="image" type="file" /></p>
<div class="submit"><button class="button-blue" type="submit">SUBMIT</button>
<div class="ease"> </div>
</div>
</form>
<div id="error_message" style="height: 100%; width: 100%; display: none">
<h4>Error</h4>
Sorry there was an error sending your form.</div>
<div id="success_message" style="height: 100%; width: 100%; display: none">
<h2>Success! Your Message was Sent Successfully.</h2>
</div>
</div>
</div>
</div>
</body>
</html>
现在对于我在网上找到的代码中包含的 PHP:
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
/*
Tested working with PHP5.4 and above (including PHP 7 )
*/
require_once './vendor/autoload.php';
use FormGuide\Handlx\FormHandler;
$pp = new FormHandler();
$validator = $pp->getValidator();
$validator->fields(['name','email'])->areRequired()->maxLength(50);
$validator->field('email')->isEmail();
$validator->fields(['message','category'])->maxLength(6000);
$pp->attachFiles(['image']);
$pp->sendEmailTo('someone@gmail.com'); // ← Your email here
echo $pp->process($_POST);
【问题讨论】:
-
PHP docs for
mail()应该拥有您开始所需的一切。