Ajax:
<?php function form(AForm) { if ((!AForm.user.value) || (AForm.user.value.length < 4)) { alert("Podaj nick, conajmniej 4 znaki!"); return false; } if ((!AForm.wiadomosc.value) || (AForm.wiadomosc.value.length < 10)) { alert("Minimalna dlugosc wiadomosci to 10 znakow!"); return false; } if (AForm.wiadomosc.value.length > 10){ var http; var browser = navigator.appName; if(browser == "Microsoft Internet Explorer"){ http = new ActiveXObject("Microsoft.XMLHTTP"); } else { http = new XMLHttpRequest(); } http.open('get', 'dodaj.php?not='+document.getElementById('Comment').value,true); http.onreadystatechange = function() { if (http.readyState == 4) { if (http.responseText == "1") { alert('Komentarz zostal dodany'); return false; } else if (http.responseText == "2") { alert('Wystaplil blad'); return false; } } } http.send(null); } return true; } ?>
dodaj.php
<? require_once('config.php'); $not = $_GET['not']; { $zapytanie = "INSERT INTO `komentarze` VALUES('', '', '$not')"; if($wykonaj) { } else { } } else { }; ?>