Jump to content

How to post to another PHP page


benchew0904

Recommended Posts

Hi

 

I need some help.

I wanted to create a start and end event date using date picker and also after selecting the start and end date, it will calculate the number of days (duration).

I have found the date picker which can do what I want but I need help to post the duration to another php page when user click on submit.

 

Can anyone help me.

You might want to refer to my attach PHP page and here is the link to the datepicker, http://www.kelvinluck.com/assets/jquery/datePicker/v2/demo/datePickerStartEnd.html

 

Thanks

Ben Chew

 

[attachment deleted by admin]

Link to comment
Share on other sites

it should be posting the dates to the confirmation.php file... does that file exist and is it located in the same directory? what code is in that file?

if you want to post the difference you'll have to change

<li style="list-style: none;" id="duration"></li>
to
<input type='text' name='duration' id='duration' />

 

also, you've got a superfluous " at the end of your <form> tag...

<form name ="drop_list" method = "POST" action ="confirmation.php" ">
//should be
<form name ="drop_list" method = "POST" action ="confirmation.php">

Link to comment
Share on other sites

Thanks joel24 for the reply.

 

Yes, the file exist and it's in the same directory.

 

I have tried changing to

<input type='text' name='duration' id='duration' />

but after I changed, the number of days between the start and end days will not be be shown.

And I have remove the superfluous ". Thanks for pointing out my careless mistake.

 

And this is in the confirmation.php page

<?php

$startDate = $_POST['startDate'];

$endDate = $_POST['endDate'];

$duration = $_POST['duration'];

?>

 

                      <table style="width: 45%" >

                        <tr>

                            <td>Event Start Date</td>

                            <td><?php echo $startDate; ?></td>

                        </tr>

                        <br/>

                        <tr>

                            <td>Event End Date</td>

                            <td<?php echo $endDate; ?></td>

                        </tr>

                        <br/>

                        <tr>

                            <td>No. of Days Selected</td>

                            <td><?php echo $duration; ?></td>

                        </tr>

                    </table>

 

Please do advise again.

 

Thanks

 

 

 

Link to comment
Share on other sites

you're not posting the duration across... you need to add the value to a form element using javascript or you can use PHP to determine the days between...

You'll need to use a '-' as a seperator rather than '/' - this tells the strtotime() function that it will be a european date format (d-m-y) rather than american (m/d/y)

 

#get unix timecode of dates (seconds past since 1st Jan 1970) - ensure they are either d-m-y or m/d/y
$start=strtotime($_POST['startDate']);
$end=strtotime($_POST['endDate']);

#subtract start from end and divide by seconds in day to determine days...
$days = $end-$start / (60*60*24);

echo $days;

Link to comment
Share on other sites

sorry, my bad


#get unix timecode of dates (seconds past since 1st Jan 1970) - ensure they are either d-m-y or m/d/y
$start=strtotime($_POST['startDate']);
$end=strtotime($_POST['endDate']);

#subtract start from end and divide by seconds in day to determine days...
$days = ($end-$start) / (60*60*24);

echo $days;

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.