Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-08-2013, 03:14 PM   PM User | #1
Jian0203
New Coder

 
Join Date: Mar 2012
Posts: 47
Thanks: 2
Thanked 0 Times in 0 Posts
Jian0203 is an unknown quantity at this point
How to pass javascript function variable into php

Can anyone please teach me how do I get the 'count' from click.php and pass into the '$clicked' of clickcount.php ?

Thank you so much for helping ^.^

cllick.php

PHP Code:
<script type="text/javascript">

    var 
count 0;
    function 
countClicks() {
    
count count 1;
    
document.getElementById("clicks").innerHTML count;
    }
    
</script> 
clickcheck.php

PHP Code:
<?php

$click 
'?????'// I don't know how should i define this
    
if(!isset($clicked) || empty($clicked)) {
                die(
"No click is counted.");
                
header = ('login3.php');
    
                } else if (
$clicked $content || $clicked $content){
                    die(
"Click count(s) is not correct!");
                    
header = ('login.php)';
                } else {
                 die(
"Login success.");
                 
header = ('welcome.php');
                    }
    
?>
Jian0203 is offline   Reply With Quote
Old 01-08-2013, 03:15 PM   PM User | #2
angst
Senior Coder

 
angst's Avatar
 
Join Date: Apr 2004
Location: Toronto, Ontario
Posts: 2,112
Thanks: 15
Thanked 122 Times in 122 Posts
angst is on a distinguished road
if your submitting a form you could load the javascript value in an input field.
angst is offline   Reply With Quote
Old 01-08-2013, 03:15 PM   PM User | #3
TFlan
New Coder

 
Join Date: Dec 2012
Location: USA
Posts: 82
Thanks: 3
Thanked 17 Times in 17 Posts
TFlan is an unknown quantity at this point
The only way for JavaScript, client-side, to interact with PHP, server-side, is through Ajax.

There may be other, newer ways that I have not heard of, but Ajax would be my first go-to
TFlan is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 01:34 AM.


Advertisement
Log in to turn off these ads.