NYCPHP Meetup

[nycphp-talk] Passing JAVASCRIPT variables to PHP

PaulCheung paulcheung at tiscali.co.uk
Mon Mar 31 15:43:33 EDT 2008


Hi Tom,

Not a problem. Here is the "Capture Client Date Routine" which I "include" 
into the main PHP script.

<?PHP session_start(); ob_start(); ?>
<script language="JavaScript" type="text/javascript">

var Days = new
Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');
var Datum;
var today = new Date();
var Year = takeYear(today);
var Month = leadingZero(today.getMonth()+1);
var DayName = Days[today.getDay()];
var Day = leadingZero(today.getDate());
var Hours = today.getHours();
Hours2 = Hours;
Hours = leadingZero(Hours);
var ampm = "am";
if (Hours2 > 11)
 ampm = "pm";
if (Hours2 > 12)
 Hours2 -= 12;
if (Hours2 == 0) Hours2 = 12;
Hours2 = leadingZero(Hours2);
var Minutes = leadingZero(today.getMinutes());
var Seconds = leadingZero(today.getSeconds());

function takeYear(theDate)
{ x = theDate.getYear();
 var y = x % 100;
 y += (y < 38) ? 2000 : 1900;
 return y; }

function leadingZero(number)
{ if (number < 10) number = "0" + number;
 return number; }

Datum = ( +Year+ '/' +Month+ '/' +Day+ ' - ' +Hours+ ':' +Minutes+ ':'
+Seconds)
document.write (Datum);

$datum = Datum;
document.write ($datum);

</SCRIPT>
<?php echo('  $datum =  ' .  $datum); ?>

It was here I thought by using an include I could overcome the problem with 
transfer of Javascript data to PHP.
Unless there is a simpler way I will have to swat up on AJAX

Paul

----- Original Message ----- 
From: "Tom Melendez" <tom at supertom.com>
To: "NYPHP Talk" <talk at lists.nyphp.org>
Sent: Sunday, March 30, 2008 9:49 PM
Subject: Re: [nycphp-talk] Passing JAVASCRIPT variables to PHP


> Hi Paul,
>
> Please slow down and provide us with some more information.
>
> 1.  What is the problem?  Meaning, what is the end result?
> Application doesn't work?  Which parts?  Explain the flow of the part
> that doesn't work
> 2. Sounds like you might be moving this application from somewhere
> else.  What is different about the architecture of each.  A phpinfo on
> each server would go a long way in determining this.
> 3. Have you narrowed it down to a piece of code?  Can you share that
> code with us?
>
> Thanks,
>
> Tom
> http://www.liphp.org
>
>
> On Sun, Mar 30, 2008 at 1:18 PM, PaulCheung <paulcheung at tiscali.co.uk>
> wrote:
>> HELP!!  - The application uses PHP sessions and not cookies as well as a
>> PHP
>>  Include to bring in a Javascript date routine, which is works fine. The
>>  problem is I cannot transfer the Javascript variable needed in to PHP.
>>
>>  I have checked on the Net; But cannot find any solution that uses
>> Includes
>>  and Sessions.
>>
>>
>>
>>
>>  _______________________________________________
>>  New York PHP Community Talk Mailing List
>>  http://lists.nyphp.org/mailman/listinfo/talk
>>
>>  NYPHPCon 2006 Presentations Online
>>  http://www.nyphpcon.com
>>
>>  Show Your Participation in New York PHP
>>  http://www.nyphp.org/show_participation.php
>>
> _______________________________________________
> New York PHP Community Talk Mailing List
> http://lists.nyphp.org/mailman/listinfo/talk
>
> NYPHPCon 2006 Presentations Online
> http://www.nyphpcon.com
>
> Show Your Participation in New York PHP
> http://www.nyphp.org/show_participation.php




More information about the talk mailing list