473,545 Members | 1,893 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to display selected value from drop down list for php

1 New Member
what is the php code for display selected dob value from drop down list - day and month





Expand|Select|Wrap|Line Numbers
  1. <form action="http://bytes.com/registerProfile.php" method="post"> <fieldset> <legend>Enter your information in the form below:</legend> <p> <b>Userid:</b> <input type="text" name="userid" size="10" maxlength="80" value="" /> </p> <p> <b>Password:</b> <input type="password" name="password" size="10" maxlength="80" value="" /> </p> <p> <b>Name:</b> <input type="text" name="firstname" size="10" maxlength="40" value=""/> </p> <p> <b>Gender:</b> <input type="radio" name="gender" value="M"/> Male
  2.     <input type="radio" name="gender" value="F"/> Female
  3.     </p> <p> <b>Date Of Birth:</b> <select name = "DateOfBirth_Day"> <option> - Day - </option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> <option value="7">7</option> <option value="8">8</option> <option value="9">9</option> <option value="10">10</option> <option value="11">11</option> <option value="12">12</option> <option value="13">13</option> <option value="14">14</option> <option value="15">15</option> <option value="16">16</option> <option value="17">17</option> <option value="18">18</option> <option value="19">19</option> <option value="20">20</option> <option value="21">21</option> <option value="22">22</option> <option value="23">23</option> <option value="24">24</option> <option value="25">25</option> <option value="26">26</option> <option value="27">27</option> <option value="28">28</option> <option value="29">29</option> <option value="30">30</option> <option value="31">31</option> </select> <select name = "DateOfBirth_Month"> <option> - Month - </option> <option value="January">January</option> <option value="Febuary">Feburary</option> <option value="March">March</option> <option value="April">April</option> <option value="May">May</option> <option value="June">June</option> <option value="July">July</option> <option value="August">August</option> <option value="September">September</option> <option value="October">October</option> <option value="November">November</option> <option value="December">December</option> </select> <input type = "text" name = "DateOfBirth_Year" size"10" maxlength="8" value=""/> </p> </fieldset> <p style="text-align:center"> <input type="submit" name="submit" value="Register me!" /> <input type="reset" value="Reset" />
  4. ========================================================================================================================
  5. <?php 
  6. if (!empty($_POST['firstname'])){ 
  7. //firstname textbox is not EMPTY
  8.   $firstname = $_POST['firstname'];
  9. }
  10. else { //firstname textbox is EMPTY
  11.   $firstname = null;
  12.     //prompt user to enter the name
  13.     echo '<p><font color="red">Please enter your name!</font></p>';
  14. }
  15.  
  16. if(!empty($_POST['gender'])){
  17.     $gender=$_POST['gender'];
  18. }
  19. else {
  20.     $gender = null;
  21.     echo '<p><font color="red">You forgot to enter your gender!</font></p>';
  22. }
  23.  
  24. if(!empty($_POST['userid'])){
  25.     $userid=$_POST['userid'];
  26. }
  27. else{
  28.     $userid = null;
  29.     echo '<p><font color="red">You forgot to enter your userid!</font></p>';
  30. }
  31.  
  32. if(!empty($_POST['password'])){
  33.     $password = $_POST['password'];
  34. }
  35.  
  36. else{
  37.     $password = null;
  38.     echo '<p><font color="red">You forgot to enter your password!</font></p>';
  39. }
  40.  
  41. if(!empty($_POST['DateOfBirth_Day'])){//$DateOfBirth_Day is SELECTED
  42.     $DateOfBirth_Day = $_POST['DateOfBirth_Day'];
  43. }
  44. else{
  45.     $DateOfBirth_Day = null;//$DateOfBirth_Day is NOT SELECTED
  46.     echo '<p><font color="red">You forgot to enter your day for date of birth!</font></p>';
  47. }
  48.  
  49. if(!empty($_POST['DateOfBirth_Month'])){//$DateOfBirth_Month is SELECTED
  50.     $DateOfBirth_Month = $_POST['DateOfBirth_Month'];
  51. }
  52. else{
  53.     $DateOfBirth_Month = null;//$DateOfBirth_Month is NOT SELECTED
  54.     echo '<p><font color="red">You forgot to enter your month for date of birth!</font></p>';
  55. }
  56.  
  57. if(is_numeric($_POST['DateOfBirth_Year'])==TRUE){//$DateOfBirth_Year is A NUMBER
  58.     $DateOfBirth_Year = $_POST['DateOfBirth_Year'];
  59. }
  60. else{
  61.     $DateOfBirth_Year = null;//$DateOfBirth_Year is NOT A NUMBER
  62.     echo '<p><font color="red">Enter NUMBER for the year of date of birth!</font></p>';
  63. }
  64.  
  65. if($firstname != null && $gender != null && $userid != null && $password != null && $DateOfBirth_Day != null && $DateOfBirth_Month != null && $DateOfBirth_Year != null){
  66.     echo '<p><font color = "green">You have entered everything correctly. Thank You!</font color></p>';
  67.  
  68. echo "<p>Thank you, <b>$firstname</b>. You entered the following details :</p>";  
  69. echo "<ol>";
  70.  
  71. echo " <li>Userid: <b>$userid</b> </li>";
  72. echo " <p>";
  73. echo " <li>Name: <b>$firstname</b></li>";
  74. echo " <li>Gender: <b>$gender</b></li>";
  75. echo " <li>Date Of Birth: <b>$DateOfBirth_Day "."/$DateOfBirth_Month "."/$DateOfBirth_Year</b></li>";
  76.  
  77. echo "</ol>";
  78.  
  79. }
  80. else{
  81.     echo '<p><font color = "red">Please go back to fill up the form!</font color><a href = "http://bytes.com/Registration.php"> Back </a><p/>';
  82. }
  83.  
  84. ?> </body> </html>
