Ir para conteúdo
  • Cadastre-se
  • 0

Formulário de Contato


Arkond

Pergunta

Olá pessoal!

Estou com um site que já está todo pronto, porém acho que está errado meu arquivo .php no formulário de contrato, já configurei como "imagino" estar certo, mais não  vai, espero que um par de olhos possa me ajudar, desde já agradeço muito! Código .php abaixo:

 

<?php

class Ajax_Contact_Form {
    
    protected $address_destination = '[email protected]';

   
    protected $message_subject = 'Message from AJAX Contact Form';

   
    protected $strings = array(
        'body'              => '
            <h1>{{subject}}</h1>
            <p><strong>From:</strong> {{name}}</p>
            <p><strong>E-Mail:</strong> {{email}}</p>
            <p><strong>Message:</strong> <br> {{message}}</p>',
        'success'           => 'Thank You! I will be in touch.',
        'error'             => 'Sorry there was an error sending your message. Please check server PHP mail configuration.',
        'demo'              => 'This is demo message from PHP',
        'header_injection'  => 'Header injection detected.',
        'enter_name'        => 'Please enter your name.',
        'enter_email'       => 'Please enter a valid email address.',
        'enter_message'     => 'Please enter your message.',
        'ajax_only'         => 'Allowed only XMLHttpRequest.',
    );

   
    protected $demo = true;

   
    public function __construct() {
        
        if ( $this->demo ) {
            $this->successHandler('demo');
        }

        // Ajax check.
        if ( ! isset( $_SERVER['HTTP_X_REQUESTED_WITH'] ) || 'XMLHttpRequest' !== $_SERVER['HTTP_X_REQUESTED_WITH'] ) {
            $this->errorHandler('ajax_only');
        }

        // Get post data.
        $name    = stripslashes(trim($_POST['name']));
        $email   = stripslashes(trim($_POST['email']));
        $message = stripslashes(trim($_POST['message']));

        // Sanitize fields.
        $name = filter_var($name, FILTER_SANITIZE_STRING);
        $email = filter_var($email, FILTER_SANITIZE_EMAIL);
        $message = filter_var($message, FILTER_SANITIZE_STRING);
        $message = nl2br($message, false); // false gives <br>, true gives <br />

        // Check header injection.
        $pattern = '/[\r\n]|Content-Type:|Bcc:|Cc:/i';
        if ( preg_match($pattern, $name) || preg_match($pattern, $email) ) {
            $this->errorHandler('header_injection');
        }

        // Validate email.
        $isEmailValid = filter_var($email, FILTER_VALIDATE_EMAIL);

        // Check if name has been entered.
        if ( ! $name ) {
            $this->errorHandler('enter_name');
        }

        // Check if email has been entered and is valid.
        if ( ! $isEmailValid || ! $email ) {
            $this->errorHandler('enter_email');
        }

        // Check if message has been entered.
        if ( ! $message ) {
            $this->errorHandler('enter_message');
        }

        // Prepare headers.
        $headers  = 'MIME-Version: 1.1' . PHP_EOL;
        $headers .= 'Content-type: text/html; charset=utf-8' . PHP_EOL;
        $headers .= "From: $name <$email>" . PHP_EOL;
        $headers .= "Return-Path: $this->address_destination" . PHP_EOL;
        $headers .= "Reply-To: $email" . PHP_EOL;
        $headers .= "X-Mailer: PHP/". phpversion() . PHP_EOL;

        // Prepare body.
        $body = $this->getString('body');
        $body = $this->template( $body, array(
            'subject' => $this->message_subject,
            'name'    => $name,
            'email'   => $email,
            'message' => $message,
        ) );
        $body = "
        <!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">
        <html>
            <head>
                <title>{$this->message_subject}</title>
                <meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />
                <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"/>
            </head>
            <body>{$body}</body>
        </html>

 

 

html.JPG

Kaio Alencar

Link para o comentário
Compartilhar em outros sites

0 respostass a esta questão

Posts recomendados

Até agora não há respostas para essa pergunta

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Visitante
Responder esta pergunta...

×   Você colou conteúdo com formatação.   Remover formatação

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Processando...
  • Registre-se

    Faça parte da maior e  mais antigas comunidades sobre Lineage2 da América Latina.





×
×
  • Criar Novo...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.