Problem getting PHP script to work (connection reset from server)

danmattos

Registered
Sep 4, 2013
4
0
1
cPanel Access Level
Root Administrator
Hi everyone!

I am very new at this and maybe I'm not posting this in the right area, but please bare with me. I'm trying to set up a form that while email me the info input by the visitor. However I always get that the connection was reset by the server and nothing happens. Could any please have a look and maybe tell me what I'm doing wrong? I've tried a million things!! I don't even know where to put the files Also, I would like to add a validation that will print a Java alert if the email is bad, if there is no name (nombre) and if the message (comments) are too short.

It might be worth noting that I'm just on the web hosting server and don't have any program installed on my pc as its a windows laptop.

I really appreciate it!! :D


Code:
<?php
$field_nombre = $_POST["nombre"];
$field_apellido = $_POST["apellido"];
$field_email = $_POST["email"];
$field_tipo = $_POST["tipo"];
$field_comments = $_POST["comments"];

$mail_to = "[email protected]";
$subject = "Contacto Web ".$field_nombre .$field_apellido;

$body_message = "From: ".$field_name .$field_apellido."\n";
$body_message .= "Tipo: ".$field_tipo."\n";
$body_message .= "E-mail: ".$field_email."\n";
$body_message .= "Message: ".$field_message;

$headers = "From: ".$field_email."\r\n";
$headers .= "Reply-To: ".$field_email."\r\n";

$email_status = mail($mail_to, $subject, $body_message, $headers);

if ($email_status) { ?>
	<script language="javascript" type="text/javascript">
		alert("Gracias por contactarnos. Un representante se contactara con usted a la brevedad");
		window.location = "Contact.html";
	</script>
<?php
}
else { ?>
	<script language="javascript" type="text/javascript">
		alert("Error en el mensaje. Por favor reintente o comuniquese con my @ email.com");
		window.location = "Contact.html";
	</script>
<?php
}
?>
-------------------------------------------------------------------------------------------------------------
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Main</title>
<style type="text/css">
<!--
body {
	margin_top: 40px
	margin-left: 30px;
	position: relative;
	height: auto;
	width: 700px;
	font-family: "Eras Light ITC", "Eras Medium ITC", "Eras Bold ITC", "Eras Demi ITC";
	font-size: 18px;
	left: 40px;
	top: 30px;
}
.Style1 {font-size: 18px; font-weight: bold; color: #63B040;}
a:link {
	color: #63B040;
}
a:visited {
	color: #63B040;
}
a:hover {
	color: #63B040;
}
a:active {
	color: #63B040;
	font-weight: bold;
}
-->
</style></head>

<body>
<form name="contactform" method="post" action="enviarformulario.php">
<p align="Left" style="font-size: 24px; color: #68BD45; font-weight: bold;"><img src="img/GreenArrow.jpg"/> Contacto</p>
<p>
Para unirte a la revolución LED basta con que nos envíes un correo y podremos empezar a diseñar una solución especial para tí y tus necesidades.</p>
<table width="665">
<tr>
 <td valign="top">
  <label for="nombre">Nombre *</label>
 </td>
 <td valign="top">
  <input  type="text" name="nombre" maxlength="50" size="15"></input>
 </td>
</tr>
<tr>
 <td valign="top">
  <label for="apellido">Apellido *</label>
 </td>
 <td valign="top">
  <input  type="text" name="apellido" maxlength="50" size="15"></input>
 </td>
</tr>
<tr>
 <td valign="top">
  <label for="email">Email *</label>
 </td>
 <td valign="top">
  <input  type="text" name="email" maxlength="80" size="30"></input>
 </td>
</tr>
<tr>
 <td valign="top">
  <label for="tipo">Tipo *</label>
 </td>
 <td valign="top"><select name="tipo" title="Tipo" dir="ltr">
   <option value="Cliente">Cliente</option>
   <option value="Proveedor">Proveedor</option>
   <option value="Otro">Otro</option>
   <option selected="selected">Elige una opción...</option>
 </select></td>
</tr>
<tr>
 <td valign="top">
  <label for="comments">Mensaje *</label>
 </td>
 <td valign="top">
  <textarea  name="comments" maxlength="1000" cols="50" rows="10"></textarea>
 </td>
</tr>
<tr>
 <td colspan="2" style="text-align:center">
     <input type="submit" value="Enviar"></input>
 </td>
 </tr>
 <tr>
<td height="53" colspan="2" align="center" style="font-size: 16px; color: #68BD45; font-weight: lighter;"></br>Cualquier información entregada en esta página será tratada con la máxima confidencialidad. No le pasaremos tu correo electrónico a nadie... Nunca.</td>
</tr>
</table>
</form>
</body>

</html>
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,913
2,201
363
Hello :)

