Realizar formulario de contacto en html en wordpress

Tengo un formulario de contacto en html en una pagina de wordpress, el contact.php que es el action del form, esta en la raiz pero cuando le doy al boton de enviar me da un error 500, a que se debe este error?

el contact.php que es donde enviamos el correo etc, ha de estar en un sitio especifico?

Codigo html que tengo en una pagina:

<form action="contact_lawyers-nuevalp.php" name="contactform" class="form" method="post">
<p><span class="usuario"></span><input id="name" class="form-control" type="text" name="first_name" placeholder="Enter your Name"> </p>
<p><span class="email"></span><input id="email" class="form-control" type="text" name="email" placeholder="Enter your Email"> </p>
<p><span class="telefono-form"></span><input id="phone" class="form-control" type="text" name="phone" placeholder="Enter your Phone Number"> </p>
<p><textarea id="comments" class="form-control" name="message" rows="6" placeholder="Hi, I would like to know ..."></textarea></p>
<p><input type="submit" value="Get a Free Consultation" id="submit"></p>
<p><input type="hidden" id="gclid_field" name="gclid_field" value=""></p>
</form>

Codigo PHP que envia el correo:

<head>

    <!-- Basic -->
    <meta charset="utf-8">
    <title>Carbray</title>
    <meta name="author" content="DSA79">
    <meta name="norobots" content="noindex,nofollow">
    <meta name="keywords" content="responsive, html5 template, one page, landing, startup, business, company, corporate, creative">
    <meta name="description" content="Crossway - Startup Landing Page Template">        

    <!-- Libs CSS -->
    <link href="css/style.css" rel="stylesheet" type="text/css" />
    <link href="css/bootstrap.css" rel="stylesheet" type="text/css" />

    <!-- Google Fonts -->   
    <link href='http://fonts.googleapis.com/css?family=Lato:400,900italic,900,700italic,400italic,300italic,300,100italic,100' rel='stylesheet' type='text/css'>


</head>

<body>

    <div id="contentForm">
