Jump to content

Help with misuse of includes and variables


plznty

Recommended Posts

<?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

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

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>';
?>

<?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

<?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

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.