gsquare567 Posted April 28, 2007 Share Posted April 28, 2007 $result = mysql_query("SELECT * FROM AuthDB WHERE Username = $_GET['username']"); this does not work. in the address bar i typed in http://localhost/abc.php?username=Test am i using the GET wrong? Quote Link to comment https://forums.phpfreaks.com/topic/49100-solved-getting-variable-from-url-address/ Share on other sites More sharing options...
bobleny Posted April 28, 2007 Share Posted April 28, 2007 $result = mysql_query("SELECT * FROM AuthDB WHERE Username = $_GET['username']"); this does not work. in the address bar i typed in http://localhost/abc.php?username=Test am i using the GET wrong? Oh man! You best not do that! That is generally a bad idea! You want to control what your user puts into your query. Never put direct user info into a query! Quote Link to comment https://forums.phpfreaks.com/topic/49100-solved-getting-variable-from-url-address/#findComment-240569 Share on other sites More sharing options...
cmgmyr Posted April 28, 2007 Share Posted April 28, 2007 Take a look at this: http://www.unixwiz.net/techtips/sql-injection.html you would be better off storing the username and/or userid in a session (or something) then running a query from that after they are signed in. Quote Link to comment https://forums.phpfreaks.com/topic/49100-solved-getting-variable-from-url-address/#findComment-240572 Share on other sites More sharing options...
desithugg Posted April 28, 2007 Share Posted April 28, 2007 <? $find_user = $_GET['username']; $query = mysql_query("SELECT * from AuthDB WHERE Username = '$find_user'") or die(mysql_error()); $row = mysql_fetch_array( $query ); $user_check = $row["id"]; if($user_check=="") { echo"Invalid Username"; exit; } else { //carry out what ever } ?> I tried doing this $query = mysql_query("SELECT * from AuthDB WHERE Username = $_GET['username']") or die(mysql_error()); once but it didn't work but than i tried $find_user = $_GET['username']; $query = mysql_query("SELECT * from AuthDB WHERE Username = '$find_user'") or die(mysql_error()); and it worked not sure why but you can give it a try Quote Link to comment https://forums.phpfreaks.com/topic/49100-solved-getting-variable-from-url-address/#findComment-240573 Share on other sites More sharing options...
gsquare567 Posted April 28, 2007 Author Share Posted April 28, 2007 thanks so much! it works!!! ur a great help. Quote Link to comment https://forums.phpfreaks.com/topic/49100-solved-getting-variable-from-url-address/#findComment-240587 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.