Good conversation!
A few questions...
1.) I'd like to clarify how $_POST and arrays work in general work.
My data entry form looked like this...
<form action="0709_HandleEvent.php" method="post">
<p>Event Name: <input type="text" name="name" size="30"/></p>
<p>Week Days:
<input type="checkbox" name="weekdays[]" value="Sunday"/> S
<input type="checkbox" name="weekdays[]" value="Monday"/> M
<input type="checkbox" name="weekdays[]" value="Tuesday"/> T
<input type="checkbox" name="weekdays[]" value="Wednesday"/> W
<input type="checkbox" name="weekdays[]" value="Thursday"/> R
<input type="checkbox" name="weekdays[]" value="Friday"/> F
<input type="checkbox" name="weekdays[]" value="Saturday"/> S
</p>
<input type="submit" name="submit" value="Add the Event!"/>
</form>
I'm not sure, but this looks like $_POST would be a multi-dimensional array like this...
[b](View #1)
$_POST
name weekdays[ ]
--------------------------- ------------------------------
key value key value[/b]
1 3-Day PHP Party 1 Sunday
6 Friday
7 Saturday
[b](View #2 - alternate view)
$_POST[/b]
name: 3-Day PHP Party
weekdays[ ]: Sunday, Friday, Saturday
Is this how data is sent (i.e. a multi-dimensional array) in the POST array?
2.) The book's goal was to display a message if no weekdays were selected.
Based on the earlier conversations between NogDog and djjjozsi, this is my understanding of things mentioned...
[b]is_array()[/b] Checks for an array which means there must be array elements
[b]isset()[/b] Checks if the array was ever given a value (i.e. "set") but does not
imply that it currently has values.
[b]!empty()[/b] Checks that the array has at least one value.
[/COLOR]
So, to meet the book's goal, it seems like I JUST need to check for !empty( ) like this...
if(!empty($_POST['weekdays'])) {
...because you can't have an array (i.e. is_array() ) by your definitions if the arrary (e.g. weekdays[ ] ) is "empty" (that is empty() ), right?
Thanks for all of the help so far! 🙂
Amy