Reputation: 21
I have been searching all over the net looking for an answer and I've been able to piece things together, however I am trying to create an HTML/PHP page for the user to submit an entry into a contest via a website link or attached pic/vid. I also have a drop down menu to choose which category it's for.
What I'd like to do is have the drop down menu selection included in the body of the email as well as their website link. Unfortunately I'm at a loss for how to accomplish this. I'm good when it comes to HTML, however I only have a basic understanding of PHP. I found an email form template of HTML and PHP that allows for an attachment, but I cannot figure out for the life of me how to add the selection from the drop down into the body of the email that I added to the HTML code.
Can anyone assist?
<!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>
And now for the PHP that was included with the code I found online:
<?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('[email protected]'); // ← Your email here
echo $pp->process($_POST);
Upvotes: 0
Views: 717
Reputation: 44
The piece of code you have found is for laravel. You need to understand how PHP works first to learn any PHP framework like laravel works. Visit: https://www.w3schools.com/php/php_forms.asp Learn how to pass values from one page to another, catch form data and run SQL queries using passed data. You can check for any php registration example to understand that. I would recommend you to learn the PHP SQL Object oriented approach then PHP PDO. Issues with code: 1. Your form does not have any action and method 2. You PHP does not catch data (becuase laravel use request classes to auto validate and store data)
Upvotes: 1