Code:
<body>
<input type="text" name="fruits[]">
<?php
$input = '<input type="hidden" name="fruits[]" value="%s">';
if (isset($_POST['fruits'])) {
foreach ($_POST['fruits'] as $fruit) {
printf($input, $fruit);
}
}
?>
<button type="submit">Put into bag</button>
<?php
echo implode(', ', $_POST['fruits']);
?>
</body>
<body>
<input type="text" name="fruits[]">
<?php
$input = '<input type="hidden" name="fruits[]" value="%s">';
if (isset($_POST['fruits'])) {
foreach ($_POST['fruits'] as $fruit) {
printf($input, $fruit);
}
}
?>
<button type="submit">Put into bag</button>
<?php
echo implode(', ', $_POST['fruits']);
?>
</body>
Ali nista se ne desava kada kilknem dugme i izbaci mi neke greske
Citat:
Notice: Undefined index: fruits in C:\wamp\www\zadatak.php on line 22
Citat:
Warning: implode(): Invalid arguments passed in C:\wamp\www\zadatak.php on line 22
7
this is line 22
Code:
echo implode(', ', $_POST['fruits']);
echo implode(', ', $_POST['fruits']);