Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.

Form to email (čšž...)

[es] :: PHP :: Form to email (čšž...)

[ Pregleda: 954 | Odgovora: 4 ] > FB > Twit

Postavi temu Odgovori

Autor

Pretraga teme: Traži
Markiranje Štampanje RSS

Zelenko

Član broj: 118092
Poruke: 10
*.dynamic.isp.telekom.rs.



Profil

icon Form to email (čšž...)07.01.2013. u 13:04 - pre 137 meseci
Da li neko zna kako da resim problem,
naime naša slova čšžđ... nakon što ih korisnik napiše u formi, ne prkaziju se pravilno u HTML (echo) kao ni u prosledjenoj poruci na moj mail (message)?


SKRIPTA:

<?php

$to = "[email protected]";
$subject = "On-line porudžbina";



function died($error) {
// your error code can go here
echo "We are very sorry, but there were error(s) found with the form you submitted. ";
echo "These errors appear below.<br /><br />";
echo $error."<br /><br />";
echo "Please go back and fix these errors.<br /><br />";
die();
}


// validation expected data exists
if(!isset($_POST['first_name']) ||
!isset($_POST['last_name']) ||
!isset($_POST['address1']) ||
!isset($_POST['city']) ||
!isset($_POST['zip']) ||

!isset($_POST['phone'])) {
died('We are sorry, but there appears to be a problem with the form you submitted.');
}


$from = "Kupac@za_proizvode";
$headers = "From:" . $from;


$quantity_1 = $_POST['quantity_1'];
$item_name_1 = $_POST['item_name_1'];
echo " ". $quantity_1 . " " . $item_name_1 . " <br />";
$message .= " ". $quantity_1 . " " . $item_name_1 . "\n";

$quantity_2 = $_POST['quantity_2'];
$item_name_2 = $_POST['item_name_2'];
echo " ". $quantity_2 . " " . $item_name_2 . " <br />";
$message .= " ". $quantity_2 . " " . $item_name_2 . "\n";

$quantity_3 = $_POST['quantity_3'];
$item_name_3 = $_POST['item_name_3'];
echo " ". $quantity_3 . " " . $item_name_3 . " <br />";
$message .= " ". $quantity_3 . " " . $item_name_3 . "\n";

$quantity_4 = $_POST['quantity_4'];
$item_name_4 = $_POST['item_name_4'];
echo " ". $quantity_4 . " " . $item_name_4 . " <br />";
$message .= " ". $quantity_4 . " " . $item_name_4 . "\n";

$quantity_5 = $_POST['quantity_5'];
$item_name_5 = $_POST['item_name_5'];
echo " ". $quantity_5 . " " . $item_name_5 . " <br />";
$message .= " ". $quantity_5 . " " . $item_name_5 . "\n";

$quantity_6 = $_POST['quantity_6'];
$item_name_6 = $_POST['item_name_6'];
echo " ". $quantity_6 . " " . $item_name_6 . " <br />";
$message .= " ". $quantity_6 . " " . $item_name_6 . "\n";

$quantity_7 = $_POST['quantity_7'];
$item_name_7 = $_POST['item_name_7'];
echo " ". $quantity_7 . " " . $item_name_7 . " <br />";
$message .= " ". $quantity_7 . " " . $item_name_7 . "\n";

//Dodati novi proizvod

//Ukupan iznos:

$totalamount = ($_POST['amount_1'] * $_POST['quantity_1']) + ($_POST['amount_2'] * $_POST['quantity_2'])+ ($_POST['amount_3'] * $_POST['quantity_3'])
+ ($_POST['amount_4'] * $_POST['quantity_4'])+ ($_POST['amount_5'] * $_POST['quantity_5'])+ ($_POST['amount_6'] * $_POST['quantity_6'])
+ ($_POST['amount_7'] * $_POST['quantity_7']); //Dodati novi proizvod
echo "Ukupan iznos: ". $totalamount ." <br />";
$message .= "Ukupan iznos: ". $totalamount ."\n";

//Moja adresa

