Login Register






PHP Developer [Help needed] filter_list
Author
Message
PHP Developer [Help needed] #1
Hello dear PHP developers, I need help wih one simple PHP code, because I haven't learned PHP yet. I need PHP mail function for my HTML code down bellow:

Code:
<form> <label for="name">First and Last Name</label><br> <input type="text" name="name" id="name" placeholder="First and Last Name"><br> <label for="email">Email</label><br> <input type="text" name="email" id="email" placeholder="Your email"><br> <div id="report"> <fieldset> <legend style="font-size: 18px;">Choose</legend> <input type="checkbox" name="translation" id="translation"> <label for="translation">Translation</label> <input type="checkbox" name="quality" id="quality"> <label for="quality">Quality</label> <input type="checkbox" name="else" id="else"> <label for="else">Else</label><br> </fieldset> </div> <label for="tv_show">TV Show Name</label><br> <input type="text" name="tv_show" id="tv_show" placeholder="TV Show"><br> <label for="season">Season</label><br> <input type="text" name="season" id="season" placeholder="Season"><br> <label for="episode">Episode</label><br> <input type="text" name="episode" id="episode" placeholder="Episode"><br> <label for="message">Additional informations</label><br> <textarea name="message" id="message" placeholder="Message..."></textarea><br> <input type="submit" value="Send" style="font-size: 18px;"> </form>

If someone could help me, I would appreciate it. Cheers.

Reply

RE: PHP Developer [Help needed] #2
I'm not good with PHP but I can tell you that this won't work without JavaScript.

Reply

RE: PHP Developer [Help needed] #3
Php mail functions link:
http://php.net/manual/en/function.mail.php

