Website Development Prices

Search Blog

Wednesday, August 17, 2016

Preuzimanje podataka sa forme u korisnickim nizovima (Retrieving data from the form in the users arrays)

PHP omogucava da podatke koje dobijete sa forme organizujete u svoje nizove. 

Primer: ako od korisnika treba da saznate ime i omiljen motor i da se podaci unesu kao $podaci['ime'] $podaci['motor']. Svakom polju za unos teksta dacete ime u uglastim zgradama, kao npr., tekst[ime] i tekst[motor].

HTML kod


<!DOCTYPE html>
<html>
<head>
<title>Web forme i validacija unosa korisnika</title>
</head>


<body>
<h1>Preuzimanje podataka sa forme u korisnickim nizovima</h1>
<h2>Upotreba tekst polja</h2>

<form method="post" action="upotreba-korisnickih-nizova.php">
<h3>Kako se zovete?</h3>
<input type="text" name="tekst[ime]">
<br /><br />
<h3>Koji je vas omiljen motor?</h3>
<input type="text" name="tekst[motor]">
<br /><br />
<input type="submit" value="Posaljite">
</form>
</body>
</html>

Sacuvajte ovaj fajl kao upotreba-korisnickih-nizova.html, u folderu htdocs, foldera xampp. U mom primeru, putanja je C:/xampp2/htdocs/PHPtuts/upotreba-korisnickih-nizova/upotreba-korisnickih-nizova.html.

Rezultat:


PHP kod


<!DOCTYPE html>
<html>
<head>
<title>Web forme i validacija unosa korisnika</title>
</head>

<body>
<h1>Preuzimanje podataka sa forme u korisnickim nizovima</h1>

Vase ime je 

<?php
$podaci = $_REQUEST['tekst'];
echo $podaci['ime'], "<br />";
?>
Vas omiljen motor je

<?php
$podaci = $_REQUEST['tekst'];
echo $podaci['motor'], "<br />";
?>

</body>
</html>

Sacuvajte ovaj fajl kao upotreba-korisnickih-nizova.php u istom folderu kao i upotreba-korisnickih-nizova.html.

Rezultat:



PHP enables that information you get from the forms you can organize in your arrays.

Example: if from the user you need to find out the name and favorite motorcycle and that the data is entered as $data ['name'] and $data ['motorcycle']. To each text field you want to give the name in the brackets, such as, text[name] and text[motorcycle].

HTML code


<!DOCTYPE html>
<html>
<head>
<title>Web forms and validation of user input</title>
</head>

<body>
<h1>Retrieving data from the form in the users arrays</h1>
<h2>Using text fields</h2>

<form method="post" action="using-users-arrays.php">
<h3>What is your name?</h3>
<input type="text" name="text[name]">
<br /><br />
<h3>What is your favorite motorcycle?</h3>
<input type="text" name="text[motorcycle]">
<br /><br />
<input type="submit" value="Send">
</form>
</body>
</html>

Save this file as the using-users-arrays.html-in htdocs folder, in the folder xampp. In my example, the path is C:/xampp2/htdocs/PHPtuts/using-users-arrays/using-users-arrays.html.

Result:


PHP code

<!DOCTYPE html>
<html>
<head>
<title>Web forms and validation of user input</title>
</head>

<body>
<h1>Retrieving data from the form in the users arrays</h1>

Your name is

<?php
$data = $_REQUEST['text'];
echo $data['name'], "<br />";
?>
Your favorite motorcycle is

<?php
$data = $_REQUEST['text'];
echo $data['motorcycle'], "<br />";
?>

</body>
</html>

Save this file as using-users-arrays.php in the same folder as the using-users-arrays.html.


Result:



No comments:

Post a Comment

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