Jump to content

get or post help


mpsn

Recommended Posts

Hi, I am building a learning site for kids. On this page,

 

1)there's a textbox to choose the directory to save the list of new words they learnt

2)an HTML table that displays all the words they have stored to db (they choose the words to store to directory via checkboxes next to each word in this HTML table)

3)then they click submit and it stores these new words they can use to file in their specified directory.

 

My quesiton is should I use $_GET or $_POST? (somehow I think I need to output the primary key in step 2) for query string, so maybe I should also store directory that user types in textbox as query string too?

 

Any help much appreciated!

Link to comment
https://forums.phpfreaks.com/topic/251416-get-or-post-help/
Share on other sites

<form action="test.php" method="post">
    <input type="checkbox" name="apple" value="apple">apple
    <br>
    <input type="checkbox" name="orange" value="orange">orange
    <br>
    <input type="submit">
</form>

<?
foreach ($_POST as $key => $value )
echo "<br>$key is checked";
?>

Hope you can get the idea

Link to comment
https://forums.phpfreaks.com/topic/251416-get-or-post-help/#findComment-1289498
Share on other sites

That's actually not such a great idea. A group of related checkboxes should be configured as an array in the form so you can then loop only through that group to get the values.

 

<input type="checkbox" name="choices[]" value="apple">apple<br>
<input type="checkbox" name="choices[]" value="orange">orange<br>
<input type="checkbox" name="choices[]" value="banana">banana<br>
<input type="checkbox" name="choices[]" value="grapes">grapes<br>

 

The values of the checked boxes will be available in array form in $_POST['choices']

Link to comment
https://forums.phpfreaks.com/topic/251416-get-or-post-help/#findComment-1289528
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.