URL Variable

Alles, was PHP betrifft, kann hier besprochen werden.

URL Variable

Postby nathan4eva » 20. December 2006 00:51

Hi, sorry I am english and dont speak any german.

I am having a problem with MySQL. The problem is that when I have a declared variable in a php page, then try to alter that variable via the URL. the value of the variable does not correspond to the value in the URL.

For exmaple somthing like:

<?php

$name = nathan;

echo ($name);

?>


Then if I was to enter to visit that page as : http://www.awebsite.com/index.php?name=mike

Any help is much appreciated, thank you.

Nathan.[/quote]
nathan4eva
 
Posts: 1
Joined: 20. December 2006 00:23

Postby deepsurfer » 20. December 2006 01:33

Code: Select all
<?php

echo $_GET[name];

?>



or that
Code: Select all
<?php

if($_GET[name] == "nathan")
    {
    echo "you are nathan";
    }
    else
    {
    echo "you are not nathan but ", $_GET[name];
    }
?>



or that
Code: Select all
<?php

$name1 = nathan;
if($_GET[name] == $name1)
    {
    echo "you are nathan";
    }
    else
    {
    echo "you are not nathan but ", $_GET[name];
    }
?>




in this case with MySQL:

Code: Select all
<?php
/*
- mysql_connect
- $dbcheckname = "read variable out of mysql-table"
*/

if($_GET[name] == $dbcheckname)
    {
    echo "you can go inside";
    }
    else
    {
    echo "you have no permission, but proud to see you ", $_GET[name];
    }
?>



greets
Deep
User avatar
deepsurfer
AF Moderator
 
Posts: 6440
Joined: 23. November 2004 10:44
Location: Cologne
Operating System: Win-XP / Win7 / Linux -Debian


Return to PHP

Who is online

Users browsing this forum: No registered users and 17 guests