Necu biti detaljan ali cu ti dati nekakve hintove.
PHP nije client side jezik. To je server side jezik tako da isti nema mogucnosti da imas recimo ovako nesto include('filename', 3000 ); pa da ti svake 3 sekunde refresha fajl. Dakle, takvu pizdariju neces moc izvest sa php-om osim ako imas namjeru hackat zend core i takve stvari radit no anyway. Imas takozvani JavaScript i AJAX (
http://jquery.com kao primjer ) Jedan od primjera bi ti bio ovakav.
Recimo da imas formu i zelis poslat na server 1 text input sa nekakvim sadrzajem.
PHP FILE kojemu mozes pristupit sa recimo
http://localhost/phpfajl.php $input = $_POST['textinput'];
if(! $input ){
return json_encode ( array (
'state' => 'error',
'msg' => "Nisi unjeo nikakav sadzaj textinputa"
));
}
return json_encode ( array (
'state' => 'success',
'msg' => "Sadrzaj textinputa je: {$input}"
));
I sada ide HTML File
Prvo moras importat u stage jquery-ev bazni fajl kojeg si skinuo sa onog jquery.com.
Onda si skines ovaj tu recimo plugin
http://malsup.com/jquery/form/#code-sampleste i njega ispod nakon sto si napravio
<script type="text/javascript" src="
http://localhost/jquery-1.2.3.js" />
stavis i taj samo da je na kraju form.js
I onda si napravis vako
<script type="text/javascript">
var options = {
target: '', // target element(s) to be updated with server response
beforeSubmit: signoutRequest, // pre-submit callback
success: signoutResponse, // post-submit callback
// other available options:
//url: url // override for form's 'action' attribute
type: 'post', // 'get' or 'post', override for form's 'method' attribute
dataType: 'json' // 'xml', 'script', or 'json' (expected server response type)
//clearForm: true // clear all form fields after successful submit
//resetForm: true // reset the form after successful submit
// $.ajax options can be used here too, for example:
//timeout: 3000
};
// bind form using 'ajaxForm'
$j('#form_id').ajaxForm(options);
// pre-submit callback
function signoutRequest(formData, jqForm, options) {
// formData is an array; here we use $.param to convert it to a string to display it
// but the form plugin does this for you automatically when it submits the data
var queryString = $j.param(formData);
// here we could return false to prevent the form from being submitted;
// returning anything other than false will allow the form submit to continue
return true;
}
// post-submit callback
function signoutResponse(data, statusText) {
if( data.state == 'error' )
{
alert( "Error: "+data.msg );
}
else if ( data.state == 'success' )
{
alert( "Success: "+data.msg );
}
}
</script>
<form id="form_id" method="POST" action="http://localhost/phpfajl.php">
<input type="text" id="textinput" name="textinput" tabindex="1" />
<button type="submit" name="form_btn" id="form_btn" tabindex="2">Posalji</button>
</form>
I to bi ti trebao biti to. Igraj se uglavnom. Ovo ti je jedan od primjera.