# Problem with my php contact form...pls help

**URL:** <https://forum.kirupa.com/t/problem-with-my-php-contact-form-pls-help/312799>\
**Category:** Uncategorized\
**Created:** [August 12, 2010, 11:40pm UTC](https://forum.kirupa.com/t/problem-with-my-php-contact-form-pls-help/312799 "2010-08-12T23:40:29Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![proteus](https://avatars.discourse-cdn.com/v4/letter/p/0ea827/32.png) [@proteus](https://forum.kirupa.com/u/proteus)\
**Post date:** [August 12, 2010, 11:40pm UTC](https://forum.kirupa.com/t/problem-with-my-php-contact-form-pls-help/312799/1 "2010-08-12T23:40:29Z")

</div>

guys i need a little help here pls! few days ago i downloaded a free site template with php contact form and when i uploaded it to the host i tried to send a message, after clicking on the submit button the page went on trying to send the message and stacked out, showing nothing on the screen… I checked out my mail and the message i wrote was there. So my question is, how can I fix this “web stacking” and not showing “message sent” or redirecting on my web page…where is my mistake?  
p.s. I m totally novice and if this question looks stupid, my apologies to all members!🙂  
here is the php code that i uploaded with the contact.html form:

\<?php

if(!$\_POST) exit;

$email = $\_POST[‘email’];

//$error[] = preg\_match(’/\b[A-Z0-9.\_%-]+@[A-Z0-9.-]+.[A-Z]{2,4}\b/i’, $_POST[‘email’]) ? ‘’ : ‘INVALID EMAIL ADDRESS’;  
if(!eregi("^[a-z0-9]+([_\.-][a-z0-9]+)_" ."@"."([a-z0-9]+([.-][a-z0-9]+)_)+"."\.[a-z]{2,}"."$",$email )){  
$error.=“Invalid email address entered”;  
$errors=1;  
}  
if($errors==1) echo $error;  
else{  
$values = array (‘name’,‘email’,‘message’);  
$required = array(‘name’,‘email’,‘message’);

```
$your_email = "lunaticti@yahoo.fr";
$email_subject = "New Message: ".$_POST['subject'];
$email_content = "new message:

```

";

```
foreach($values as $key =&gt; $value){
  if(in_array($value,$required)){
    if ($key != 'subject' && $key != 'company') {
      if( empty($_POST[$value]) ) { echo 'PLEASE FILL IN REQUIRED FIELDS'; exit; }
    }
    $email_content .= $value.': '.$_POST[$value]."

```

";  
}  
}

```
if(@mail($your_email,$email_subject,$email_content)) {
    echo 'Message sent!'; 
} else {
    echo 'ERROR!';
}

```

}  
?\>

and this is the contact.html:

\<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “[http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd](http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd)”\>  
\<html xmlns=“[http://www.w3.org/1999/xhtml](http://www.w3.org/1999/xhtml)”\>  
\<head\>  
\<title\>\</title\>  
\<meta http-equiv=“Content-Type” content=“text/html; charset=UTF-8” /\>  
\<link href=“style.css” rel=“stylesheet” type=“text/css” /\>  
\<script type=“text/javascript” src=“js/cufon-yui.js”\>\</script\>  
\<script type=“text/javascript” src=“js/georgia.js”\>\</script\>  
\<script type=“text/javascript” src=“js/cuf\_run.js”\>\</script\>

\<script src=“js/jquery.js” type=“text/javascript”\>\</script\>  
\<script type=“text/javascript”\>  
// \<![CDATA[  
$(function(){  
$(’#contactform’).submit(function(){  
var action = $(this).attr(‘action’);  
$.post(action, {  
name: $(’#name’).val(),  
email: $(’#email’).val(),  
company: $(’#company’).val(),  
subject: $(’#subject’).val(),  
message: $(’#message’).val()  
},  
function(data){  
$(’#contactform #submit’).attr(‘disabled’,’’);  
$(’.response’).remove();  
$(’#contactform’).before(’\<p class=“response”\>’+data+’\</p\>’);  
$(’.response’).slideDown();  
if(data==‘Message sent!’) $(’#contactform’).slideUp();  
}  
);  
return false;  
});  
});  
// ]]\>  
\</script\>  
\</head\>  
\<body\>  
\<div class=“main”\>  
\<div class=“header”\>  
\<div class=“header\_resize”\>  
\<div class=“logo”\>\<h1\>\<a href=“index.html”\>\<small\>\</small\>\<br /\>\</a\>\</h1\>\</div\>  
\<div class=“logo\_text”\>\<a href="#"\>Help\</a\> | \<a href="#"\>Search\</a\> | \<a href="#"\>Contacts\</a\>\</div\>

```
  &lt;div class="clr"&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="headert_text_resize"&gt;
  &lt;div class="menu"&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;a href="index.html"&gt;Home&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href="services.html"&gt;Services&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href="about.html"&gt;About Us&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href="contact.html" class="active"&gt;Contact Us&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/div&gt;
  &lt;div class="clr"&gt;&lt;/div&gt;
  &lt;img src="images/text_header.gif" alt="img" width="576" height="147" /&gt;
  &lt;div class="headert_text"&gt;
    &lt;p&gt; | &lt;span&gt;&lt;/span&gt;&lt;/p&gt;
  &lt;/div&gt;
  &lt;div class="clr"&gt;&lt;/div&gt;
&lt;/div&gt;

```

\</div\>  
\<div class=“body”\>  
\<div class=“body\_resize”\>  
\<div class=“left”\>  
\<h2\>contact\</h2\>  
\<p\>\</p\>  
\<form action=“contact.php” method=“post” id=“contactform”\>  
\<ol\>  
\<li\>  
\<label for=“name”\>Your Name\*\</label\>  
\<input id=“name” name=“name” class=“text” /\>  
\</li\>  
\<li\>  
\<label for=“email”\>E-Mail\*\</label\>  
\<input id=“email” name=“email” class=“text” /\>  
\</li\>  
\<li\>  
\<label for=“company”\>Website\</label\>  
\<input id=“company” name=“company” class=“text” /\>  
\</li\>  
\<li\>  
\<label for=“message”\>Your Message\*\</label\>  
\<textarea id=“message” name=“message” rows=“6” cols=“50”\>\</textarea\>  
\</li\>  
\<li class=“buttons”\>  
\<input type=“submit” name=“imageField” id=“imageField” value=“Send message” class=“send” /\>  
\<div class=“clr”\>\</div\>  
\</li\>  
\</ol\>  
\</form\>  
\</div\>  
any appropriate comment is welcomed!  
thank you in advanced! 🙂
