plznty Posted November 14, 2008 Share Posted November 14, 2008 <?php $username = include("archive/username.txt"); $password = include("archive/password.txt"); if ( $_GET[username] == $username ) { echo " Hello World "; } else { echo " Omg Quackerz "; } ?> How do I make it so if in title index.php?username= [ get from archive/username.txt ] then say hello world. Etc for password aswell. If not either of those, say omg quackerz Thanks Quote Link to comment https://forums.phpfreaks.com/topic/132769-help-with-misuse-of-includes-and-variables/ Share on other sites More sharing options...
wildteen88 Posted November 14, 2008 Share Posted November 14, 2008 You cannot assign an include to a variable. You should look into file_get_contents or fopen/fread instead. if(isset($_GET['username']) && file_exists('archive/'.$_GET['username'].'.txt')) { $data['username'] = file_get_contents('archive/'.$_GET['username'].'.txt'; } if(isset($_GET['password']) && file_exists('archive/'.$_GET['password'].'.txt')) { $data['password'] = file_get_contents('archive/'.$_GET['password'].'.txt'; } echo '<pre>'.print_r($data, true).'<pre>'; Quote Link to comment https://forums.phpfreaks.com/topic/132769-help-with-misuse-of-includes-and-variables/#findComment-690474 Share on other sites More sharing options...
plznty Posted November 14, 2008 Author Share Posted November 14, 2008 That doesnt work, can someone correct it Quote Link to comment https://forums.phpfreaks.com/topic/132769-help-with-misuse-of-includes-and-variables/#findComment-690479 Share on other sites More sharing options...
flyhoney Posted November 14, 2008 Share Posted November 14, 2008 Is this the correction you are looking for? <?php if(isset($_GET['username']) && file_exists('archive/username.txt')) { $data['username'] = file_get_contents('archive/username.txt'); } if(isset($_GET['password']) && file_exists('archive/password.txt')) { $data['password'] = file_get_contents('archive/password.txt'); } echo '<pre>'.print_r($data, true).'<pre>'; ?> Quote Link to comment https://forums.phpfreaks.com/topic/132769-help-with-misuse-of-includes-and-variables/#findComment-690480 Share on other sites More sharing options...
plznty Posted November 14, 2008 Author Share Posted November 14, 2008 <?php if(isset($_GET['username']) && file_exists('archive/username.txt')) { $data['username'] = file_get_contents('archive/username.txt'); } if(isset($_GET['password']) && file_exists('archive/password.txt')) { $data['password'] = file_get_contents('archive/password.txt'); } echo '<pre>'.print_r($data, true).'<pre>'; ?> I want it so that it displays text if ?username=[username.txt]&password=[password.txt] in like pheudo code terms or wteva. If not then display like "wrong" Cheers for ur help so far Quote Link to comment https://forums.phpfreaks.com/topic/132769-help-with-misuse-of-includes-and-variables/#findComment-690483 Share on other sites More sharing options...
ShiloVir Posted November 14, 2008 Share Posted November 14, 2008 <?php $username = $_GET['username']; $password = $_GET['password']; if(isset($username) && file_exists('archive/username.txt')) { $data['username'] = file_get_contents('archive/username.txt'); } if(isset($password) && file_exists('archive/password.txt')) { $data['password'] = file_get_contents('archive/password.txt'); } echo '<pre>'.print_r($data, true).'<pre>'; ?> Then simply if u wanna pull Username and pass type like this: "Localhost/login.php?Username=carl419&password=Freddyiscool" u can even impliment this into a $_POST['username']; and $_POST['password']; Veriables Quote Link to comment https://forums.phpfreaks.com/topic/132769-help-with-misuse-of-includes-and-variables/#findComment-690496 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.