Some examples:
http://www.html-form-guide.com/email-for...email.html
http://www.freecontactform.com/email_form.php
[Video: https://www.youtube-nocookie.com/embed/bOkD-HSOmyI]
[bt][1B1sXX2sHhvUrf9Ga9MKcH5e9T4xgN13tB]

Reply

RE: PHP Developer [Help needed] #4
(03-11-2017, 10:58 PM)SxTxN Wrote: I'm not good with PHP but I can tell you that this won't work without JavaScript.

Well maybe, but I'm looking php function first.
(This post was last modified: 03-11-2017, 11:40 PM by Cyber Warrior.)

Reply

RE: PHP Developer [Help needed] #5
(03-11-2017, 10:58 PM)SxTxN Wrote: I'm not good with PHP but I can tell you that this won't work without JavaScript.

This could work with php or javascript.

Sorry for not contributing op just wanted to let you know you can do it with php.
Look at what Num5kull has posted gl
(This post was last modified: 03-12-2017, 05:34 AM by Eclip$e.)
cool kid


Reply

RE: PHP Developer [Help needed] #6
(03-11-2017, 10:58 PM)SxTxN Wrote: I'm not good with PHP but I can tell you that this won't work without JavaScript.

It will work without javascript if the form's action is a php script. When the form is submitted, PHP receives all of the form data in the $_POST superglobal.
(This post was last modified: 04-28-2017, 06:48 AM by Weg.)

Reply

RE: PHP Developer [Help needed] #7
Edit the html file......

Code:
<form action='./send_email.php' method='post'> <label for="name">First and Last Name</label><br> <input type="text" name="name" id="name" placeholder="First and Last Name"><br> <label for="email">Email</label><br> <input type="text" name="email" id="email" placeholder="Your email"><br> <div id="report"> <fieldset> <legend style="font-size: 18px;">Choose</legend> <input type="checkbox" name="translation" id="translation"> <label for="translation">Translation</label> <input type="checkbox" name="quality" id="quality"> <label for="quality">Quality</label> <input type="checkbox" name="else" id="else"> <label for="else">Else</label><br> </fieldset> </div> <label for="tv_show">TV Show Name</label><br> <input type="text" name="tv_show" id="tv_show" placeholder="TV Show"><br> <label for="season">Season</label><br> <input type="text" name="season" id="season" placeholder="Season"><br> <label for="episode">Episode</label><br> <input type="text" name="episode" id="episode" placeholder="Episode"><br> <label for="message">Additional informations</label><br> <textarea name="message" id="message" placeholder="Message..."></textarea><br> <input type="submit" value="Send" style="font-size: 18px;"> </form>


Make a file send_email.php
Code:
<?php //Fist check everything is set in the form... if (!isset($_POST["name"]) || $_POST["name"] == "") {  print "Error , name field is empty";  exit(); } if (!isset($_POST["email"]) || $_POST["email"] == "") {  print "Error , email field is empty";  exit(); } if (!isset($_POST["name"]) || $_POST["name"] == "") {  print "Error , name field is empty";  exit(); } $reportchoice = ""; //Set report choice to empty if (isset($_POST["translation"])) {  $reportchoice =  "translation"; } elseif (isset($_POST["quality"])) {  $reportchoice =  "quality"; } elseif (isset($_POST["else"])) {  $reportchoice =  "else"; } if ($reportchoice == "") //No reportchoice was set if this is still empty :/ {  print "Please choose a reason for reporting this";  exit(); } if (!isset($_POST["tv_show"]) || $_POST["tv_show"] == "") {  print "Error , Tv show name field is empty";  exit(); } if (!isset($_POST["season"]) || $_POST["season"] == "") {  print "Error , season field is empty";  exit(); } if (!isset($_POST["episode"]) || $_POST["episode"] == "") {  print "Error , episode field is empty";  exit(); } if (!isset($_POST["message"]) || $_POST["message"] == "") {  print "Error , message field is empty";  exit(); } //If we got here everything is good so lets construct our email $emailsubject = "Email from " . $_POST["name"] . " reporting a problem with " . $reportchoice . " in  " . $_POST["tv_show"] . " S" . $_POST["season"] . "E" . $_POST["episode"] ; $emailbody = $_POST["message"]; $emailbody = wordwrap($emailbody, 70, "\r\n"); // In case any of our lines are larger than 70 characters, we should use wordwrap() mail('yoursupportemail@yourdomain.com', $emailsubject, $emailbody); // Send print "Email was sent"; ?>


Assuming this was filled out...

[Image: il0354y.png]

You would receive a email with this subject...

Email from Joe Bloggs reporting a problem with translation in The flash S2E1

and the message
This show started out great but now it sucks wtf?

hope that helps Smile

[+] 1 user Likes Darkbyte's post
Reply

RE: PHP Developer [Help needed] #8
(04-28-2017, 07:53 PM)Darkbyte Wrote: Edit the html file......

Code:
<form action='./send_email.php' method='post'> <label for="name">First and Last Name</label><br> <input type="text" name="name" id="name" placeholder="First and Last Name"><br> <label for="email">Email</label><br> <input type="text" name="email" id="email" placeholder="Your email"><br> <div id="report"> <fieldset> <legend style="font-size: 18px;">Choose</legend> <input type="checkbox" name="translation" id="translation"> <label for="translation">Translation</label> <input type="checkbox" name="quality" id="quality"> <label for="quality">Quality</label> <input type="checkbox" name="else" id="else"> <label for="else">Else</label><br> </fieldset> </div> <label for="tv_show">TV Show Name</label><br> <input type="text" name="tv_show" id="tv_show" placeholder="TV Show"><br> <label for="season">Season</label><br> <input type="text" name="season" id="season" placeholder="Season"><br> <label for="episode">Episode</label><br> <input type="text" name="episode" id="episode" placeholder="Episode"><br> <label for="message">Additional informations</label><br> <textarea name="message" id="message" placeholder="Message..."></textarea><br> <input type="submit" value="Send" style="font-size: 18px;"> </form>


Make a file send_email.php
Code:
<?php //Fist check everything is set in the form... if (!isset($_POST["name"]) || $_POST["name"] == "") {  print "Error , name field is empty";  exit(); } if (!isset($_POST["email"]) || $_POST["email"] == "") {  print "Error , email field is empty";  exit(); } if (!isset($_POST["name"]) || $_POST["name"] == "") {  print "Error , name field is empty";  exit(); } $reportchoice = ""; //Set report choice to empty if (isset($_POST["translation"])) {  $reportchoice =  "translation"; } elseif (isset($_POST["quality"])) {  $reportchoice =  "quality"; } elseif (isset($_POST["else"])) {  $reportchoice =  "else"; } if ($reportchoice == "") //No reportchoice was set if this is still empty :/ {  print "Please choose a reason for reporting this";  exit(); } if (!isset($_POST["tv_show"]) || $_POST["tv_show"] == "") {  print "Error , Tv show name field is empty";  exit(); } if (!isset($_POST["season"]) || $_POST["season"] == "") {  print "Error , season field is empty";  exit(); } if (!isset($_POST["episode"]) || $_POST["episode"] == "") {  print "Error , episode field is empty";  exit(); } if (!isset($_POST["message"]) || $_POST["message"] == "") {  print "Error , message field is empty";  exit(); } //If we got here everything is good so lets construct our email $emailsubject = "Email from " . $_POST["name"] . " reporting a problem with " . $reportchoice . " in  " . $_POST["tv_show"] . " S" . $_POST["season"] . "E" . $_POST["episode"] ; $emailbody = $_POST["message"]; $emailbody = wordwrap($emailbody, 70, "\r\n"); // In case any of our lines are larger than 70 characters, we should use wordwrap() mail('yoursupportemail@yourdomain.com', $emailsubject, $emailbody); // Send print "Email was sent"; ?>


Assuming this was filled out...

[Image: il0354y.png]

You would receive a email with this subject...

Email from Joe Bloggs reporting a problem with translation in The flash S2E1

and the message
This show started out great but now it sucks wtf?

hope that helps Smile

HQ post! Smile

Reply