Could you paste the full error message that is output to the Apache error log? Also, which PHP handler are you using?

Thank you.
 

danmattos

Registered
Sep 4, 2013
4
0
1
cPanel Access Level
Root Administrator
Hello :)

Could you paste the full error message that is output to the Apache error log? Also, which PHP handler are you using?

Thank you.
Hi Michael!!

Thanks for your reply. Here is a snapshot of the error:

PrintScreen1.jpg

Regarding the apache error log, I have no Idea what this is.. also, no idea what a php handler. I am really really inexperienced and have no idea what I'm doing. Any way, this is the actual page /http://www.s-led.cl I probably shouldn't be live but o well.

Cheers!! And thanks again. :D
 

danmattos

Registered
Sep 4, 2013
4
0
1
cPanel Access Level
Root Administrator
Just to update... I put a cgi-script Apache handler with the following extensions .cgi .pl .plx .ppl .perl and .php. But still nothing... im just shooting in the dark here, but o well.

Cheer :P
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,913
2,201
363
Do you have root access to this server? If so, you can find the Apache error log at:

Code:
/usr/local/apache/logs/error_log
You can utilize the "tail -f" command to watch the error log as you load the web page to see what exactly is output. You can find out which PHP handler you are using with this command:

Code:
/usr/local/cpanel/bin/rebuild_phpconf --current
Thank you.
 

danmattos

Registered
Sep 4, 2013
4
0
1
cPanel Access Level
Root Administrator
As far as I can tell no. The only thing similar to terminal on the cpanel page is ssh/shell access. I don't know where to go on the panel. Im so sorry, I must be pain.

Cheers


Do you have root access to this server? If so, you can find the Apache error log at:

Code:
/usr/local/apache/logs/error_log
You can utilize the "tail -f" command to watch the error log as you load the web page to see what exactly is output. You can find out which PHP handler you are using with this command:

Code:
/usr/local/cpanel/bin/rebuild_phpconf --current
Thank you.
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,913
2,201
363
It sounds like you may only have a standard web hosting account with access to cPanel. In this case, you must contact your web hosting provider for assistance so they can see why that error message is occurring.

Thank you.
 

arvin1844

Member
Feb 4, 2012
8
0
51
cPanel Access Level
Root Administrator
I also have the same issue. I have a html form . When I click submit button atfter filling all the data, I am getting "The connection was reset". And there is nothing on apache error logs. When I restart apache /scripts/restartsrv_httpd issue will get solved. But after few minutes issue will be back again.

/usr/local/cpanel/bin/rebuild_phpconf --current
Available handlers: suphp dso cgi none
DEFAULT PHP: 5
PHP4 SAPI: none
PHP5 SAPI: suphp
SUEXEC: enabled
RUID2: not installed

And the html form is using cgi-bin/feedback.pl in public_html. When I submit the html form domain.com/cgi-bin/feedback.pl is the link dispalying last with the error "The connection was reset".

Please help.
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,913
2,201
363
Hello :)

Feel free to open a support ticket using the link in my signature so we can take a closer look. You can post the ticket number here so we can update this thread with the outcome.

Thank you.