lightlydone Posted November 10, 2010 Share Posted November 10, 2010 Hi, I'm using $_GET to pass form data to a URL - http://localhost/projects/phpget/test.php?Q7=Dave&Q8=Smith&Q9=123+Road&Q10=ls11sl&Q2=dave%40hotmail.com&Q4=71&day=19&month=01&year=1995&Q263=3127&Q262=3126&x=99&y=24 All the form fields are named Qx and all are ok apart from dob. I've been trying to get the dob to be passed as dd-mm-yyyy with name of Q5, so in above example would be: http://localhost/projects/phpget/test.php?Q7=Dave&Q8=Smith&Q9=123+Road&Q10=ls11sl&Q2=dave%40hotmail.com&Q4=71&Q5=19-01-1995&Q263=3127&Q262=3126&x=99&y=24 I cannot name all 3 fields (date, month, year) as Q5 si i'm guessing that the 3 values need to be assinged to Q5 before the form is submitted?? Any help on this would be much appreciated as hours of trawling through google has not helped. Many thanks. Link to comment https://forums.phpfreaks.com/topic/218307-php-_get-issue/ Share on other sites More sharing options...
simshaun Posted November 10, 2010 Share Posted November 10, 2010 There are two ways. 1: On submit button click, use JS to create a hidden input (Q5) in the form and assign its value, then disable the day, month, and year fields so they are not submitted. 2: Have the form POST to the same page, use PHP to generate the query string and then header redirect to the correct URL with the query string appended. Link to comment https://forums.phpfreaks.com/topic/218307-php-_get-issue/#findComment-1132690 Share on other sites More sharing options...
lightlydone Posted November 15, 2010 Author Share Posted November 15, 2010 Thanks for your reply. I will have to use the JS solution as I am already using header redirect to redirect to a thankyou page after the form has been submitted. I know absolutley no JS and cannot make sense of how to implement the JS solution (after 5 days of trying!!). Could anyone tell me how to do this? Thanks. Link to comment https://forums.phpfreaks.com/topic/218307-php-_get-issue/#findComment-1134363 Share on other sites More sharing options...
chintansshah Posted November 15, 2010 Share Posted November 15, 2010 Hey, Please change the format of date which you are passing in your query string. I think, It will help you. Link to comment https://forums.phpfreaks.com/topic/218307-php-_get-issue/#findComment-1134364 Share on other sites More sharing options...
revraz Posted November 15, 2010 Share Posted November 15, 2010 Send the unix timestamp and convert it. Link to comment https://forums.phpfreaks.com/topic/218307-php-_get-issue/#findComment-1134369 Share on other sites More sharing options...
Pikachu2000 Posted November 15, 2010 Share Posted November 15, 2010 What are you ultimately trying to accomplish here? Link to comment https://forums.phpfreaks.com/topic/218307-php-_get-issue/#findComment-1134469 Share on other sites More sharing options...
lightlydone Posted November 15, 2010 Author Share Posted November 15, 2010 Im trying to pass form data into URL using $_GET, which i understand. The prob is that the dob fields are named <select name="day" id="select" style="width:70px;">, <select name="month" id="select2" style="width:70px;"> and <select name="year" id="select3" style="width:80px;"> so in the URL i get ?day=29&month=01&year=1927 when I need it to be ?dob=29-01-1927. So i guess i need to somehow OnSubmit get the 3 values and put them into 1 value=dob, then disable the day, month and year values so they don't appear in the URL as well. Does this make sense? Link to comment https://forums.phpfreaks.com/topic/218307-php-_get-issue/#findComment-1134544 Share on other sites More sharing options...
Pikachu2000 Posted November 15, 2010 Share Posted November 15, 2010 I know you didn't say this is being inserted in a DB, so I'm making kind of an assumption here, but is there a reason you can't just concatenate the three in the script that does the processing, either before or within the DB query? $dob = "{$_POST['year']}-{$_POST['month']}-{$_POST['day']}"; then use $dob in the insert, or concatenate the values directly in the query INSERT INTO `table` (dob) VALUES ( CONCAT_WS( '-', $_POST['year'], $_POST['month'], $_POST['day']) ) Link to comment https://forums.phpfreaks.com/topic/218307-php-_get-issue/#findComment-1134552 Share on other sites More sharing options...
lightlydone Posted November 15, 2010 Author Share Posted November 15, 2010 Im not inserting the data into a DB. Im sending the data to a URL: https://www.xxx.co.uk/xxx/en/members/livefeed.aspx?ref=vc_an_lf&[email protected]&Q4=71&Q5=07-05-1980&Q7=Bob&Q8=Smith&Q9=1+Sesame+Street+London&Q10=sw123sh&Q262=3126&Q263=3127 All the fields are named q2=email, Q7=forename etc... and all work as above. I have to name the dob drop down fields as day, month, year so 3 names. i need to put all 3 of these values under 1 name, Q5, so the query string includes Q5=07-05-1990 Link to comment https://forums.phpfreaks.com/topic/218307-php-_get-issue/#findComment-1134575 Share on other sites More sharing options...
Pikachu2000 Posted November 15, 2010 Share Posted November 15, 2010 OK, so you're sending it to an external site then, not back to a site you have control over? Link to comment https://forums.phpfreaks.com/topic/218307-php-_get-issue/#findComment-1134576 Share on other sites More sharing options...
lightlydone Posted November 15, 2010 Author Share Posted November 15, 2010 Thats right. What i'm trying to achieve is similar to this: http://limegreensurvey.co.uk/index.php Link to comment https://forums.phpfreaks.com/topic/218307-php-_get-issue/#findComment-1134578 Share on other sites More sharing options...
Pikachu2000 Posted November 15, 2010 Share Posted November 15, 2010 Hmmm... The only thing that comes to mind at the moment is to use a different date picker, one that can be configured as to how the value should be formatted and sent, and what variable's name should be. I've used this one from DynamicDrive in the past. It's highly configurable, and pretty easy to implement. Link to comment https://forums.phpfreaks.com/topic/218307-php-_get-issue/#findComment-1134592 Share on other sites More sharing options...
lightlydone Posted November 15, 2010 Author Share Posted November 15, 2010 I will give it a go. Thanks for your help. Link to comment https://forums.phpfreaks.com/topic/218307-php-_get-issue/#findComment-1134596 Share on other sites More sharing options...
Pikachu2000 Posted November 15, 2010 Share Posted November 15, 2010 There may be another way to do it with some additional javascript in the code you're already using, but my javascript knowledge ends right around alert(), lol. Link to comment https://forums.phpfreaks.com/topic/218307-php-_get-issue/#findComment-1134599 Share on other sites More sharing options...
lightlydone Posted November 16, 2010 Author Share Posted November 16, 2010 yeah i think javascript is the way to go. Simshaun suggested: "On submit button click, use JS to create a hidden input (Q5) in the form and assign its value, then disable the day, month, and year fields so they are not submitted." But, alas, my js is very poor. Does anyone no how to do this? Link to comment https://forums.phpfreaks.com/topic/218307-php-_get-issue/#findComment-1134959 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.