What I'm looking to to is create a variable in a php file on my server called "likes"
Then, on my html web page, I want to have a like button, that when clicked used javascript to edit the variable "likes" in that php file and adds 1. There will be a little place on the page above the like button that shows the total number of likes.
WHAT I HAVE:
PHP FILE: "index.php"
<?php
$likes=0;
/** Load likes page START */
require( dirname( __FILE__ ) . '/likespagestart.html' );
echo $likes;
/** Load likes page END */
require( dirname( __FILE__ ) . '/likespageend.html' );
?>
HTML FILE: "likepagestart.html"
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Likes Page</title>
<script type="text/javascript">
var count = 0;
function countClicks() {
count = count + 1;
document.getElementById("p2").innerHTML = count;
}
</script>
</head>
<body>
This is the likes page!
<br/>
Number of likes: <p id="p2">0</p>
HTML FILE: "likepageend.html"
<br/>
<a href="javascript:countClicks();">Like</a>
</body>
</html>
View on my website: www.stevenhower.com/phpinclude/likes (The first 0 is the javascript only, the second 0 is the php variable.
So right now, I just have a silly javascript function, and can't actually edit the variable in the php file...