Wszystko działa super, aczkolwiek musiałem wywalić Ajax'a, teraz 'nie ładnie' się wyświetla, u tu moje pytanie, czy jest możliwość edycji powyższego skryptu, aby zapisywał dane i działał pięknie z Ajax'em?
index.php<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <!--
body {
background-color: #000000;
}
body,td,th {
color: #FFFFFF;
}
-->
<script type="text/javascript" language="javascript" src="ajax.js"></script>
<div align="center"><h2>Skrypt
</h2> <form action="javascript:get(document.getElementById('acctform'));" name="acctform" id="acctform"> <textarea rows="1" cols="1" style="width: 50%; height: 140px" id="accounts"></textarea> <br />username : password
</p><p> <input type="submit" name="button" value="Sprawdz" onclick="return Tab_Click(this)">
ajax.jsvar http_request = false;
function makePOSTRequest(url, parameters) {
http_request = false;
if (window.XMLHttpRequest) {
http_request = new XMLHttpRequest();
if (http_request.overrideMimeType) {
http_request.overrideMimeType('text/html');
}
} else if (window.ActiveXObject) {
try {
http_request = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
http_request = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {}
}
}
if (!http_request) {
alert('Cannot create XMLHTTP instance');
return false;
}
http_request.onreadystatechange = alertContents;
http_request.open('POST', url, true);
http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
http_request.setRequestHeader("Content-length", parameters.length);
http_request.setRequestHeader("Connection", "close");
http_request.send(parameters);
}
function alertContents() {
if (http_request.readyState == 4) {
if (http_request.status == 200) {
result = http_request.responseText;
document.getElementById('waiting').innerHTML = '';
document.getElementById('showresults').innerHTML = result;
} else {
alert('There was a problem with the request.');
}
}else{
document.getElementById('waiting').innerHTML = '
<img src="loading.gif">';}
}
function get(obj) {
var poststr = "accounts=" + encodeURI( document.getElementById("accounts").value );
makePOSTRequest('skrypt.php', poststr);
}
skrypt.php<?php
if (isset ($_POST['accounts'])) { $dtaaccounts = nl2br($dtaaccounts); $dtaaccounts = explode("\n", $_POST['accounts']); //Header
echo "<table font-size=1 width=\"90%\" border=1 cellspacing=\"0\" cellpadding=\"5\">". "<tr><th>Username</th><th>Password</th><th>Email</th><th>Points</th><th>TrafficShare</th><th>Traffic left</th><th>Traffic (+)</th><th>Used storage</th><th>Validity</th><th>Security Lock</th></tr>";
[i]dalej reszta kodu[/i], [i]ale on już potrzebny nie będzie[/i]
?>