html - PHP Contact Form 403 Error -
in process of setting website myself, i've hit bit of road block php contact form. believe coded correctly, whenever upload site , try use contact form "page forbidden 403". i'm using hostinger way, i've set permissions of public_html file 755. not sure problem be. included code, appreciated.
contact code of html index:
<div class="row stay-behind" id="contact"> <h4 class="right-name">contact</h4> <div class="col-md-1"></div> <div class="col-sm-12 col-md-4 feature-image"><img alt="vx1k" height="510" src="images/ux/004.jpg" width="374"> <img alt="vx1k" class="mobile-only" src="images/ux/mobile/004.jpg"></div> <div class="col-sm-12 col-md-6 main"> <h3 class="title">contact</h3> <form class="contact-form" id="contactform" novalidate method="post" action="public_html/mail/contact_me.php"> <div id="form-alert"></div> <div class="form-group"> <input class="form-control" id="name" name="name" placeholder="name" type="name"> </div> <div class="form-group"> <input class="form-control" id="email" name="email" placeholder="email" type="email"> </div> <textarea class="form-control" id="message" placeholder="message" rows="3"></textarea> <input class="btn btn-block btn-primary" id="btnsubmit" name="submit" type="submit" value="send"> </form> </div> <div class="col-md-1"></div>
code php file.
<?php function validate() { // check empty fields if (empty($_post['name']) || empty($_post['email']) || empty($_post['message']) || !filter_var($_post['email'], filter_validate_email)) { return false; } else return true; } function sendemail($to = 'noreply@vx1k.com') { if (validate() == true) { $name = $_post['name']; $email_address = $_post['email']; $message = $_post['message']; // create email , send message $email_subject = "website contact form: $name"; $email_body = "you have received new message website contact form.\n\n" . "here details:\n\nname: $name\n\nemail: $email_address\n\nmessage:\n$message"; $headers = "from: noreply@vx1k.com\n"; $headers.= "reply-to: $email_address"; // send true on successful send. // send false if failed return (mail($to, $email_subject, $email_body, $headers)) ? true : false; } else // invalid inputs return 'err'; } // apply function(s). true, false, or err $send = sendemail(); // on return, can echo result if ($send == 'err') echo 'invalid fields.'; elseif ($send == false) echo 'an error occurred.'; else echo 'email sent successfully.'; ?>
Comments
Post a Comment