Gå til innhold

problemer med øæå i ajax kontaktskjema


Anbefalte innlegg

Videoannonse
Annonse

index fila:

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="nor" lang="nor">
<head>
<meta Content-Type: text/html; charset=UTF-8 />
<title>Ajax contact form</title>
<link href="style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="mootools.js"></script>
<script type="text/javascript">
	window.addEvent('domready', function(){
		$('myForm').addEvent('submit', function(e) {

		new Event(e).stop();
		var log = $('log_res').empty().addClass('ajax-loading');
		this.send({
			update: log,
			onComplete: function() {
				log.removeClass('ajax-loading');
			}
		});
		});		
	});
</script>
</head>
<body>
<div id="log">
<div id="log_res">
	<!-- spanner -->
</div>
</div>
<form id="myForm" action="send.php" method="get" name="myForm">
<div id="form_box">
	<div>
		<p>
			First Name:
		</p><input type="text" name="first_name" value="" />
	</div>
	<div>
		<p>
			Last Name:
		</p><input type="text" name="last_name" value="" />
	</div>
	<div>
		<p>
			E-Mail:
		</p><input type="text" name="e_mail" value="" />
	</div>
	<div>
		<p>
			Message:
		</p><textarea name="message" cols="40" rows="5"></textarea>
	</div>
	<div class="hr">
		<!-- spanner -->
	</div><input type="submit" name="button" id="submitter" /></div>
</form>
</body>
</html>

 

send fila:

<?php
error_reporting(E_NOTICE);

function valid_email($str)
{
	return ( ! preg_match("/^([a-å0-9\+_\-]+)(\.[a-å0-9\+_\-]+)*@([a-å0-9\-]+\.)+[a-å]{2,6}$/ix", $str)) ? FALSE : TRUE;
}

if($_POST['first_name']!='' && $_POST['last_name']!='' && $_POST['e_mail']!='' && valid_email($_POST['e_mail'])==TRUE && strlen($_POST['message'])>30)
{
	$to = '[email protected]';
	$headers = 	'From: '.$_POST['e_mail'].''. "\r\n" .
			'Reply-To: '.$_POST['e_mail'].'' . "\r\n" .
			'X-Mailer: PHP/' . phpversion();
	$subject = "BB Elektro AS webmail kontakt skjema";
	$message = htmlspecialchars($_POST['message']);

	if(mail($to, $subject, $message, $headers))
	{//we show the good guy only in one case and the bad one for the rest.
		echo 'Thank you '.$_POST['first_name'].'. Your message was sent';
	}
	else {
		echo "Message not sent. Please make sure you're not
			running this on localhost and also that you 
			are allowed to run mail() function from your webserver";
	}
}
else {
	echo 'Please make sure you filled all the required fields, 
	that you entered a valid email and also that your message 
	contains more then 30 characters.';
}
?> 

 

Etter det eg forstår er det utf-8. Men det virker jo ikkje sånn som det skal.

 

Kossen setter eg utf-8 i "send-options" og header ?

Lenke til kommentar

Opprett en konto eller logg inn for å kommentere

Du må være et medlem for å kunne skrive en kommentar

Opprett konto

Det er enkelt å melde seg inn for å starte en ny konto!

Start en konto

Logg inn

Har du allerede en konto? Logg inn her.

Logg inn nå
  • Hvem er aktive   0 medlemmer

    • Ingen innloggede medlemmer aktive
×
×
  • Opprett ny...