Witam, mam taki oto problem. Skopiowałem z mojego innego formularza skrypt, który sprawdza formularz i wysyła maila.
Skopiowałem na nowo stworzoną stronę i tu pojawia się problem. Skrypt wysyła maila wtedy, gdy wszystkie dane są wpisane niekoniecznie poprawni.
Natomiast nie wyświetla, że coś jest nie wpisane. Domyślam się, że to jakiś problem z JS. w pliku JS nic nie zmieniałem, na innych
formularzach działa. Z tym, że inne są na stronie index.php a ten jest na formularz.php? Czy to jest jakiś problem?
Podaję kod formularza, może ktoś mi pomoże.
<?
if($imie!="" && $nazwisko!="" && $telefon!="" && $email!="" && $wiadomosc!=""){
include('../wysylka/classes.php');
include('../wysylka/htmlMimeMail.php');
$from = "xx@xx.pl";
$from1 = "xx@xx.pl";
$to[] = "xx.xx@xx.pl";
$body_txt = "\n\n";
$subject = "[xx.pl] formularz kontaktowy";
$body_txt .= "\nImię i nazwisko: ".$imie." ".$nazwisko;
$body_txt .= "\nTelefon: ".$telefon;
$body_txt .= "\nEmail: ".$email;
$body_txt .= "\nTreść zapytania:";
$body_txt .= "\n".$wiadomosc;
$body_txt .= "\n\nstrona:".$_SERVER['SERVER_NAME'].$_SERVER['SCRIPT_NAME'];
$return_path = $email;
wysylka_maila($subject, $from, $from1, $to, $dw, $body_html, $body_txt, $att, $att_name, $mimetype, $return_path);
//koniec wysłanie maila
$komentarz_wysylka = "Twoje zapytanie zostało wysłane, dziękujemy.";
}
//print_r($_SERVER);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" type="text/css" href="styles.css" />
</head>
<body>
<script type="text/javascript">
var url = String(document.location);
if(url.match(/index\.html\?true/) != null) {
alert('Wysłano wiadomość.');
} else if(url.match(/index\.html\?false/) != null){
alert('Nie udało się wysłać wiadomości.');
}
</script>
<div id="wrapper">
<div id="top" class="clear">
<h1><a href="index.php">tytul</a></h1>
</div>
<div id="body" class="clear">
<div id="sidebar" class="column-left">
<ul>
<li>
<h4>MENU</h4>
<ul>
<?php
include_once ('include/menu.php');
?>
</ul>
<br />
</ul>
</div>
<div id="content" class="column-right">
<h2></h2>
<form method="post" action="" onsubmit="return validate(this);">
<table>
<tr>
<td width="35%">Imię: </td>
<td><input type="text" name="imie" id="imie" /><br />
<span class="error" id="ie">Musisz podać swoje imię!</span></td>
</tr>
<tr>
<td>Nazwisko: </td>
<td><input type="text" name="nazwisko" id="nazwisko" /><br />
<span class="error" id="ne">Musisz podać swoje nazwisko!</span></td>
</tr>
<tr>
<td>Telefon: </td>
<td><input type="text" name="telefon" onkeydown="return onlyNumbers(event)" id="telefon" maxlength="9" /><br />
<span class="error" id="te">Musisz podać nr telefonu! (9-cyfr)</span></td>
</tr>
<tr>
<td>E-mail: </td>
<td><input type="text" name="email" id="email" /><br />
<span class="error" id="ee">Musisz podać adres mailowy!</span></td>
</tr>
<tr>
<td style="vertical-align: top;">Wiadomość: </td>
<td><textarea name="wiadomosc" id="wiadomosc" rows="10" cols="10"></textarea><br />
<span class="error" id="we">Musisz podać treść wiadomości! (min. 30 znaków)</span></td>
</tr>
<tr><td> </td><td><input type="image" src="images/send.png" /></td></tr>
</table>
<div class="inline"><input type="checkbox" id="zgoda" name="zgoda" /></div>
<div class="inline2">Wyrażam zgodę na przetwarzanie Moich danych osobowych na zasadach określonych w regulaminie. Pełna treść <a href="#">REGULAMINU</a><br />
<span class="error" id="ze">Musisz wyrazić zgodę!</span></div>
</form>
<br /><br />
</div>
</div>
<div id="footer" class="clear">
<div class="footer-box">
</div>
<div class="footer-box">
<h4>Polecamy:</h4>
<ul>
<?php
include_once ('include/polecamy.php');
?>
</ul>
</div>
<div class="footer-box">
<h4>Podstrony</h4>
<ul>
<?php
include_once ('include/menu_dol.php');
?>
</ul>
</div>
</div>
<div id="footer-links">
<p>
© 2012 Design by <a href="http://www.spyka.net">Free CSS Templates</a>
</p>
</div>
</div>
<?
if($komentarz_wysylka!=""){
?>
<script language="JavaScript">
<!--
alert("
<?echo $komentarz_wysylka;?>");
window.location='http://
<?echo $_SERVER['SERVER_NAME'].str_replace("index.php", "", $_SERVER['SCRIPT_NAME']);?>';
//-->
</script>
<?
}
?>
</body>
</html>