NYCPHP Meetup

NYPHP.org

[nycphp-talk] Passing JAVASCRIPT variables to PHP

PaulCheung paulcheung at tiscali.co.uk
Sat Apr 5 14:47:21 EDT 2008


Sorry Mate,

I lost it. I just cannot see what I'm doing wrong. All the coding before 
Datum is just working out the date. the following snippet is where I am 
trying to upload the Javascript data to the server.

Paul

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

var $datum = Datum;
new Image()).src = 'http://www.localhost/showdatum.php?$datum='+"$datum";

</SCRIPT>
<FORM action="showdatum.php" method="post">
<input type='text' name='$datum' size='20'><br>
</FORM>
</BODY>
</HTML>

showdatum.php
===========
<?PHP $datum = $_POST['$datum'];
echo('$datum = ' . $datum . "<BR>"); ?>


----- Original Message ----- 
From: "tedd" <tedd at sperling.com>
To: "NYPHP Talk" <talk at lists.nyphp.org>
Sent: Monday, March 31, 2008 2:27 PM
Subject: Re: [nycphp-talk] Passing JAVASCRIPT variables to PHP


> At 6:07 PM -0400 3/30/08, Daniel Convissor wrote:
>>Hi Paul:
>>
>>On Sun, Mar 30, 2008 at 09:18:10PM +0100, PaulCheung wrote:
>>
>>>  The problem is I cannot transfer the Javascript variable needed in to 
>>> PHP.
>>
>>JavaScript is client side.  PHP is server side.  This has been discussed
>>on this list a couple times, and on the web too many times to count.
>>
>>You either need to submit the JS data to the server as part of a form or
>>via an AJAX request.
>>
>>--Dan
>
>
> --Dan:
>
> And don't forget this way:  :-)
>
> var a = 1;
> (new Image()).src = '/myscript.php?a='+ a;
>
> Cheers,
>
> tedd
>
> -- 
> -------
> http://sperling.com  http://ancientstones.com  http://earthstones.com
> _______________________________________________
> 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