Hi to all in this nice forum,
I have a problem with my contact form, and as I am very new in php
I ask help from everybody.
Contact form works nice, but when I click the send button nothing happens.
Some problem must be in the contact.php.
I would be greatful to everybody who helps me...
Thanks a lot
Here is the code of the form:
<form id="form-main2" action="contact.php" enctype="multipart/form-data" method="post">
<fieldset>
<div class="wrapper">
<div class="column-1">
<span style="display:inline;position:relative;top:20px;right:-2px;color:red;">*</span>
<input class="text" type="text" name="name" id="name" value="Name:" onBlur="if(this.value=='') this.value='Name:'" onFocus="if(this.value =='Name:' ) this.value=''">
<span style="display:inline;position:relative;top:20px;right:-2px;color:red;">*</span>
<input class="text" type="text" name="email" id="email" value="Email:" onBlur="if(this.value=='') this.value='Email:'" onFocus="if(this.value =='Email:' ) this.value=''">
<span style="display:inline;position:relative;top:20px;right:-2px;color:red;">*</span>
<input class="text" type="text" name="telephone" id="telephone" value="Telephone:" onBlur="if(this.value=='') this.value='Telephone:'" onFocus="if(this.value =='Telephone:' ) this.value=''">
</div>
<div class="column-2">
<span> </span>
<input class="text" style="width:255px" type="text" name="subject" id="subject" value="Subject:" onBlur="if(this.value=='') this.value='Subject:'" onFocus="if(this.value =='Subject:' ) this.value=''">
<span style="display:inline;position:relative;top:20px;right:-2px;color:red;">*</span>
<textarea class="text" name="message" id="message" value="Message:'" onBlur="if(this.value=='') this.value='Message:'" onFocus="if(this.value =='Message:' ) this.value=''">Message:</textarea>
<div class="captcha">
<center>
Insert Security Code<br />
<img src="Captcha/CaptchaSecurityImages.php?width=100&height=40&characters=5" />
<p></p>
<input id="security_code" name="security_code" type="text" />
</center>
<div class="buttons">
<a class="button" href="#" onClick="document.getElementById('form-main2').reset()">Clear</a>
<a class="button" href="#" onClick="document.getElementById('form-main2').submit()">Send</a>
</div>
</div>
</div>
</fieldset>
</form>
And here is contact.php
<?php
session_start();
$name = @$POST['name'];
$email = @$POST['email'];
$message = @$POST['message'];
if( isset($POST['submit'])) {
if (! ereg('[A-Za-z0-9-]+@[A-Za-z0-9-]+.[A-Za-z0-9-]+', $email))
{
header("Location: contact_error.html");
exit;
}
if (!$name or !$message){
header("Location: contact_error.html");
exit;
}
if( $SESSION['security_code'] == $POST['security_code'] && !empty($SESSION['security_code'] ) ) {
// Insert you code for processing the form here, e.g emailing the submission, entering it into a database.
$your_email = "my@male.com";
$headers= "From: ".$_POST['name']." <".$_POST['email'].">\r\n";
$headers.='Content-type: text/html; charset=utf-8';
mail($your_email, $_POST['subject'], "
<html>
<head>
<title>Contact Message</title>
</head>
<body>
Contact Message<br><br>
Name : ".$POST['name']."<br>
Email : ".$POST['email']."<br>
Message : <br>".$POST['message']."<br>
</body>
</html>" , $headers);
header("Location: contact_message.htm");
unset($SESSION['security_code']);
} else {
// Insert your code for showing an error message here
//echo 'Sorry, you have provided an invalid security code';
header("Location: contact_wrong.html");
}
}
?>