18-09-2009, 02:04
(Ten post był ostatnio modyfikowany: 18-09-2009, 02:07 przez milanista7.)
Cześć, mam problem z instalacją skryptu kontaktu mailowego w php.
Nie wiem co robię źle że skrypt nie działa - tzn wszystko na stronie jest ok i formularz działa, potem jest komunikat że wiadomość wysłana . Ale nic nie dochodzi
To umieściłem w HEAD działu kontakt.html ( czyli tam gdzie mam ten formularz)
Tak jak kazał autor tego skryptu w instrukcjach.
A o to kod skryptu contact.php ( jest w osobnym pliku)
No i te dwa pliki ( kontakt.html i contact.php ) umieściłem na serwerze. Po czym ze strony próbowałem wysłać maila. Niestety bezskutecznie. Trzy razy próbowałem i nic. nie doszło.
aha jest jeszcze to. nie wiem czy to coś pomoże
Nie wiem co robię źle że skrypt nie działa - tzn wszystko na stronie jest ok i formularz działa, potem jest komunikat że wiadomość wysłana . Ale nic nie dochodzi

To umieściłem w HEAD działu kontakt.html ( czyli tam gdzie mam ten formularz)
Kod:
<style type="text/css">
body {
margin:50px 0px; padding:0px;
text-align:center;
}
#contactarea {
width:350px;
margin:0px auto;
text-align:left;
padding:15px;
border:1px solid #333;
background-color:#b9e58b;
font-weight: bold;
font-family: Verdana, Arial;
font-size: 12px;
}
#inputbox {
border: 1px solid #000;
width: 180px;
padding: 2px;
font-weight: bold;
font-family: Verdana, Arial;
font-size: 12px;
}
#inputlabel {
font-weight: bold;
font-family: Verdana, Arial;
font-size: 12px;
}
#textarea {
border: 1px solid #000;
padding: 2px;
font-weight: bold;
font-family: Verdana, Arial;
font-size: 12px;
width: 300px;
}
</style>
<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 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='Wysyłanie...';
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];
}
}
}
</script>
Tak jak kazał autor tego skryptu w instrukcjach.
A o to kod skryptu contact.php ( jest w osobnym pliku)
Kod PHP:
<?php
/*
Author: Andrew Walsh
Date: 30/05/2006
Codewalkers_Username: Andrew
*/
$to = "TUTAJ JEST MÓJ ADRES E-MAIL"; //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("You must not access this page directly!"); //Just to stop people from visiting contact.php normally
}
/* Now lets trim up the input before sending it */
$name = trim($_GET['Imię']); //The senders name
$email = trim($_GET['email']); //The senders email address
$subject = trim($_GET['temat']); //The senders subject
$message = trim($_GET['wiadomosc']); // Te cztery pozycje sobie skonfigurowałem, właśnie nie wiem czy można .
mail($to,$subject,$message,"From: ".$email.""); //a very simple send
echo 'contactarea|Dziękujemy '.$name.', twój e-mail został wysłany'; //now lets update the "contactarea" div on the contact.html page. The contactarea| tell's the javascript which div to update.
?>
aha jest jeszcze to. nie wiem czy to coś pomoże

Kod:
<div id="contactarea">
<div align="center"><form name="contactform" id="contactform">
<span id="inputlabel">Imię: </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 />
<span id="inputlabel">Wiadomość:</span><br />
<textarea name="msg" rows="10" id="textarea"></textarea>
<br /><br />
<input type="button" a class="art-button" value="Wyślij!" name="send" onclick="sendemail();" id="submitbutton">