I have done with my contact form but I received an error showing message “couldn’t be sent”. I have no errors showing except the line of sending mail which is:
$isSuccess = mail($to, $subject, $message, $headers);
Also, I have modified the code according the forum members’ suggestions and still I am receiving the same error.
Could help me with that? I have also read the PHP documentation and I followed all instructions but still no result.
HTML code:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
</head>
<body>
<h2>Contact Form</h2>
<p><span style="color: red" >*Required field</span></p>
<form action="contact.php" method="post" enctype="multipart/form-data" accept-charset="UTF-8">
First Name:<input type="text" name="fname"><span style="color: red" >*</span><br><br>
Last Name:<input type="text" name="lname"><span style="color: red" >*</span><br><br>
E-mail:<input type="text" name="email"><span style="color: red" >*</span><br><br>
Telephone:<input type="text" name="tel"><br><br>
Designation:<select name="design">
<option value="Architectural Engineer">Architectural Engineer</option>
<option value="Structural Engineer">Structural Engineer</option>
<option value="Draughts-man">Draughts-man</option>
<option value="Receptionist">Receptionist</option>
<option value="Secertary">Secertary</option>
</select><br><br>
Country Applied From:<select name="country">
<option value="">Country...</option>
<option value="Afganistan">Afghanistan</option>
<option value="Albania">Albania</option>
</select><br><br>
Message:<textarea name="comment"></textarea> <br><br>
Upload Your Resume:<span style="color: red" >*</span><input type="file" name="uploaded_file"><br><br>
<input type="submit" name="submit" value="Submit">
<input type="reset" value="Clear">
</form>
</body>
</html>
PHP code:
<?php
if(isset($_POST['submit']))
{
$fname = $_POST['fname'];
$lname = $_POST['lname'];
$email = $_POST['email'];
$tel = $_POST['tel'];
$design = $_POST['design'];
$country = $_POST['country'];
$comment = $_POST['comment'];
$to = 'eng.bolaraafat@hotmail.com';
$subject = 'Contact Form';
$message = 'From: '.$fname .$lname."\r\n";
'E-mail: '.$email."\r\n";
'Telephone: '.$tel."\r\n";
'Designation: '.$design."\r\n";
'Country Appled From: '.$country."\r\n";
'Message: '.$comment."\r\n";
$headers = "From:" .$email. "\n" .
$isSuccess = mail($to, $subject, $message, $headers);
if( $isSuccess == true ) { // if mail is successfully sent
echo "Message sent successfully...";
}else{
echo "Message could not be sent...";
}
}
?>