Sunday, 18 August 2013

Cannot return the values of forms

Cannot return the values of forms

I am new to php and web programming.
I am programming a website that collects essays. In the submission form, I
want the date to be entered by 3 select dropdown forms (day-month-year). I
used to add them in a text field and save them as strings in database. I
added already hundreds of essays so I am not changing the type of data.
I did the following: 1- I made a dynamic dropdown using php:
function get_dropdown_options( $name, array $options, $selected=null ) {
$dropdown = '<select name="'.$name.'" id="'.$name.'">'."\n";
$selected = $selected;
foreach( $options as $key=>$option )
{
$select = $selected==$key ? ' selected' : null;
$dropdown .= '<option
value="'.$key.'"'.$select.'>'.$option.'</option>'."\n";
}
$dropdown .= '</select>'."\n";
return $dropdown; }
2- then I made a function to show three dropdown menus for days, months
and years.
function show_date_dropdown_row($name, $label, $option1, $option2,
$option3, $value = "") {
echo "<tr class=\"".get_row_bg()."\" valign='top'>\n<td><p
class=\"rowtitle\">".$label."</p></td>\n";
echo "<td><p>\n";
echo get_dropdown_options($name1, $option1,
$value1).get_dropdown_options($name2, $option2,
$value2).get_dropdown_options($name3, $option3, $value3);
return $name = $name1." - ".$name2." - ".$name3;
}
3- in the submission form page, I put the following code:
show_date_dropdown_row("release_date", "Release Date", $days_list,
$months_list, $years_list, "");
4- the name "release_date" is then added to the database.
The page shows the three dropdown lists perfectly. But the problem is that
the "release_date" in database don't store any value.
I tried the function in step1 and it works perfectly. I know that the
problem is in step two, but don't know where.

No comments:

Post a Comment