<?php
session_start();
        header('Content-Type: text/html; charset=utf-8');

        if(isset($_POST['email'])) {


            // EDIT THE 2 LINES BELOW AS REQUIRED

            $email_to = "aitor.udabe@carbray.es";

            $email_subject = "Landing English Lawyers 3.0";
             $email_subject_client = "Thank you for contacting us.";

            $headers_cliente = "Content-Type: text/html; charset=UTF-8\n";  //Con esta cabecera lo que hacemos es que el contenido html se vea 
            $_SESSION['nombre'] = $_POST['first_name']; // required 
            $_SESSION['email'] = $_POST['email']; // required
            $_SESSION['phone'] = $_POST['phone']; // required
            $_SESSION['mensaje']= $_POST['message']; // required
            $_SESSION['gclid'] = $_POST['gclid_field'];//obtenemos el gclid del campo gclid-field
            $landingP=$_SERVER['HTTP_REFERER'];//obtenemos la ruta de donde viene por las cabeceras http        



            $email_message = "Form details below.\n\n";


            function clean_string($string) {
                $bad = array("content-type","bcc:","to:","cc:","href");
                return str_replace($bad,"",$string);
            }


            $email_message .= "Name: ".clean_string($_SESSION['nombre'])."\n";
            $email_message .= "Email Address: ".clean_string($_SESSION['email'])."\n";
            $email_message .= "Phone: ".clean_string($_SESSION['phone'])."\n";
            $email_message .= "Message: ".clean_string($_SESSION['mensaje'])."\n";

            $email_message2 .= "
             <!DOCTYPE html> 
            <html> 
                     <head> 
                           <meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'> 
                           <title>Enviar email</title>
                        <style>
                            <!--/* Font Definitions */
                                @font-face
                                    {font-family:'Cambria Math';
                                    panose-1:2 4 5 3 5 4 6 3 2 4;}
                                @font-face
                                    {font-family:Calibri;
                                    panose-1:2 15 5 2 2 2 4 3 2 4;}
                                @font-face
                                    {font-family:Tahoma;
                                    panose-1:2 11 6 4 3 5 4 4 2 4;} 
                                    p.fuente-mail,span.fuente-mail,strong.fuente-mail,span.fuente-mail{font-size:13.0pt;font-family:'Calibri','sans-serif';color:#1F497D;}
                                    .imagen-logo{float: right;width: 42%;margin-top: 2%;}
                        </style>  
                     </head> 

                     <body> 
                     <div>
                      <p class='fuente-mail' style='font-size:13.0pt;font-family:'Calibri','sans-serif';color:#1F497D;'>Dear ".clean_string($_SESSION['nombre']).",</p> 
                    <p class='fuente-mail' style='font-size:13.0pt;font-family:'Calibri','sans-serif';color:#1F497D;'>Thank you for contacting us.</p><br/>
<p class='fuente-mail' style='font-size:13.0pt;font-family:'Calibri','sans-serif';color:#1F497D;'>Our team of professionals have received your inquire and will be in contact with you shortly.</p>
<p class='fuente-mail' style='font-size:13.0pt;font-family:'Calibri','sans-serif';color:#1F497D;'>As one of the leaders in resolving legal issues for international clients, Carbray is proud to represent you in your case, working with you to achieve the most positive outcome.</p>
<p class='fuente-mail' style='font-size:13.0pt;font-family:'Calibri','sans-serif';color:#1F497D;'>Thank you for choosing us, and a warm welcome from us all.</p>
<p class='fuente-mail' style='font-size:13.0pt;font-family:'Calibri','sans-serif';color:#1F497D;'>Best regards,</p>
                    <p class='fuente-mail' style='font-size:13.0pt;font-family:'Calibri','sans-serif';color:#1F497D;'>Name: ".clean_string($_SESSION['nombre'])." </p>
                    <p class='fuente-mail' style='font-size:13.0pt;font-family:'Calibri','sans-serif';color:#1F497D;'>Email Address: ".clean_string($_SESSION['email'])." </p>
                    <p class='fuente-mail' style='font-size:13.0pt;font-family:'Calibri','sans-serif';color:#1F497D;'>Phone: ".clean_string($_SESSION['phone'])."</p>
                    <p class='fuente-mail' style='font-size:13.0pt;font-family:'Calibri','sans-serif';color:#1F497D;'>Message: ".clean_string($_SESSION['mensaje'])."</p>
                     </div>
                     <div> <img class='imagen-logo' style='float: right;width: 42%;margin-top: 2%;' src='http://www.carbray.es/landing_carbray/english/img/logocarbray.png'/></div>
                        <div style='float:left;    width: 50%!important;'>     <div style='float:left'><br/><br/><strong class='fuente-mail' style='<font-size:13.0pt;font-family:'Calibri','sans-serif';color:#1F497D;'>Barcelona</strong><br/><span style='font-size:12px' class='fuente-mail'>Ronda Sant Pere, 33 Ppal. 3ª y 4ª,<br/>08010 | Tlf.  +34 93 488 09 72</span></div>
                         <div style='float:left;margin-top: 7.5%;padding-left: 4%;'><strong class='fuente-mail'>Madrid Office</strong> <br/><span style='font-size:12px
                         ;font-family:'Calibri','sans-serif';color:#1F497D;' class='fuente-mail'>Paseo de la Castellana, 18 Planta 7ª,<br/>28046 | Tlf.  +34 91 794 28 10</span></div></div>

                         <p class='fuente-mail' style='font-size:13.0pt;font-family:'Calibri','sans-serif';color:#1F497D;'><strong class='fuente-mail'>Disclaimer:</strong> This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Your must not, directly or indirectly, use, disclose, distribute, print, or copy any part of this message if you are not the intended recipient.    </p>
</div>
                     </body> 
                 </html>";

            $headers = "From: ".$_SESSION['email']."\r\n";
    $headers .= 'Bcc: aitor.udabe@carbray.es' . "\r\n";
    $headers_cliente .= "From: Info Carbray <aitor.udabe@carbray.es>\r\n".'X-Mailer: PHP/' . phpversion();


            @mail($email_to, $email_subject, $email_message, $headers);
            @mail($_SESSION['email'], $email_subject_client,     $email_message2, $headers_cliente);                



            /*Message sent! (change the text below as you wish)*/
            header('Location: http://www.carbray.es/landing_carbray/en/thanks.php'); 

             /*End Message Sent*/

            }else
            {

            }
?>
</div>



<div id="contentForm">
<?php

        header('Content-Type: text/html; charset=utf-8');

        if(isset($_POST['email2'])) {


            // EDIT THE 2 LINES BELOW AS REQUIRED

            $email_to2 = "aitor.udabe@carbray.es";

            $email_subject2 = "Landing English Lawyers  SUB 3.0";
             $email_subject_client3 = "Thank you for contacting us.";

            $headerscliente3 = "Content-Type: text/html; charset=UTF-8\n";  //Con esta cabecera lo que hacemos es que el contenido html se vea 
            $_SESSION['nombre2'] = $_POST['first_name2']; // required 
            $_SESSION['email2'] = $_POST['email2']; // required
            $_SESSION['phone2'] = $_POST['phone2']; // required
            $_SESSION['mensaje2'] = $_POST['message2']; // required
            $_SESSION['gclid'] = $_POST['gclid_field2']
            $landingP2=$_SERVER['HTTP_REFERER'];//obtenemos la ruta de donde viene por las cabeceras http       


            $email_message4 = "Form details below.\n\n";


            function clean_string($string) {
                $bad = array("content-type","bcc:","to:","cc:","href");
                return str_replace($bad,"",$string);
            }


            $email_message4 .= "Name: ".clean_string($_SESSION['nombre2'])."\n";
            $email_message4 .= "Email Address: ".clean_string($_SESSION['email2'])."\n";
            $email_message4 .= "Phone: ".clean_string($_SESSION['phone2'])."\n";
            $email_message4 .= "Message: ".clean_string($_SESSION['mensaje2'])."\n";


            $email_message3 .= "
             <!DOCTYPE html> 
            <html> 
                     <head> 
                           <meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'> 
                           <title>Enviar email</title>
                        <style>
                            <!--/* Font Definitions */
                                @font-face
                                    {font-family:'Cambria Math';
                                    panose-1:2 4 5 3 5 4 6 3 2 4;}
                                @font-face
                                    {font-family:Calibri;
                                    panose-1:2 15 5 2 2 2 4 3 2 4;}
                                @font-face
                                    {font-family:Tahoma;
                                    panose-1:2 11 6 4 3 5 4 4 2 4;} 
                                    p.fuente-mail,span.fuente-mail,strong.fuente-mail,span.fuente-mail{font-size:13.0pt;font-family:'Calibri','sans-serif';color:#1F497D;}
                                    .imagen-logo{float: right;width: 42%;margin-top: 2%;}
                        </style>  
                     </head> 

                     <body> 
                     <div>
                      <p class='fuente-mail' style='font-size:13.0pt;font-family:'Calibri','sans-serif';color:#1F497D;'>Dear ".clean_string($_SESSION['nombre2']).",</p> 
                    <p class='fuente-mail' style='font-size:13.0pt;font-family:'Calibri','sans-serif';color:#1F497D;'>Thank you for contacting us.</p>    <br/>
<p class='fuente-mail' style='font-size:13.0pt;font-family:'Calibri','sans-serif';color:#1F497D;'>Our team of professionals have received your inquire and will be in contact with you shortly.</p>
<p class='fuente-mail' style='font-size:13.0pt;font-family:'Calibri','sans-serif';color:#1F497D;'>As one of the leaders in resolving legal issues for international clients, Carbray is proud to represent you in your case, working with you to achieve the most positive outcome.</p>
<p class='fuente-mail' style='font-size:13.0pt;font-family:'Calibri','sans-serif';color:#1F497D;'>Thank you for choosing us, and a warm welcome from us all.</p>
<p class='fuente-mail' style='font-size:13.0pt;font-family:'Calibri','sans-serif';color:#1F497D;'>Best regards,</p>
                    <p class='fuente-mail' style='font-size:13.0pt;font-family:'Calibri','sans-serif';color:#1F497D;'>Name: ".clean_string($_SESSION['nombre2'])." </p>
                    <p class='fuente-mail' style='font-size:13.0pt;font-family:'Calibri','sans-serif';color:#1F497D;'>Email Address: ".clean_string($_SESSION['email2'])." </p>
                    <p class='fuente-mail' style='font-size:13.0pt;font-family:'Calibri','sans-serif';color:#1F497D;'>Phone: ".clean_string($_SESSION['phone2'])."</p>
                    <p class='fuente-mail' style='font-size:13.0pt;font-family:'Calibri','sans-serif';color:#1F497D;'>Message: ".clean_string($_SESSION['mensaje2'])."</p>
                     </div>
                     <div> <img class='imagen-logo' style='float: right;width: 42%;margin-top: 2%;' src='http://www.carbray.es/landing_carbray/english/img/logocarbray.png'/></div>
                        <div style='float:left;    width: 50%!important;'>         <div style='float:left'><br/><br/><strong class='fuente-mail' style='<font-size:13.0pt;font-family:'Calibri','sans-serif';color:#1F497D;'>Barcelona</strong><br/><span style='font-size:12px' class='fuente-mail'>Ronda Sant Pere, 33 Ppal. 3ª y 4ª,<br/>08010 | Tlf.  +34 93 488 09 72</span></div>
                         <div style='float:left;margin-top: 7.5%;padding-left: 4%;'><strong class='fuente-mail'>Madrid Office</strong> <br/><span style='font-size:12px
                         ;font-family:'Calibri','sans-serif';color:#1F497D;' class='fuente-mail'>Paseo de la Castellana, 18 Planta 7ª,<br/>28046 | Tlf.  +34 91 794 28 10</span></div></div>

                         <p class='fuente-mail' style='font-size:13.0pt;font-family:'Calibri','sans-serif';color:#1F497D;'><strong class='fuente-mail'>Disclaimer:</strong> This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Your must not, directly or indirectly, use, disclose, distribute, print, or copy any part of this message if you are not the intended recipient.    </p>
</div>
                     </body> 
                 </html>";










            // create email headers

            $headers2 = "From: " .$_SESSION['email2']. "\r\n";
$headers2 .= 'Bcc:aitor.udabe@carbray.es' . "\r\n";
$headerscliente3 .= "From: Info Carbray <aitor.udabe@carbray.es>\r\n". 'X-Mailer: PHP/' . phpversion();

            @mail($email_to2, $email_subject2, $email_message4, $headers2);
            @mail($_SESSION['email2'], $email_subject_client3,     $email_message3, $headerscliente3);              



            /*Message sent! (change the text below as you wish)*/
            header('Location: http://www.carbray.es/landing_carbray/en/thanks.php'); 

             /*End Message Sent*/

            }else
            {

            }
?>
<?php
// Composer's auto-loading functionality
require "vendor/autoload.php";

use Google\Spreadsheet\DefaultServiceRequest;
use Google\Spreadsheet\ServiceRequestFactory;

$nombreAplicacion = "PhpSheet";
$direccionCorreo = "addrowinsheet@phpsheet.iam.gserviceaccount.com";
$idCliente = "3a5bbd2c9ada9a0f85e8fc1516157400c754d6fa";

// Nombre del SpreadSheet creada
$nombreSpreahSheet = "Php Sheet volcado";
// Nombre de hoja de cálculo
$hojaCalculo = "Hoja 2";

$scope = array('https://spreadsheets.google.com/feeds');

// Inicializamos Google Client
$client = new Google_Client();
$client->setApplicationName($nombreAplicacion);
$client->setClientId($idCliente);

// credenciales, scope y archivo p12. Agregar el correcto Path al archivo p12
$cred = new Google_Auth_AssertionCredentials(
 $direccionCorreo,
 $scope,
 file_get_contents('PhpSheet-3a5bbd2c9ada.p12')
);

$client->setAssertionCredentials($cred);

// si expiro el access token generamos otro
if($client->isAccessTokenExpired()) {
 $client->getAuth()->refreshTokenWithAssertion($cred);
}

// Obtenemos el access token
$obj_token = json_decode($client->getAccessToken());
$accessToken = $obj_token->access_token;

// Inicializamos google-spreadsheet-client
$serviceRequest = new DefaultServiceRequest($accessToken);
ServiceRequestFactory::setInstance($serviceRequest);

//Obtenemos los Spreadsheets disponibles para las credenciales actuales
$spreadsheetService = new Google\Spreadsheet\SpreadsheetService();
$spreadsheetFeed = $spreadsheetService->getSpreadsheets();

// Obtenemos la spreadsheet por su nombre
$spreadsheet = $spreadsheetFeed->getByTitle($nombreSpreahSheet);

// Obtenemos las hojas de cálculo de la spreadsheet obetenida
$worksheetFeed = $spreadsheet->getWorksheets();

// Obtenemos la hoja de cálculo por su nombre
$worksheet = $worksheetFeed->getByTitle($hojaCalculo);
$listFeed = $worksheet->getListFeed();

if(!empty($_SESSION['nombre'])&&!empty($_SESSION['gclid'])) {
$dataAgregar = array('gclid' => $_SESSION['gclid'],
   'nombre' => $_SESSION['nombre'],
 'email' => $_SESSION['email'],
 'telefono' =>"'" .$_SESSION['phone'],
 'mensaje' => $_SESSION['mensaje'],
 'landing' =>  $landingP
 );
 $listFeed->insert($dataAgregar);
}
if(!empty($_SESSION['nombre2'])&&!empty($_SESSION['gclid2'])) {
  $dataAgregar2 = array('gclid' => $_SESSION['gclid2'],
'nombre' => $_SESSION['nombre2'],
 'email' => $_SESSION['email2'],
 'telefono' =>"'" .$_SESSION['phone2'],
 'mensaje' => $_SESSION['mensaje2'],
 'landing' =>  $landingP2
 );
 $listFeed->insert($dataAgregar2);
}    
?>  

    </div>


</body>

</html>
1
задан 27.10.2016, 12:38
2 ответа

Он делает очень мало я вооружил формуляры PHP, настроенные для WordPress. У него есть Ваши возвращения. Я это документировал в каких-то статьях. Я перемещаю тебя соединения. Предупреди меня, если necesitás больше информации:

Есть какие-то части статей, что ты может быть не нуждался в них. Привет!

1
ответ дан 24.11.2019, 12:53
  • 1
    Благодаря которым вы ответили, проблема contact form 7, что я это использовал, - следующий, я использую composer, чтобы реализовывать вещь с google sheet однажды пользователь дает кнопке посылать ему, с contactform7 я не могу реализовывать это или, по крайней мере, не, как делание этого. –  AitorUdabe 28.10.2016, 12:39
  • 2
    Я думаю, что ты комментарии он для другого вопроса. Обрати внимание art и # 237; зады, что ты pas и # 233; страховка они будут подавать тебя. Привет –  jpussacq 28.10.2016, 15:05

Так как ты используешь WordPress, я рекомендую тебе не изобретать порох. У этого plugin есть все и конечно больше, чем ты нуждаешься, чтобы создавать формуляры очень простой формы:

Ваша официальная страница говорит:

"Формуляр контакта 7 может управлять о многообразных формулярах контакта, кроме того, ты можешь настраивать формуляр и контент электронных почт простого способа посредством просто помеченный. Формуляр выносит отправления из-за Аякса, CAPTCHA, выдано spam Akismet и гораздо больше."

https://es.wordpress.org / plugins / contact-form-7 /

Удача

0
ответ дан 24.11.2019, 12:53

Теги

Похожие вопросы