mattennant Posted June 27, 2005 Share Posted June 27, 2005 hi there wonder if anyone can point me in the right direction with this one. I want to create a form where a user enters the date of an event. at present the only way i can manage this is if i get the user to enter todays date in a text box as (eg todays date) 20051227 which is sure going to confuse people. What i'm wondering is how complex a procedure, taking into account my noobie status, would it be to enter the date into one columns of a database using three drop down menus. Any help much appreciated thanks Quote Link to comment Share on other sites More sharing options...
jeremywesselman Posted June 27, 2005 Share Posted June 27, 2005 [!--PHP-Head--][div class=\'phptop\']PHP[/div][div class=\'phpmain\'][!--PHP-EHead--][span style=\"color:#0000BB\"]<?php [/span][span style=\"color:#007700\"]if(isset([/span][span style=\"color:#0000BB\"]$_POST[/span][span style=\"color:#007700\"][[/span][span style=\"color:#DD0000\"]\'submit\'[/span][span style=\"color:#007700\"]])) { [/span][span style=\"color:#0000BB\"]$month [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]$_POST[/span][span style=\"color:#007700\"][[/span][span style=\"color:#DD0000\"]\'month\'[/span][span style=\"color:#007700\"]]; [/span][span style=\"color:#0000BB\"]$day [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]$_POST[/span][span style=\"color:#007700\"][[/span][span style=\"color:#DD0000\"]\'day\'[/span][span style=\"color:#007700\"]]; [/span][span style=\"color:#0000BB\"]$year [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]$_POST[/span][span style=\"color:#007700\"][[/span][span style=\"color:#DD0000\"]\'year\'[/span][span style=\"color:#007700\"]]; [/span][span style=\"color:#0000BB\"]$eventDate [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]$month [/span][span style=\"color:#007700\"]. [/span][span style=\"color:#DD0000\"]\" \" [/span][span style=\"color:#007700\"]. [/span][span style=\"color:#0000BB\"]$day [/span][span style=\"color:#007700\"]. [/span][span style=\"color:#DD0000\"]\", \" [/span][span style=\"color:#007700\"]. [/span][span style=\"color:#0000BB\"]$year[/span][span style=\"color:#007700\"]; echo([/span][span style=\"color:#0000BB\"]$eventDate[/span][span style=\"color:#007700\"]); } else { [/span][span style=\"color:#0000BB\"]?> [/span]<form action=\"[span style=\"color:#0000BB\"]<?=$_SERVER[/span][span style=\"color:#007700\"][[/span][span style=\"color:#DD0000\"]\'PHP_SELF\'[/span][span style=\"color:#007700\"]][/span][span style=\"color:#0000BB\"]?>[/span]\" method=\"post\"> Enter Event Date: <select name=\"month\"> <option value=\"Jan\">Jan</option> <option value=\"Feb\">Feb</option> <option value=\"Mar\">Mar</option> <option value=\"April\">April</option> </select> <select name=\"day\"> <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> </select> <select name=\"year\"> <option value=\"2005\">2005</option> <option value=\"2006\">2006</option> </select> <input type=\"submit\" value=\"Submit\" name=\"submit\"> </form> [span style=\"color:#0000BB\"]<?php [/span][span style=\"color:#007700\"]} [/span][span style=\"color:#0000BB\"]?>[/span] [/span][!--PHP-Foot--][/div][!--PHP-EFoot--] All you have to do is concatenate all of the values of the selects. You can format it however you want. Jeremy Quote Link to comment Share on other sites More sharing options...
mattennant Posted June 27, 2005 Author Share Posted June 27, 2005 thanks for that the principle makes sense, just that when i pasted the code i got the following error Parse error: parse error, unexpected T_VARIABLE in /home/fhlinux195/m/matthewtennant.com/user/htdocs/mainevent_1.php on line 9 i'm guessing i'm making a massive error. All the code belongs in the same page right?? thanks again mat Quote Link to comment Share on other sites More sharing options...
jeremywesselman Posted June 27, 2005 Share Posted June 27, 2005 Yes, it all goes on the same page. I tested on my own server before I posted here and it works for me. Jeremy Quote Link to comment Share on other sites More sharing options...
mattennant Posted June 28, 2005 Author Share Posted June 28, 2005 weirdly some extra spaces before the variables appear to have been causing my error, all is working fine now. Thanks a bunch Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.