Contact form

Hello everyone. I have some issues with my contact form. I found it on web and with some modifications I made it work perfectly. But for some reason i stopped to receive the emails even if it says that they’ve been posted. Here is the codes:

test.html

[code]

Αγορά


Ονοματεπώνυμο:

Νομός:

Διεύθυνση:

Τηλ.Επικοινωνίας:

Email:


Παραγγελία-Σχόλια:
 

 
Εισάγεται τον κωδικό που βλέπετε.

[/code]

orders.php

[php]<?php header(“content-type: text/html;charset=utf-8”)
?>

<?php session_start(); if(isset($_POST["submit"])&&$_POST["captcha"]!=""&&$_SESSION["code"]==$_POST["captcha"]) { echo "Correct Code Entered"; //Do you stuff } else { die("Εισάγατε λάθος κωδικό. Προσπαθήστε ξανά."); } { //This page should not be accessed directly. Need to submit the form. echo "Σφάλμα; Πρέπει να κάνετε αποστόλη την φόρμα."; } $name = $_POST['name']; $state = $_POST['state']; $address = $_POST['address']; $telephone = $_POST['telephone']; $email = $_POST['email']; $comments = $_POST['comments']; //Validate first if(empty($name)||empty($email)||empty($telephone)) { echo "Το ονοματεπώνυμο,το τηλέφωνο και το E-mail είναι υποχρεωτικά."; exit; } if(IsInjected($email)) { echo "Το E-mail σας δεν είναι σωστό."; exit; } $email_from = '[email protected]';//<== update the email address $email_subject = "Νέα Παραγγελία-Σχόλιο."; $email_body = "Έχετε λάβει καινούργιο μύνημα απο $name.\n". "Αυτό είναι το μύνημα:\n Ονοματεπώνυμο: $name Νομός: $state Διεύθυνση: $address Τηλ.Επικοινωνίας: $telephone Email: $email Σχόλια: $comments ". $to = "[email protected]";//<== update the email address $headers = "From: $email_from \r\n"; $headers .= "Reply-To: $email \r\n"; //Send the email! mail($to,$email_subject,$email_body,$headers); //done. redirect to thanks page. header('Location: thanks.html'); // Function to validate against any email injection attempts function IsInjected($str) { $injections = array('(\n+)', '(\r+)', '(\t+)', '(%0A+)', '(%0D+)', '(%08+)', '(%09+)' ); $inject = join('|', $injections); $inject = "/$inject/i"; if(preg_match($inject,$str)) { return true; } else { return false; } }[/php] [b]captcha.php[/b] [php]<?php session_start(); $code=rand(1000,9999); $_SESSION["code"]=$code; $im = imagecreatetruecolor(50, 24); $bg = imagecolorallocate($im, 22, 86, 165); //background color blue $fg = imagecolorallocate($im, 255, 255, 255);//text color white imagefill($im, 0, 0, $bg); imagestring($im, 5, 5, 5, $code, $fg); header("Cache-Control: no-cache, must-revalidate"); header('Content-type: image/png'); imagepng($im); imagedestroy($im); ?>[/php]

Any help would be great.

That’s Greek to me…sorry I couldn’t resist. ;D

First you say you have it working, but it doesn’t receive emails? That to me tells me that it doesn’t work.
Second, you really shouldn’t be using inline css styling, you should be using internal or external (my recommendation) css styling.

Third using empty to validate has one serious flaw, what about the person who just enters spaces?

This is what I do before using empty or other ways to validate:

[php]$_SESSION[‘username’] = isset($_SESSION[‘username’]) ? trim($_SESSION[‘username’]) : ‘’;[/php]

Lastly I personally would recommend using a third party email mailer (PHPMailer for example), in the long run it will save you a lot of headaches and time.

From the example email, I am going to guess this is being received by a gmail account? They have ultra strict email requirements. So, it is likely that the mail is being rejected before it even see’s your mailbox.

Sponsor our Newsletter | Privacy Policy | Terms of Service