Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if(isset($_POST['email'])) {
- // EDIT THE 2 LINES BELOW AS REQUIRED
- $email_to = "[email protected]";
- $email_subject = "narudzba";
- function died($error) {
- // your error code can go here
- echo "ŽAO NAM JE,IMA GREŠAKA U VAŠOJ NARUDŽBI. ";
- echo "POGLEDAJTE ZAPIS GREŠKE:.<br /><br />";
- echo $error."<br /><br />";
- echo "POGLEDAJTE VAŠE POLJE I PROBAJTE PONOVO!.<br /><br />";
- die();
- }
- // validation expected data exists
- if(!isset($_POST['Ime']) ||
- !isset($_POST['Uplatnica']) ||
- !isset($_POST['email']) ||
- !isset($_POST['ID_NARUDZBE']) ||
- !isset($_POST['carlist']) ||
- !isset($_POST['Drzava']) ||
- !isset($_POST['opis'])) {
- died('We are sorry, but there appears to be a problem with the form you submitted.');
- }
- $Ime = $_POST['Ime']; // required
- $Uplatnica = $_POST['Uplatnica']; // required
- $email_from = $_POST['email']; // required
- $carlist = $_POST['carlist']; // required
- $Drzava = $_POST['Drzava']; // required
- $ID_NARUDZBE = $_POST['ID_NARUDZBE']; // required
- $opis = $_POST['opis']; // required
- $error_message = "";
- $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
- if(!preg_match($email_exp,$email_from)) {
- $error_message .= 'VASA E-MAIL ADRESA NIJE TOCNA.MOLIMO UNESITE ISPRAVNU!.<br />';
- }
- $string_exp = "/^[A-Za-z .'-]+$/";
- if(!preg_match($string_exp,$Ime)) {
- $error_message .= '"NISTE UPISALI IME".<br />';
- }
- if(!preg_match($string_exp,$Uplatnica)) {
- $error_message .= 'The Last Name you entered does not appear to be valid.<br />';
- }
- if(strlen($opis) < 2) {
- $error_message .= 'The Comments you entered do not appear to be valid.<br />';
- }
- if(strlen($Drzava) < 2) {
- $error_message .= 'The Comments you entered do not appear to be valid.<br />';
- }
- if(strlen($error_message) > 0) {
- died($error_message);
- }
- $email_message = "Form details below.\n\n";
- function clean_string($string) {
- $bad = array("content-type","bcc:","to:","cc:","href");
- return str_replace($bad,"",$string);
- }
- $email_message .= "Ime: ".clean_string($Ime)."\n";
- $email_message .= "Uplatnica: ".clean_string($Uplatnica)."\n";
- $email_message .= "Email: ".clean_string($email_from)."\n";
- $email_message .= "ID_NARUDZBE: ".clean_string($ID_NARUDZBE)."\n";
- $email_message .= "opis: ".clean_string($opis)."\n";
- $email_message .= "Drzava: ".clean_string($Drzava)."\n";
- $email_message .= "carlist: ".clean_string($carlist)."\n";
- // create email headers
- $headers = 'From: '.$email_from."\r\n".
- 'Reply-To: '.$email_from."\r\n" .
- 'X-Mailer: PHP/' . phpversion();
- @mail($email_to, $email_subject, $email_message, $headers);
- ?>
- <!-- include your own success html here -->
- <?php
- }
- ?><p>NARUCENO!</p>
Advertisement
Add Comment
Please, Sign In to add comment