Website Development Prices

Search Blog

Saturday, June 18, 2016

Preuzimanje podataka iz skrivenih kontrola (Retrieving data from hidden controls)

Skrivene kontrole omogucavaju da na web stranicama imate skrivene podatke, sto je korisno ako zelite da imate podatke o korisniku, a korisnik ne dozvoljava upotrebu kolacica. 

Primer: u skrivenoj kontroli sa imenom "skriveni_podatak" stavicemo tekst "Zdravo iz Beograda.".

HTML kod

<!DOCTYPE html>
<html>
<head>
<title>HTML forme</title>
</head>



<body>

<h2>Upotreba skrivenih kontrola</h2>
<form action="skriveni-podaci.php" method="post">
<h3>Klinknite dugme da vidite skriveni podatak</h3>
<input name="skriveni_podatak" type="hidden" value="Zdravo iz Beograda.">

<input name="pogledajte" type="submit"  Value="Pogledajte"/>
</form>

</body>

</html>

Rezultat:


Objasnjenje: podaci koji se nalaze u skrivenoj kontroli nisu vidljivi, ali kada korisnik klikne dugme, PHP skript skriveni-podaci.php moze da izvadi taj podatak i da ga prikaze.

Podaci iz skrivenih kontrola se preuzimaju pomocu imena i nizova $_GET, $_POST i $_REQUEST.

PHP kod

<!DOCTYPE html>
<html>
<head>
<title>HTML forme</title>
</head>

<body>
<h1>Preuzimanje podataka iz skrivenih kontrola</h1>

Skriveni podatak je<br /><br />

<?php
echo $_POST["skriveni_podatak"];
?>

</body>

</html>

Rezultat:



Hidden controls allow you to have hidden information on web pages, which is useful if you want to have information about the user, and the user does not allow the use of cookies.

Example: in a hidden control with the name "hidden_data" we'll put the text "Hello from Belgrade.".

HTML code

<!DOCTYPE html>
<html>
<head>
<title>HTML forms</title>

</head>
<body>

<h2>Using hidden controls</h2>
<form action="hidden-data.php" method="post">
<h3>Click the button to see the hidden data</h3>
<input name="hidden_data" type="hidden" value="Hello from Belgrade.">

<input name="click" type="submit"  Value="Click Here"/>
</form>

</body>

</html>

Result:



Explanation: data contained in hidden controls are not visible, but when the user clicks the button, a PHP script hidden-data.php can retrieve this information and displays it.

Data from the hidden controls can be retrieved using the names and arrays $_GET, $_POST and $_REQUEST.

PHP code

<!DOCTYPE html>
<html>
<head>
<title>HTML forms</title>
</head>

<body>
<h1>Retrieving data from hidden controls</h1>

Hidden data is<br /><br />

<?php
echo $_POST["hidden_data"];
?>

</body>

</html>

Result:




No comments:

Post a Comment

Note: Only a member of this blog may post a comment.