Benötigt Jquery
ist der code von http://www.losestatistik.de/ Loginformular
Code:
function sendefuk() {
//Daten von den HTML Feldern in JS-Vars Übersetzen
var efuk_id = escape(document.getElementsByName( 'efuk_id' )[0].value);
var efuk_stat = escape(document.getElementsByName( 'efuk_stat' )[0].value);
var efuk_art = escape(document.getElementsByName( 'efuk_art' )[0].checked);
var data = 'a=efuk&b=' + efuk_id + '&c=' + efuk_stat + '&d=' + efuk_art;
//Request abschicken
$.ajax({
url: "ajax/register.php",
type: "POST",
data: data,
success: function (reqCode) {
if (reqCode!=1) {
var dives = 'ajax_formular_efuk';
if(document.getElementById( dives ).innerHTML){
document.getElementById( dives ).innerHTML = reqCode;
}
}else{
alert('Fehler beim Abschicken des Formulares.');
}
}
});
return false;
}
PHP-Code:
<form method="POST" onsubmit="return false;">
<ul id="ajax_formular_efuk">
<li>Klamm-ID / EF-ID</li>
<li><input type="text" name="efuk_id" placeholder="Klamm/EF-ID"/> </li>
<li>Satistik-PW</li>
<li><input type="password" name="efuk_stat" placeholder="Statistik Passwort"/></li>
<li><input type="radio" name="efuk_art" value="klamm" checked="checked"> Klamm Account</li>
<li><input type="radio" name="efuk_art" value="ef"> EF Account</li>
<li><input type="submit" name="efuk_eintrag" value="Eintragen / Login" onclick="sendefuk();" /></li>
<li style="font-size:10px; line-height:12px;">Nach dem Absenden kann alles eingestellt<br> werden, was Ausgegeben werden darf. </li>
</ul>
</form>
PHP-Code:
if( !isset( $_POST['a'] ) ) $_POST['a'] = FALSE;
if( !isset( $_POST['b'] ) ) $_POST['b'] = FALSE;
if( !isset( $_POST['c'] ) ) $_POST['c'] = FALSE;
if( !isset( $_POST['d'] ) ) $_POST['d'] = FALSE;