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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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));

Link to comment
Share on other sites

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));

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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