【问题标题】:Creating email form in HTML/PHP and include drop down selection, message area, and attachment in email在 HTML/PHP 中创建电子邮件表单并在电子邮件中包含下拉选择、消息区域和附件
【发布时间】: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="&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 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 html email


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 2017-05-17
    • 1970-01-01
    • 2011-10-07
    • 2011-06-22
    • 2021-04-15
    • 2010-11-20
    • 2021-02-06
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多