Jump to content

First Script Help


Timma

Recommended Posts

PHP is server side. Your code wont work. you need to do something like:


<html><head>
<title>TEST THANKS</title>
</head><body>
<?php
if ($_GET['num'])
{
$thanks = $_GET['num'];
$thanks++;
}
else
{
$thanks = 0;
}

echo '<a href="'.$_SERVER['PHP_SELF'].'?num='.$thanks.'"> Thanks ME </a>';
echo "$thanks";
?>
</body></html>

Link to comment
https://forums.phpfreaks.com/topic/44212-first-script-help/#findComment-214730
Share on other sites

There isnt any real way with just PHP to change the value of $thanks without reloading.

What do you mean, do you want to click a link and then store the number?

if so you will need something like this:

<?php
//db connection defined earlier
if ($_GET['num'])
{
$thanks = $_GET['num'];
$thanks++;
mysql_real_escape_string($thanks);
$sql = "insert into numbers (number) values ('{$thanks}')"
mysql_query($sql);
}
else
{
$thanks = 0;
}

echo '<a href="'.$_SERVER['PHP_SELF'].'?num='.$thanks.'"> Thanks ME </a>';
echo "$thanks";
?>

Link to comment
https://forums.phpfreaks.com/topic/44212-first-script-help/#findComment-214737
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.