Website Development Prices

Search Blog

Tuesday, June 7, 2016

Upotreba polja za unos teksta (Using a text fields)

Polja za unos teksta su kontrole u kojima korisnik moze da unese jedan red teksta. Prave se pomocu oznake <input type="text">, koja se nalazi u okviru oznake <form>.

Primer: jedna HTML strana, sa formom, prikazivace polje za unos teksta. Pomocu te strane cemo slati tekst koji se unese u polju za unos teksta. PHP skript ce da cita podatke koje je korisnik uneo i prikazace taj tekst na novoj strani. 

U ovom primeru cemo traziti ime omiljenog motora. Polje za unos teksta cemo nazvati ime-motora, koje se pravi pomocu atributa name. U sledecem clanku cemo koristiti to ime motora u PHP kodu da bismo preuzeli podatke koje je korsnik uneo.

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


<body>
<h1>Upotreba polja za unos teksta</h1>

<form method="post" action="phptekst.php">
<h3>Koji je vas omiljen motor?</h3>
<input name="ime-motora" type="text">
<br /><br />
<input type="submit" value="Posaljite">
</form>
</body>

</html>

Sacuvajte ovaj fajl kao phptekst.html, u folderu htdocs, foldera xampp. U mom primeru, putanja je C:/xampp2/htdocs/PHPtuts/polje-za-unos-teksta/phptekst.html.

Rezultat: 



Fajl phptekst.php napravicemo u sledecem clanku.

Text fields are controls in which the user can enter one line of text. They are made using the tag <input type = "text">, which is located within the tag <form>.

Example: an HTML page, with the form, will display text field. Using that page we will send the text that is entered in the text field. PHP script will read data that the user has entered and will show the text on a new page.

In this example, we will ask for the name of your favorite motorcycle. Text field we will call motorcycle-name, which is made by using the attribute name. In the next article we will use this motorcycle name in the PHP code in order to retrieve data that is entered by that user.

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

<body>
<h1>Using a text fields</h1>

<form method="post" action="phptext.php">
<h3>What's your favorite motorcycle?</h3>
<input name="motorcycle-name" type="text">
<br /><br />
<input type="submit" value="Send">
</form>
</body>

</html>

Save this file as phptext.html, in the htdocs folder, in the folder xampp. In my example, the path is C:/xampp2/htdocs/PHPtuts/text-field/phptext.html.

Result:





The file phptext.php we will make in the next article.

No comments:

Post a Comment

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