$first_name = $_POST['first_name'];
echo "Vase Ime: ". $first_name . " <br />";
$message .= "Vase Ime: ". $first_name . "\n";

$last_name = $_POST['last_name'];
echo "Vase Prezime: ". $last_name . " <br />";
$message .= "Vase Prezime: ". $last_name . "\n";

$address1 = $_POST['address1'];
echo "Adresa i broj: ". $address1 . " <br />";
$message .= "Adresa i broj: ". $address1 . "\n";

$city = $_POST['city'];
echo "Mesto: ". $city . " <br />";
$message .= "Mesto: ". $city . "\n";

$zip = $_POST['zip'];
echo "Poštanski broj: ". $zip . " <br />";
$message .= "Poštanski broj: ". $zip . "\n";

$country = $_POST['country'];
echo "Država: ". $country . " <br />";
$message .= "Država: ". $country . "\n";

$phone = $_POST['phone'];
echo "Kontakt tel: ". $phone . " <br />";
$message .= "Kontakt tel: ". $phone . "\n";


$error_message = "";

$string_exp = '/^((\p{L}\p{M}*)|(\p{Cc})|(\p{P}\p{P}\p{N}.{3})|(\p{N})|(\p{Zs}))+$/ui';
if(!preg_match($string_exp,$first_name)) {
$error_message .= 'The First Name you entered does not appear to be valid.<br />';
}
if(!preg_match($string_exp,$last_name)) {
$error_message .= 'The Last Name you entered does not appear to be valid.<br />';
}
if(!preg_match($string_exp,$city)) {
$error_message .= 'The Last Name you entered does not appear to be valid.<br />';
}
$string_exp = "^[0-9 .)(-]+$";
if(!eregi($string_exp,$phone)) {
$error_message .= 'The Telephone Number you entered does not appear to be valid.<br />';
}
if(!eregi($string_exp,$zip)) {
$error_message .= 'The Zip you entered does 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);
}


mail('[email protected]','On-line porudžbina',$message,$headers);

echo "Hvala na poseti!";
?>
 
Odgovor na temu

Zelenko

Član broj: 118092
Poruke: 10
*.dynamic.isp.telekom.rs.



Profil

icon Re: Form to email (čšž...)07.01.2013. u 14:52 - pre 137 meseci
Rešio sam problem unosom koda:

header('Content-Type: text/xml, charset=utf-8');
echo '<?xml version="1.0" encoding="utf-8"?>';

Medjutim treba još rešiti naslov mail-a, ne prikazuje slovo "ž"

$subject = "On-line porudžbina";

Da li neko zna rešenje?
 
Odgovor na temu

Zelenko

Član broj: 118092
Poruke: 10
*.dynamic.isp.telekom.rs.



Profil

icon Re: Form to email (čšž...)07.01.2013. u 15:08 - pre 137 meseci
Pronašao :)

Ali napisacu, mozda nekom zatreba:

mail($to, '=?utf-8?B?'.base64_encode($subject).'?=', $message, $headers);
 
Odgovor na temu

Burgos
Nemanja Borić
Amazon Web Services
Berlin

Član broj: 12484
Poruke: 1947
..106.109.adsl.dyn.beotel.net.

Sajt: stackoverflow.com/users/1..


+480 Profil

icon Re: Form to email (čšž...)07.01.2013. u 15:13 - pre 137 meseci
Probaj sa

Code:
"Subject: =?UTF-8?Q?".imap_8bit($subject)."?="


Problem je u tome što ono što si uradio ne postavlja enkoding email headera, već samo poruke.

// Kasno :).
 
Odgovor na temu

3dd13
Bosnia & Hercegowina

Član broj: 144829
Poruke: 58
46.36.161.*



Profil

icon Re: Form to email (čšž...)07.01.2013. u 15:40 - pre 137 meseci
A zasto ne koristis phpmailer klasu ?
I dont need netbsd on a toster...
 
Odgovor na temu

[es] :: PHP :: Form to email (čšž...)

[ Pregleda: 954 | Odgovora: 4 ] > FB > Twit

Postavi temu Odgovori

Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.