Jump to content

PHP/HTML Form Help


RepublicOfDavid

Recommended Posts

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="me@email.com" />

<input type="hidden" name="required_fields" value="date, field_name2" />

 

</form>

 

 

Hope this makes sense, thanks in advance

 

David

 

Link to comment
Share on other sites

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";

Link to comment
Share on other sites

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 :-)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.