Reply to Re: How PHP $_POST gets the multiple values from a HTML form?

Your name:

Reply:


Posted by RC on 10/24/12 11:16

RC wrote:
> I am try test a simple HTML form with PHP
>
> <form method=POST action="testing.php">
> Cat <input type="checkbox" name="pet" value="cat">
> Dog <input type="checkbox" name="pet" value="dog">
> Pig <input type="checkbox" name="pet" value="pig">

Never mind, I found the solution
In HTML file form need to changed to

Cat <input type="checkbox" name="pet[]" value="cat">
Dog <input type="checkbox" name="pet[]" value="dog">
Pig <input type="checkbox" name="pet[]" value="pig">

> <br>
> <select name="dates" multiple>

and need to changed to
<select name="dates[]" multiple>


> <option value="Monday">Monday</option>
> <option value="Tuesday">Tuesday</option>
> <option value="Wednesday">Wednesday</option>
> <option value="Thursday">Thursday</option>
> <option value="Friday">Friday</option>
> <option value="Saturday">Saturday</option>
> <option value="Sunday">Sunday</option>
> </select><br>
> <input type="submit" value="Submit">
> <input type="reset" value="Reset">
> </form>
>
> When I checked cat, pig and selected Tuesday and Saturday from the form
> and click submitt
>
> My testing.php is
>
> <?php
> $pet = $_POST['pet'];
> $dates = $_POST['dates'];

Then in PHP need to changed to

$pet = array($_POST['pet']);
$dates = array($_POST['dates']);



> print_r($pet);
> var_dump($dates);
> ?>
>

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация