RepublicOfDavid Posted September 5, 2011 Share Posted September 5, 2011 Hi All, I’m currently building a website and was wondering if anybody can help me with my PHP/form problem, I’ve put together a standard HTML form and I’m bringing in via ‘Get Parameters’ dates from another page that are being placed inside one of the form fields, each date is formatted like this: “15/06/11 – 18/06/11” The next step is I need the form to realise that if the first part of the date (in this case 15/06/11) is less than 30 days away to on form submission take the visitor to a different ‘Thank You Page’ URL Here’s my form code: <form method="post" action=""> <td>Date:</td> <div class="field"> <input type="text" name="date" value="<?php echo $id_1 = $_GET['prop_id']; ?>"/> </div> </tr> <td>Comments:<td> <div class="field"><textarea rows="10" cols="50" name="field_name2"></textarea></div> </tr> <td> <input type="submit" value="Submit" /> </td> </tr> <input type="hidden" name="ccf_customhtml" value="1" /> <input type="hidden" name="thank_you_page" value="http://www.google.com" /> <input type="hidden" name="destination_email" value="[email protected]" /> <input type="hidden" name="required_fields" value="date, field_name2" /> </form> Hope this makes sense, thanks in advance David Quote Link to comment https://forums.phpfreaks.com/topic/246486-phphtml-form-help/ Share on other sites More sharing options...
Cagecrawler Posted September 6, 2011 Share Posted September 6, 2011 Something like this should get you started. <?php $input = "15/09/11 - 18/06/11"; //Explode input to get first date. $dates = explode("-", $input); //Explode it again to get the date parts. $dateParts = explode("/", $dates[0]); //Flip the parts around to Americanise the date, since that's what strtotime takes. $time = strtotime($dateParts[1]."/".$dateParts[0]."/".$dateParts[2]); //Compare to the current time. echo ($time - time() > 60*60*24*30) ? "OVER 30 DAYS" : "UNDER 30 DAYS"; Quote Link to comment https://forums.phpfreaks.com/topic/246486-phphtml-form-help/#findComment-1265801 Share on other sites More sharing options...
RepublicOfDavid Posted September 6, 2011 Author Share Posted September 6, 2011 Thanks so much Cagecrawler, that’s a huge help, would you by any chance know how to incorporate that into my form code so if date is less than 30 days away on form submission take visitor to a different ‘thank you page’? <input type="hidden" name="thank_you_page" value="http://www.google.com" /> PHP Newbie :-) Quote Link to comment https://forums.phpfreaks.com/topic/246486-phphtml-form-help/#findComment-1265868 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.