AgerNic.com/ro
WEB DEVELOPER SITE, HTML, CSS, PHP, SQL
Tutorial

Tutorial PHP» PHP GET POST

Variabilele super globale sunt variabile īncorporate, care sunt īntotdeauna disponibile īn toate domeniile.
Exist? dou? modalit??i prin care clientul browserului poate trimite informa?ii serverului web.

Metoda GET
Metoda POST

Īnainte ca browserul s? trimit? informa?iile, aceasta o codific? folosind o schem? numit? codare URL. Īn aceast? schem?, perechile nume / valoare sunt unite cu semne egale ?i perechi diferite sunt separate de ampersand (semnul &)

Exemplu:
name1=value1&name2=value2&name3=value3

Metoda GET
Metoda GET trimite informa?iile de utilizator codate anexate la solicitarea paginii. Pagina ?i informa?iile codate sunt separate de ? caracter.

http://www.test.com/index.htm?name1=value1&name2=value2
Metoda GET produce un ?ir lung care apare īn jurnalele serverului dvs., īn caseta Loca?ia browserului: caseta.
Metoda GET este restric?ionat? pentru a trimite numai pān? la 1024 de caractere.
Nu folosi?i niciodat? metoda GET dac? ave?i parola sau alte informa?ii sensibile pentru a fi trimise serverului.
GET nu poate fi utilizat pentru a trimite date binare, cum ar fi imagini sau documente word, c?tre server.
Datele trimise prin metoda GET pot fi accesate folosind variabila de mediu QUERY_STRING.
PHP ofer? matrice asociativ? $ _GET pentru a accesa toate informa?iile trimise folosind metoda GET.
Īncerca?i s? urma?i exemplul punānd codul surs? īn scriptul test.php.
<?php
if( $_GET["name"] || $_GET["age"] ) {
echo "Welcome ". $_GET['name']. "<br />";
echo "You are ". $_GET['age']. " years old.";
exit();
}
?>
<html>
<body>

<form action = "<?php $_PHP_SELF ?>" method = "GET">
Name: <input type = "text" name = "name" />
Age: <input type = "text" name = "age" />
<input type = "submit" />
</form>

</body>
</html>

Metoda POST

Metoda POST transfer? informa?ii prin anteturile HTTP. Informa?iile sunt codate a?a cum este descris īn cazul metodei GET ?i introduse īntr-un antet numit QUERY_STRING.
Metoda POST nu are nicio restric?ie privind dimensiunea datelor care trebuie trimise.
Metoda POST poate fi utilizat? pentru a trimite ASCII, precum ?i date binare.
Datele trimise prin metoda POST trec prin antetul HTTP, astfel īncāt securitatea depinde de protocolul HTTP. Folosind Secure HTTP v? pute?i asigura c? informa?iile dvs. sunt sigure.
PHP ofer? matrice asociativ? $ _POST pentru a accesa toate informa?iile trimise folosind metoda POST.
Īncerca?i s? urma?i exemplul punānd codul surs? īn scriptul test.php.

<?php
if( $_POST["name"] || $_POST["age"] ) {
if (preg_match("/[^A-Za-z'-]/",$_POST['name'] )) {
die ("invalid name and name should be alpha");
}
echo "Welcome ". $_POST['name']. "<br />";
echo "You are ". $_POST['age']. " years old.";

exit();
}
?>
<html>
<body>

<form action = "<?php $_PHP_SELF ?>" method = "POST">
Name: <input type = "text" name = "name" />
Age: <input type = "text" name = "age" />
<input type = "submit" />
</form>

</body>
</html>
Tags: PHP $_GET si $_POST, metoda GET, POST

Online Editor
ONLINE EDITOR

news templates


COLOR PICKER

news templates
This tool makes it easy to create, adjust, and experiment with custom colors for the web.


HTML Templates
news templates
Magnews2 is a modern and creative free magazine and news website template that will help you kick off your online project in style.


CSS HTML Layout
news templates
Find here examples of creative and unique website layouts.


Free CSS HTML Menu
news templates
Find here examples of creative and unique website CSS HTML menu.


Online Editor
ONLINE EDITOR

news templates


COLOR PICKER

news templates
This tool makes it easy to create, adjust, and experiment with custom colors for the web.


HTML Templates
news templates
Magnews2 is a modern and creative free magazine and news website template that will help you kick off your online project in style.


CSS HTML Layout
news templates
Find here examples of creative and unique website layouts.


Free CSS HTML Menu
news templates
Find here examples of creative and unique website CSS HTML menu.


analytics piwika