Please Help Me Out!

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
aknessy
Forum Newbie
Posts: 1
Joined: Fri Aug 30, 2013 1:40 am

Please Help Me Out!

Post by aknessy »

Am a PHP noob, as one of the Forumers rightly pointed out. Am designing a simple PHP/HTML/CSS code (just for the fun of it though). My script includes a form and in the form, i have an external PHP file called 'date_field.php' which i have used to dynamically generate the Date Drop Down for my birth day field. My problem is; am trying to access some parameters like "date_day", "date_month" and "date_year" in that external file but my php script is unable to read those parameters. I have imported my external file using the "include('date_field.php')", and i have crreated a reference to a function inside the PHP file using the normal variable assignment. Something like $date = date_dropdown(); This works fine as the drop down field is displayed as it should. This is the content of my date_field.php file:

***** Please Use the PHP Code Tag *****

Code: Select all

<?php
function date_dropdown($year_limit = 0){
	        $html_output = '    <div id="date_select" >'."\n";
	        $html_output .= '        <label for="date_day">Date of birth:</label>'."\n";
	 
	        /*days*/
	        $html_output .= '           <select name="date_day" id="day_select">'."\n";
	            for ($day = 1; $day <= 31; $day++) {
	                $html_output .= '               <option>' . $day . '</option>'."\n";
	            }
	        $html_output .= '           </select>'."\n";
	 
	        /*months*/
	        $html_output .= '           <select name="date_month" id="month_select" >'."\n";
	        $months = array("", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
	            for ($month = 1; $month <= 12; $month++) {
	                $html_output .= '               <option value="' . $month . '">' . $months[$month] . '</option>'."\n";
	            }
	        $html_output .= '           </select>'."\n";
	 
	        /*years*/
	        $html_output .= '           <select name="date_year" id="year_select">'."\n";
	            for ($year = 1900; $year <= (date("Y") - $year_limit); $year++) {
	                $html_output .= '               <option>' . $year . '</option>'."\n";
	            }
	        $html_output .= '           </select>'."\n";
	 
	        $html_output .= '   </div>'."\n";
	    return $html_output;
}
?>
My Headache is trying to get the "date_day", "date_month" and "date_year" html parameters in my real PHP code so that i can insert them normally into the database, as other parameters. :banghead: :banghead:
Your help will be very much appreciated.
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Please Help Me Out!

Post by Christopher »

You would get the values from the PHP superglobal variable $_POST. Specifically $_POST["date_day"], $_POST["date_month"] and $_POST["date_year"]
(#10850)
Post Reply