Jak w temacie. Modyfikuje pewny skrypt formularza kontaktowego. Przy ostatniej modyfikacji (dodaniu pola osoba kontaktowa) nie chce mi wysyłać, nie wiem czemu, postępowałem identycznie jak przy dodawaniu adres firmy. Proszę o sprawdzenie skryptu.
#contactarea {
color:white;
width:250px;
margin:0px auto;
text-align:left;
padding:15px;
border:1px solid purple;
background-color:#313131;
font-weight: bold;
font-family: Verdana, Arial;
font-size: 10px;
}
#inputbox {
color:white;
background:#313131;
border: 1px solid purple;
width: 210px;
padding: 2px;
font-weight: bold;
font-family: Verdana, Arial;
font-size: 10px;
}
#inputlabel {
font-weight: bold;
font-family: Verdana, Arial;
font-size: 10px;
}
#textarea {
color:white;
background:#313131;
border: 1px solid purple;
padding: 2px;
font-weight: bold;
font-family: Verdana, Arial;
font-size: 10px;
width:240px;
}
#submitbutton {
border: 1px solid #000;
background-color: #eee;
}
<script language="javascript">
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 adres = document.contactform.adres.value;
var osoba = document.contactform.osoba.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+'&adres='+adres+'&osoba='+osoba+'&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];
}
}
}
<form name="contactform" id="contactform"> <span id="inputlabel">Nazwa firmy:
</span> <input type="text" name="name" id="inputbox"><br /><br /> <span id="inputlabel">E-mail:
</span> <input type="text" name="email" id="inputbox"><br /><br /> <span id="inputlabel">Temat:
</span> <input type="text" name="subject" id="inputbox"><br /><br /> <input type="button" value="Wyślij" name="send" onclick="sendemail();" id="submitbutton">
i plik conntact.php
<?php
/*
Author: Andrew Walsh
Date: 30/05/2006
Codewalkers_Username: Andrew
This script is a basic contact form which uses AJAX to pass the information to php, thus making the page appear to work without any refreshing or page loading time.
*/
$to = "none@none.pl "; //This is the email address you want to send the email to
$subject_prefix = ""; //Use this if you want to have a prefix before the subject
if(!isset($_GET['action'])) {
die("Strona nie może zostać wyświetlona"); //Just to stop people from visiting contact.php normally }
/* Now lets trim up the input before sending it */
$name = trim($_GET['name']); //The senders name $email = trim($_GET['email']); //The senders email address $subject = trim($_GET['subject']); //The senders subject $message = trim($_GET['msg']); //The senders message $adres = trim($_GET['adres']); //The senders message $osoba = trim($_GET['osoba']); //The senders message
mail($to,$subject,$message,$osoba,"Adres firmy: ".$adres,"From: ".$email.""); //a very simple send
echo 'contactarea|Dziekujemy '.$name.', Twój e-mail zostal wyslany.'; //now lets update the "contactarea" div on the contact.html page. The contactarea| tell's the javascript which div to update. ?>
Ten post edytował jimy 24.06.2009, 13:57:43