用HTML/PHP创建电子邮件表单,并在电子邮件中包括下拉选择、消息区域和附件



我一直在网上搜索答案,我已经能够把事情拼凑在一起,但我正在尝试创建一个HTML/PHP页面,供用户通过网站链接或附加的pic/vid提交参赛作品。我还有一个下拉菜单来选择它的类别。

我想做的是在电子邮件的正文中包含下拉菜单选项以及他们的网站链接。不幸的是,我不知道如何做到这一点。我擅长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="&quot;multipart/form-data&quot;" 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">&nbsp;</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 FormGuideHandlxFormHandler;

$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);

您找到的这段代码用于laravel。您首先需要了解PHP是如何工作的,才能了解像laravel这样的PHP框架的工作原理。访问:https://www.w3schools.com/php/php_forms.asp了解如何将值从一个页面传递到另一个页面、捕获表单数据以及使用传递的数据运行SQL查询。您可以查看任何php注册示例来了解这一点。我建议您先学习PHP SQL面向对象的方法,然后再学习PHP PDO。代码问题:1.您的表单没有任何操作和方法2.您的PHP无法捕获数据(因为laravel使用请求类来自动验证和存储数据(

最新更新