Hi all,
I have a problem with a contact form. Everything behaves as it should except that it truncates the message so that after about 300 characters the message is cut off (even though it shows in the form field. Code is below.
Thanks!
------------------ form------------------
------------------processor------------------
------------------js.------------------
I have a problem with a contact form. Everything behaves as it should except that it truncates the message so that after about 300 characters the message is cut off (even though it shows in the form field. Code is below.
Thanks!
------------------ form------------------
Code:
<form name="contactform" id="contactform" method="post" action="contact.php"> <span class="inputlabel">Name:</span><br /> <input name="name" type="text" class="searchbox" id="name" size="24" maxlength="50" /> <span class="inputlabel">Email:</span><br /> <input name="email" type="text" class="searchbox" id="email" size="24" maxlength="30" /> <span class="inputlabel">Organisation (if appropriate):</span><br /> <input type="text" name="subject" class="searchbox" id="subject" size="24" /> <span class="inputlabel">Your message:</span><br /> <textarea name="msg" cols="45" rows="8" id="textarea"></textarea> <br /> <input type="button" value="Send email" name="send" onclick="sendemail();" id="submitbutton" /> </form>
Code:
<?php
$to = "xxx@xxx.xx.xx";
$subject = "From the website"; //Use this if you want to have a prefix before the subject
if(!isset($_GET['action']))
{
die("You must not access this page directly!");
}
$name = trim($_GET['name']); //The senders name
$email = trim($_GET['email']); //The senders email address
$message = trim($_GET['msg']); //The senders message
mail($to,$subject,$message,"From: ".$email.""); //a very simple send
echo 'form|<h4> Dear '.$name.', <br /><br />Thank you for your message. We check our email regularly and will be in touch shortly. </h4>';
?>
Code:
function createRequestObject() {
var ro;
var browser = navigator.appName;
if(browser == "Microsoft Internet Explorer"){
ro = new ActiveXObject("Microsoft.XMLHTTP");
}else{
ro = new XMLHttpRequest();
}
return ro;
}
var http = createRequestObject();
function sendemail() {
var msg = document.contactform.msg.value;
var name = document.contactform.name.value;
var email = document.contactform.email.value;
var subject = document.contactform.subject.value;
document.contactform.send.disabled=true;
document.contactform.send.value='Sending....';
http.open('get', 'contact.php?msg='+msg+'&name='+name+'&subject='+subject+'&email='+email+'&action=send');
http.onreadystatechange = handleResponse;
http.send(null);
}
function handleResponse() {
if(http.readyState == 4){
var response = http.responseText;
var update = new Array();
if(response.indexOf('|' != -1)) {
update = response.split('|');
document.getElementById(update[0]).innerHTML = update[1];
}
}
Comment