Jump to content

Why isn't it working? Using the GET fuction


3raser

Recommended Posts

<?php

mysql_connect("", "", "") or die("Error connecting to the MySQL database!");
mysql_select_db("") or die("Error connecting to the selected database!");

$ip = $_SERVER[REMOTE_ADDR];
$action = $_GET['a'];

//prosses of getting the numbers for users

        $construct = "SELECT * FROM agreedusers WHERE ip='$ip'";
        $run = mysql_query($construct);

        $foundnum = (mysql_num_rows($run));

if ($foundnum ==1)
   die("You have not yet agreed to the TOS! TOS content goes here. <a href='?a=yes'>I agree</a>- If you don't agree, leave this page now.");

if ($action =="yes") {
   echo "You've agreed to the TOS.<br><a href='index.php'>Back</a>";
   mysql_query("INSERT INTO agreedusers ('$ip')") or die(mysql_error());
   } else {

echo "You've agreed to the TOS.";

}

?>

 

http://sawthememusic.comli.com/

 

It says you've agreed when you really haven't, and it says I have an error in my SQL syntax at http://sawthememusic.comli.com/?a=yes

Alright, I updated my code and fixed a few things you mentioned.

 

<?php

$ip = $_SERVER[REMOTE_ADDR];
$action = $_GET['a'];

//prosses of getting the numbers for users

        $construct = "SELECT * FROM agreedusers WHERE ip='$ip'";
        $run = mysql_query($construct);

        $foundnum = (mysql_num_rows($run));

if ($foundnum ==0)
   die("You have not yet agreed to the TOS! TOS content goes here. <a href='index.php?a=yes'>I agree</a>- If you don't agree, leave this page now.");

if ($action =="yes") {
   echo "You've agreed to the TOS.<br><a href='index.php'>Back</a>";
   mysql_query("INSERT INTO agreedusers VALUES ('$ip')") or die(mysql_error());
   } else {

echo "You've agreed to the TOS.";

}

?>

 

Now, when I click the agree link it doesn't do anything.

try

 

if ( isset($action) =="yes") {

 

see if that works =/

 

also it's probably because you have

 

$ip = $ip = $_SERVER['REMOTE_ADDR']; instead of $ip = $_SERVER[REMOTE_ADDR]; (punctuations)

 

 

try this too:

 

$foundnum = mysql_num_rows($run); instead of $foundnum = (mysql_num_rows($run));

try

 

if ( isset($action) =="yes") {

 

see if that works =/

 

also it's probably because you have

 

$ip = $_SERVER[REMOTE_ADDR]; instead of $ip = $_SERVER['REMOTE_ADDR']; (punctuations)

 

 

try this too:

 

$foundnum = mysql_num_rows($run); instead of $foundnum = (mysql_num_rows($run));

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.