Dec 27 '13 #1
1 1570
Rabbit
12,516 Recognized Expert Moderator MVP
I don't understand your question. It looks like you're already displaying the date of birth.
Dec 27 '13 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
2455
by: Serge Myrand | last post by:
Hi, I cannot get the selected option to be POSTed (it does not appear in the QueryString when using GET neither) I construct the drop down list from an array, I select an element in the list, I POST using a submit button. When I use Request.Form("NAME") it's always empty. Is the selected item is Posted? How to retreive it?
1
1910
by: Tom Ewall | last post by:
I have an iframe which has a drop-down list, which I'm trying to use to refresh a drop-down list in the main page. I'm using this call to refresh the page: window.parent.document.all.asset_id_list.innerHTML = document.all.assetid.innerHTML; When the list is displayed in the main page, it doesn't display as a drop-down list, but instead...
4
37450
by: charliewest | last post by:
I need to set the selected drop down list value at run time. I am aware of the method "SelectIndex" however this works only if you know the precise location of the value within the ListItem collection. Otherwise, what is the recommended approach? I have managed to set the appropriate value using the following loop: for (int i = 1; i <...
2
12599
by: Yoshitha | last post by:
hi I have 2 drop down lists in my application.1st list ontains itmes like java,jsp,swings,vb.net etc.2nd list contains percentage i.e it conatains the items like 50,60,70,80,90,100. i will select any skill in 1st drop down list then i'll select % of this skill in the 2nd list box , based on the percentage i've selected in the 2nd list...
5
4210
by: Vigneshwar Pilli via DotNetMonster.com | last post by:
string connectionString1 = "server=(local); user=sa;password=sa; database=sonic"; System.Data.SqlClient.SqlConnection dbConnection1 = new System.Data.SqlClient.SqlConnection(connectionString1); System.Data.SqlClient.SqlCommand dbCommand1 = new System.Data.SqlClient.SqlCommand();
1
1115
by: mrjoka | last post by:
hi, i have a label and i have two drop down list and i want to assign a value to this label when a value has been selected from drop down list 1(this one already working) now i want the label to have the value of the second drop down list. first drop down list is a comminuty and the second is site. can you tell me how can i make this happen?!!...
2
1900
by: usgog | last post by:
I have a <select style="" name="" size="2"> <option value="1">Name 1</option> <option value="1">Name2</option> </select>. It will popup and display as a drop down list with "gray'ed" vertical scrollbar. So how can I make it like a panel without the vertical scrollbar at the right side?
3
7337
by: penny111 | last post by:
Hi there, For my application, i need to have 3 drop down lists 1. drop down list of folder names 2. drop down list of documents in the folder selected 3. drop down list of instances of the document selected (my application uses the BusinessObjects Java Web Services SDK) The 2nd list is dependent on the 1st, while the 3rd list is...
2
3191
by: leeperman | last post by:
In Dreaweaver I cannot filter my database results to display only specific data that is retrieved from mulptile drop down list on my search page. The drop down list selections are posted to my display page by GET. How do i write my sql code so to only display info where TOWN = "Town selected from list" AND BEDS ="No of Beds selected from list ...
2
3318
by: crazychrisy54 | last post by:
Hi there I have a option, select drop down list which a user can open. My page however refreshes very frequently and when this occurs the selected drop down list will pop back up. The user then has to open the drop down list again. I just wondered if there was a way using javascript to firstly detect if the user has selected the drop...
0
7486
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7416
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7676
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7932
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7442
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7776
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
4965
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
1
1905
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
729
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.