![]() |
|
PHP Developer [Help needed] - Printable Version +- Sinisterly (https://sinister.li) +-- Forum: Coding (https://sinister.li/Forum-Coding) +--- Forum: PHP (https://sinister.li/Forum-PHP) +--- Thread: PHP Developer [Help needed] (/Thread-PHP-Developer-Help-needed) |
PHP Developer [Help needed] - Cyber Warrior - 03-11-2017 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. RE: PHP Developer [Help needed] - SxTxN - 03-11-2017 I'm not good with PHP but I can tell you that this won't work without JavaScript. RE: PHP Developer [Help needed] - Num5kull - 03-11-2017 Php mail functions link: http://php.net/manual/en/function.mail.php Some examples: http://www.html-form-guide.com/email-form/php-form-to-email.html http://www.freecontactform.com/email_form.php RE: PHP Developer [Help needed] - Cyber Warrior - 03-11-2017 (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. RE: PHP Developer [Help needed] - Eclip$e - 03-12-2017 (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 RE: PHP Developer [Help needed] - Weg - 04-28-2017 (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. RE: PHP Developer [Help needed] - Darkbyte - 04-28-2017 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... ![]() 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
RE: PHP Developer [Help needed] - Noob - 04-28-2017 (04-28-2017, 07:53 PM)Darkbyte Wrote: Edit the html file...... HQ post!
|