Podatke mozete poslati u PHP skript pomocu atributa value dugmeta submit. Ova vrednost se moze procitati u PHP skriptu, zbog cega ne morate da koristite skrivene kontrole za slanje podataka.
Primer: ovo cete dobiti ako svakom dugmetu submit date isto ime, u ovom primeru to je "mojedugme3", a ime dugmeta dodelite atributu value:
<form name="forma1" action="php-dugmad-3.php" method="post">
<input type="submit" name="mojedugme3" value="dugme 1">
</form>
HTML kod
<!DOCTYPE html>
<html>
<head>
<title>HTML forme</title>
</head>
<body>
<h1>Upotreba dugmadi 3</h1>
<h3>Upotreba dugmadi pomocu atributa Value dugmeta Submit</h3>
<form name="forma1" action="php-dugmad-3.php" method="post">
<input type="submit" name="mojedugme3" value="dugme 1">
</form>
<br />
<form name="forma2" action="php-dugmad-3.php" method="post">
<input type="submit" name="mojedugme3" value="dugme 2">
</form>
<br />
<form name="forma3" action="php-dugmad-3.php" method="post">
<input type="submit" name="mojedugme3" value="dugme 3">
</form>
</body>
</html>
Sacuvajte ovaj fajl kao php-dugmad-3.html, u folderu htdocs, foldera xampp. U mom primeru, putanja je C:/xampp2/htdocs/PHPtuts/phpdugme3/php-dugmad-3.html.
Rezultat:
U PHP skriptu treba da proverite vrednost kontrole sa imenom "mojedugme3", sto je ime dugmeta submit.
PHP kod
<!DOCTYPE html>
<html>
<head>
<title>HTML forme</title>
</head>
<body>
<h1>Citanje iz dugmadi 3</h1>
Kliknuli ste na
<?php
if (isset($_POST["mojedugme3"]))
echo $_POST["mojedugme3"], "<br />";
?>
</body>
</html>
Sacuvajte ovaj fajl kao php-dugmad-3.php u istom folderu kao i php-dugmad-3.html.
Rezultat:
The data can be sent to the PHP script using attribute value of button submit. This value can be read in PHP script, which is why you do not have to use a hidden control to send data.
Example: you will get this if to each submit button you give the same name, in this example it is "mybutton3", a name of button you assign to the attribute value:
<form name="form1" action="php-buttons-3.php" method="post">
<input type="submit" name="mybutton3" value="button 1">
</form>
HTML code
<!DOCTYPE html>
<html>
<head>
<title>HTML forms</title>
</head>
<body>
<h1>Using buttons 3</h1>
<h3>Using buttons with attribute Value of button Submit</h3>
<form name="form1" action="php-buttons-3.php" method="post">
<input type="submit" name="mybutton3" value="button 1">
</form>
<br />
<form name="form2" action="php-buttons-3.php" method="post">
<input type="submit" name="mybutton3" value="button 2">
</form>
<br />
<form name="form3" action="php-buttons-3.php" method="post">
<input type="submit" name="mybutton3" value="button 3">
</form>
</body>
</html>
Save this file as php-buttons-3.html, in the htdocs folder, of the folder xampp. In my example, the path is C:/xampp2/htdocs/PHPtuts/phpbutton3/php-buttons-3.html.
Result:
In the PHP script you should check the value of control with the name "mybutton3" which is the name of the button submit.
PHP code
<!DOCTYPE html>
<html>
<head>
<title>HTML forms</title>
</head>
<body>
<h1>Reading from buttons 3</h1>
You clicked on
<?php
if (isset($_POST["mybutton3"]))
echo $_POST["mybutton3"], "<br />";
?>
</body>
</html>
Save this file as php-buttons-3.php in the same folder as the php-buttons-3.html.
Result:
Primer: ovo cete dobiti ako svakom dugmetu submit date isto ime, u ovom primeru to je "mojedugme3", a ime dugmeta dodelite atributu value:
<form name="forma1" action="php-dugmad-3.php" method="post">
<input type="submit" name="mojedugme3" value="dugme 1">
</form>
HTML kod
<!DOCTYPE html>
<html>
<head>
<title>HTML forme</title>
</head>
<body>
<h1>Upotreba dugmadi 3</h1>
<h3>Upotreba dugmadi pomocu atributa Value dugmeta Submit</h3>
<form name="forma1" action="php-dugmad-3.php" method="post">
<input type="submit" name="mojedugme3" value="dugme 1">
</form>
<br />
<form name="forma2" action="php-dugmad-3.php" method="post">
<input type="submit" name="mojedugme3" value="dugme 2">
</form>
<br />
<form name="forma3" action="php-dugmad-3.php" method="post">
<input type="submit" name="mojedugme3" value="dugme 3">
</form>
</body>
</html>
Sacuvajte ovaj fajl kao php-dugmad-3.html, u folderu htdocs, foldera xampp. U mom primeru, putanja je C:/xampp2/htdocs/PHPtuts/phpdugme3/php-dugmad-3.html.
Rezultat:
PHP kod
<!DOCTYPE html>
<html>
<head>
<title>HTML forme</title>
</head>
<body>
<h1>Citanje iz dugmadi 3</h1>
Kliknuli ste na
<?php
if (isset($_POST["mojedugme3"]))
echo $_POST["mojedugme3"], "<br />";
?>
</body>
</html>
Sacuvajte ovaj fajl kao php-dugmad-3.php u istom folderu kao i php-dugmad-3.html.
Rezultat:
Example: you will get this if to each submit button you give the same name, in this example it is "mybutton3", a name of button you assign to the attribute value:
<form name="form1" action="php-buttons-3.php" method="post">
<input type="submit" name="mybutton3" value="button 1">
</form>
HTML code
<!DOCTYPE html>
<html>
<head>
<title>HTML forms</title>
</head>
<body>
<h1>Using buttons 3</h1>
<h3>Using buttons with attribute Value of button Submit</h3>
<form name="form1" action="php-buttons-3.php" method="post">
<input type="submit" name="mybutton3" value="button 1">
</form>
<br />
<form name="form2" action="php-buttons-3.php" method="post">
<input type="submit" name="mybutton3" value="button 2">
</form>
<br />
<form name="form3" action="php-buttons-3.php" method="post">
<input type="submit" name="mybutton3" value="button 3">
</form>
</body>
</html>
Save this file as php-buttons-3.html, in the htdocs folder, of the folder xampp. In my example, the path is C:/xampp2/htdocs/PHPtuts/phpbutton3/php-buttons-3.html.
Result:
In the PHP script you should check the value of control with the name "mybutton3" which is the name of the button submit.
PHP code
<!DOCTYPE html>
<html>
<head>
<title>HTML forms</title>
</head>
<body>
<h1>Reading from buttons 3</h1>
You clicked on
<?php
if (isset($_POST["mybutton3"]))
echo $_POST["mybutton3"], "<br />";
?>
</body>
</html>
Save this file as php-buttons-3.php in the same folder as the php-buttons-3.html.
Result:
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.