Pesquisar na Comunidade
Mostrando resultados para as tags ''erro em formulario''.
Encontrado 1 registro
-
Boa tarde tudo bem ? alguém poderia me ajuda? estou com problemas com esse formulario ele não esta enviando <?php /*-------------------------------------------------------------------------------------------*/ /* This script takes values from the Universe Contact Form and send it to a specified email /* TAKE CARE WHEN EDIT IT - If you need further assistance on how to setup it get in touch * through our profile on Theme Forest /*-------------------------------------------------------------------------------------------*/ if($_POST) { $to_Email = "guitaracousitc@hotmail.com"; // Replace with recipient email address $subject = 'Mensagem de formulário do site'; //Subject line for emails, you can alter it //check if its an ajax request, exit if not if(!isset($_SERVER['HTTP_X_REQUESTED_WITH']) AND strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) != 'xmlhttprequest') { //exit script outputting json data $output = json_encode( array( 'type'=>'error', 'text' => 'Request must come from Ajax' )); die($output); } //check $_POST vars are set, exit if any missing if(!isset($_POST["firstName"]) || !isset($_POST["subject"]) || !isset($_POST["userEmail"]) || !isset($_POST["userMessage"])) { $output = json_encode(array('type'=>'error', 'text' => 'Input fields are empty!')); die($output); } //Sanitize input data using PHP filter_var(). $first_Name = filter_var($_POST["firstName"], FILTER_SANITIZE_STRING); $user_subject = filter_var($_POST["subject"], FILTER_SANITIZE_EMAIL); $user_Email = filter_var($_POST["userEmail"], FILTER_SANITIZE_STRING); $user_Message = filter_var($_POST["userMessage"], FILTER_SANITIZE_STRING); //additional php validation if(strlen($first_Name)<4) // If length is less than 4 it will throw an HTTP error. { $output = json_encode(array('type'=>'error', 'text' => 'Nome curto ou campo vazio!')); die($output); } if(strlen($user_subject)<4) // If length is less than 4 it will throw an HTTP error. { $output = json_encode(array('type'=>'error', 'text' => 'Nome curto ou campo vazio!')); die($output); } if(!filter_var($user_Email, FILTER_VALIDATE_EMAIL)) //email validation { $output = json_encode(array('type'=>'error', 'text' => 'Por favor insira um e-mail valido!')); die($output); } if(strlen($user_Message)<5) //check emtpy message { $output = json_encode(array('type'=>'error', 'text' => 'Too short message! Please enter something.')); die($output); } //proceed with PHP email. $headers = 'From: '.$user_Email.'' . "\r\n" . 'Reply-To: '.$user_Email.'' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); // send mail $sentMail = @mail($to_Email, $subject, $user_Message .' - Email sent by: '.$first_Name. ' '.$user_subject, $headers); if(!$sentMail) { $output = json_encode(array('type'=>'error', 'text' => 'Could not send mail! Please check your PHP mail configuration.')); die($output); }else{ $output = json_encode(array('type'=>'message', 'text' => 'Hi '.$first_Name .'. Thank you for your email.')); die($output); } } ?>e os campos do formulario são esses <form action="assets/includes/contact-form.php" method="post" class="form-group"> <div class="row"> <div class="col-md-6 col-sm-6 col-xs-12"> <input type="text" name="name" id="name" placeholder="Nome (obrigatório)"> </div> <div class="col-md-6 col-sm-6 col-xs-12"> <input type="email" name="email" id="email" placeholder="Email (obrigatório)"> </div> <div class="col-md-12 col-sm-12 col-xs-12"> <input type="text" name="subject" id="subject" placeholder="Assunto"> </div> <div class="col-md-12 col-sm-12 col-xs-12"> <textarea name="message" id="message" cols="39" rows="4" placeholder="Sua Mensagem"></textarea> </div> <div class="col-md-12 col-sm-12 col-xs-12"> <input name="submit" type="submit" id="submit" tabindex="5" value="Enviar Mensagem" class="comment-submit t-btn t-btn-primary"> </div> </div> </form> <!-- .form-group -->obrigado.
- 4 respostas
-
- erro em formulario
- ajax
-
(e %d mais)
Tags: