Skip to main content
TooManyQuestions
Participating Frequently
June 6, 2018
Answered

Trouble with a contact form...

  • June 6, 2018
  • 2 replies
  • 1394 views

Let me completely honest… I have no idea what I’m doing and I don´t know how to use Dreamweaver, however, I’m trying to do something that is (hopefully) very simple.

Here’s the problem: I recently changed my hosting provider and our contact form stopped working; someone in customer service explained to me (without success) why my php script doesn’t work with their servers. I told him I had no idea how to fix that, so, he was kind enough to give me a php and an index file with a contact form that works.

Next, I opened Dreamweaver, copied the new contact form over the original, replaced the php file in the server and, for some reason, it just doesn’t work. The website goes blank after I click "SEND".

Does anyone know what's going on? I thought this was just a simple copy-paste trick…

Thanks in advance!

This topic has been closed for replies.
Correct answer Nancy OShea

Oh... I see what your are saying... the site still has references to the original script.

Do you know if there's way to correct that using design mode? The only thing I did was to change the "Form Action" in the SEND Button and to make sure that the "Name" tag in each text box matched the new script.

Maybe I have to make the form from scratch?


The SEND button has no action. 

Action is in the <form> tag.

Compare the Host's form with yours and fix the differences in Code view.

2 replies

Nancy OShea
Community Expert
Community Expert
June 6, 2018

Your contact form's names must match those in your processing script.

EDIT:  first_name, last_name, email, telephone, etc....

Use the host's contact form and script as they gave it to you.  If that works on your contact page, you're 90% there.

Nancy O'Shea— Product User & Community Expert
TooManyQuestions
Participating Frequently
June 6, 2018

I did check that... well I think i did... In the properties panel there is a text box called "NAME" and I just checked that matched with the php script.

I think the answer to this mistery is going to be something I should've known....

Nancy OShea
Community Expert
Community Expert
June 6, 2018

Compare the code in your contact form with the working form your host gave you.   I see several differences.

The working form contains this:

<form name="frmContacto" method="post" action="sendbymail.php">

<table width="500px">

Your contact page contains this which is not at all the same.

<form action="manda_mail.php" method='get'  id="form1" onsubmit="MM_validateForm('Nombre','','R','Comentarios','','R','CorreoElectronico','','RisEmail','','','');return document.MM_returnValue">

  <table cellpadding="3" cellspacing="3" class="left" >

Nancy O'Shea— Product User & Community Expert
Legend
June 6, 2018

Can you paste your form code from start <form> tag to end </form> tag and also the php code in the forum?

TooManyQuestions
Participating Frequently
June 6, 2018

Sure!

**This is the form code the hosting service gave me:

<form name="frmContacto" method="post" action="sendbymail.php">

<table width="500px">

<tr>

<td>

<label for="first_name">Nombre: *</label>

</td>

<td>

<input type="text" name="first_name" maxlength="50" size="25">

</td>

</tr>

<tr>

<td valign="top"">

<label for="last_name">Apellido: *</label>

</td>

<td>

<input type="text" name="last_name" maxlength="50" size="25">

</td>

</tr>

<tr>

<td>

<label for="email">Direccion de E-mail: *</label>

</td>

<td>

<input type="text" name="email" maxlength="80" size="35">

</td>

</tr>

<tr>

<td>

<label for="telephone">Numero de telefono:</label>

</td>

<td>

<input type="text" name="telephone" maxlength="25" size="15">

</td>

</tr>

<tr>

<td>

<label for="comments">Comentarios: *</label>

</td>

<td>

<textarea name="comments" maxlength="500" cols="30" rows="5"></textarea>

</td>

</tr>

<tr>

<td colspan="2" style="text-align:right">

<input type="submit" value="Enviar">

</td>

</tr>

</table>

</form>

**This is the PHP script the hosting service gave me:

<?php

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

// Debes editar las próximas dos líneas de código de acuerdo con tus preferencias

$email_to = "contact@myemail.com";

$email_subject = "Contacto desde el sitio web";

// Aquí se deberían validar los datos ingresados por el usuario

if(!isset($_POST['first_name']) ||

!isset($_POST['last_name']) ||

!isset($_POST['email']) ||

!isset($_POST['telephone']) ||

!isset($_POST['comments'])) {

echo "<b>Ocurrio un error y el formulario no ha sido enviado. </b><br />";

echo "Por favor, vuelva atrás y verifique la información ingresada<br />";

die();

}

$email_message = "Detalles del formulario de contacto:\n\n";

$email_message .= "Nombre: " . $_POST['first_name'] . "\n";

$email_message .= "Apellido: " . $_POST['last_name'] . "\n";

$email_message .= "E-mail: " . $_POST['email'] . "\n";

$email_message .= "Teléfono: " . $_POST['telephone'] . "\n";

$email_message .= "Comentarios: " . $_POST['comments'] . "\n\n";

// Ahora se envía el e-mail usando la función mail() de PHP

$headers = 'From: '.$email_from."\r\n".

'Reply-To: '.$email_from."\r\n" .

'X-Mailer: PHP/' . phpversion();

@mail($email_to, $email_subject, $email_message, $headers);

echo "¡El formulario se ha enviado con exito!";

}

?>

**This is my original php script, that no longer works... aparently it must have my email in the script.

<?php /* Created on: 02/05/2007 */ ?>

<?php

$to = $_GET["Email"] . "@" . $_GET["Dominio"];

$from = $_GET["From"] . "@" . $_GET["Dominio"];

$correo = $_GET["Email"];

//Datos para procesar el correo

$respuesta = $_GET["Confirmacion"];

$from =  $_GET["Correo"];

$replyto = $_GET["ReplyTo"];

$subject = $_GET["Subject"];

//Servidor de correo del cliente. Siempre va mail.dominio por ejemplo: mail.syop.com.mx

//$server = "mail.inventsa.com";

$server = "mail.".$_GET["Dominio"]."";

//Variables que recibe de estilo

$nombre_empresa= $_GET["Empresa"];

$font = $_GET["font"];

$color_titulo = $_GET["c_tit"];

$background_titulo = $_GET["b_tit"];

$color_subtitulo = $_GET["c_stit"];

$background_subtitulo = $_GET["b_stit"];

//VALIDACIONES PARA TODOS LOS CAMPOS

//|| $server == "mail.sysop.com.mx"

if($server == "" ){

echo "Tienes un error en la forma de contacto, no has cambiado el servidor de correo.";

exit;

}

else if (  $_GET["Email"] == "" ||  $_GET["Dominio"] == "" || $subject == "" ||  $_GET["From"] == ""){

echo "No estas mandando los campos escondidos para procesar el correo. <br/>

Estos campos pueden ser Email, Dominio o From.";

exit;

}

else if ( $nombre_empresa == " " || $font == "" || $color_titulo== "" || $background_titulo== "" || $color_subtitulo== "" || $background_subtitulo== ""){

echo "No estas mandando todos los campos para personalizar el correo. <br/>

  Revisa los hiddens de tu forma de contacto.";

exit;

}

if($respuesta == ""){

echo "Tienes un error en la forma de contacto, falta mandar la confirmaci&oacute;n.";

exit;

}

//Se borran las variables que no queremos que imprima en el correo.

unset ($_GET['Enviar']);

unset ($_GET['Submit']);

unset ($_GET['Email']);

unset ($_GET['Dominio']);

unset ( $_GET["Confirmacion"]);

unset ($_GET["Empresa"]);

unset ($_GET["font"]);

unset ($_GET["c_tit"]);

unset ($_GET["b_tit"]);

unset ($_GET["c_stit"]);

unset ($_GET["b_stit"]);

//Headers que tiene que tener para mandar el correo en html.

  $headers = "From: $from\r\n" .

     "Content-Type: text/html; ".

       "charset=UTF-8; format=flowed\n".

       "MIME-Version: 1.0\n".

       "Content-Transfer-Encoding: 8bit\n ".

       "X-Mailer: PHP\n";

// Se tienen las variables en el arreglo $Get y se les asigna llave y valor para imprimir.

foreach ($_GET as $key => $value)

{

$body.= '

<tr class="fondo">

    <td width="16%" class="left"> '.$key.':</td>

    <td width="84%"> '.$value.'</td>

</tr>';

}

$mensaje= '

<html>

<head>

<title>----Forma de Contacto----</title>

<meta http-equiv="Content-Type"  content="text/html; charset=UTF-8"/>

<style type="text/css">

.ancho{

height:40px;

}

body{

font-family:Lucida Sans;

font-size:12px;

color:#646464;

}

.borderright{

border-right:medium;

border-right-width:medium;

border-right-color:#D3D3D3;

border-right-style:solid;

}

.borderbottom{

border-bottom:medium;

border-bottom-width:medium;

border-bottom-color:#D3D3D3;

border-bottom-style:solid;

}

.fondo{

background-color:#fff;

}

.left{

padding-left:30px;

font-weight:bold;

}

.subtitulo{

font-family:'.$font.';

font-size:14px;

color:'.$color_subtitulo.';

background-color:'.$background_subtitulo.';

padding-top:5px;

padding-left:20px;

text-align:center;

font-style:italic;

font-weight:bold;

}

.titulo{

font-family:'.$font.';

font-size:20px;

color:'.$color_titulo.';

padding-top:5px;

padding-left:20px;

background-color:'.$background_titulo.';

}

</style>

</head>

<body>

<table width="50%" border="0" cellpadding="0" cellspacing="2" class="borderright borderbottom">

  <tr>

    <td colspan="2" class="titulo ancho">'.$nombre_empresa.'</td>

  </tr>

  <tr>

    <td colspan="2" class="subtitulo">El Solicitante introdujo los siguientes campos </td>

  </tr>

    '.$body.'

<tr>

<td> </td>

<td align="right" style="font-size:12px; font-family:Times New Roman, Times, serif; color:#001a78;">APISA</td></tr>

</table>

</body>

</html>';

//Manda el correo

mail("$to", "$subject", "$mensaje", "$headers");

//Se hace un location hacia la p?na de respuesta que se env?como par?tro.

print "<script>document.location.href='$respuesta'</script>";

?>

<html>

<?php

print "Mail enviado exitosamente";

?>

</body>

</body>

</html>

**Hope its not a problem that its in spanish.

Legend
June 6, 2018

You say that the form code and the php script that your hosting company gave you worked? Did you test the form and script yourself?