PHP: Wataalam Nahitaji Maelezo

ni kweli hata baada ya submit button values hazibadiliki(haziwi empty) na hata nikireload page baada ya kujaza textbox(bila ku submit) values hazibadiliki kuwa empty!
Baadaya ya kufanay business logic yako zi reset values zote kama ni strings to NULL n.k, pia kabla hauja display form kwa mara ya kwanza makesure hizo values zipo NULL, ni kitu kidogo tu aisee.
 
Baadaya ya kufanay business logic yako zi reset values zote kama ni strings to NULL n.k, pia kabla hauja display form kwa mara ya kwanza makesure hizo values zipo NULL, ni kitu kidogo tu aisee.

sijajaza chochote as its values. They are empty. Kinachotokea ni kwamba, i just set lets say

PHP:
$username=$_POST['username'];
Na textbox nyingine hivyo hivyo. Yaani ni kama facebook pale kwenye home page yao, ujaze fields zake. Lakini bila hata kuclick submit ukirefresh zile field haziwi empty but ninarudi na input zako. Umenielewa Mkuu?
 
PHP:
<?php

// some code
// some code

header('Location:http://www.page_yeyote.php');
?>


Unachotakiwa kufanya ni kuredirect browser kwenye page yeyote baada ya kutuma POST data yaani kwa ku-redirect header. Page yeyote inaweza kuwa ni ile ile ya kutumia form.
 
PHP:
<?php

// some code
// some code

header('Location:http://www.page_yeyote.php');
?>


Unachotakiwa kufanya ni kuredirect browser kwenye page yeyote baada ya kutuma POST data yaani kwa ku-redirect header. Page yeyote inaweza kuwa ni ile ile ya kutumia form.

ok mkuu, in kiswahili?
 
namaanisha sijaelewa 'kidogo'.

Let explain it in plain English

When you redirect a page the POST data is not populated (not passed on to another page) , so a simple trick to clear the form fields after your data has been sent is to redirect to your original page . So let say you have two files form.html and process_form.php. Also say form.html is a registration page that is used to send data (name, email, address etc) to process_form.php to be processed.

You mentioned earlier that you want your form fields to be clear when you refresh, in other words you want your header to have no POST data after executing process_form.php. You do that by placing the code below at the end of your process_form.php code to free your header from POST data.
PHP:
header('Location:http://www.your_domain.com/form.html');
 
Let explain it in plain English

When you redirect a page the POST data is not populated (not passed on to another page) , so a simple trick to clear the form fields after your data has been sent is to redirect to your original page . So let say you have two files form.html and process_form.php. Also say form.html is a registration page that is used to send data (name, email, address etc) to process_form.php to be processed.

You mentioned earlier that you want your form fields to be clear when you refresh, in other words you want your header to have no POST data after executing process_form.php. You do that by placing the code below at the end of your process_form.php code to free your header from POST data.
PHP:
header('Location:http://www.your_domain.com/form.html');

thanks!
 
Back
Top Bottom