Jump to content

Doesn't seem to recive data


Sami

Recommended Posts

This code:

<?phpif($_POST["pass"]&&$_POST["username"]) {$status=file_get_contents("http://192.168.0.197/login.php?username=".$_POST["username"]."&password=".$_POST["pass"]);$user=file_get_contents("http://192.168.0.197/login.php?username=".$_POST["username"]."&password=".$_POST["pass"]."&c=username");$mission=file_get_contents("http://192.168.0.197/login.php?username=".$_POST["pass"]."&password=".$_POST["pass"]."&c=mission");}if($user){setcookie("nick",$user);setcookie("mission",$mission);// header("location:chat");}else{if($ok=="Fail!") {// header("location:chat?action=errormsg"); }else {// header("location:chat?action=errormsg_offline"); }}echo "Debugging: " . $status;?>

Are returning this:

Debugging: 

But it's supposed to return this:

Debugging: ok

or this:

Debugging: Fail!

Anybody know what I've done wrong?

Link to comment
Share on other sites

There might be an error in login.php. What happens if you load it directly from your address bar? Should it output something if there is no POST data? That would let you test it, anyway.
Yeah, I've loaded it from my adress bar, and it's working just fine.
It will probably be a good idea to also make sure all errors messages are enabled. Maybe it's not even loading the page.
How?
Link to comment
Share on other sites

If you add these lines to the top of your script, you will get reports of runtime errors:

error_reporting(E_ALL);ini_set('display_errors', 1);

This technique will not alert you to syntax errors, because the lines will never execute. To detect syntax (parsing) errors, you might want to use a shell script.

Link to comment
Share on other sites

Notice: Undefined index: pass in /var/www/htl/retro/include/log_in.php on line 3Notice: Undefined variable: user in /var/www/htl/retro/include/log_in.php on line 9Notice: Undefined variable: ok in /var/www/htl/retro/include/log_in.php on line 16Notice: Undefined variable: status in /var/www/htl/retro/include/log_in.php on line 25Debugging: 

Link to comment
Share on other sites

$user=file_get_contents("http://192.168.0.197/login.php?username=".$_POST["username"]."&password=".$_POST["pass"]."&c=username")

most probably $user is not assighining a value there...i think it is not entering in your first if block..you may echo the $_POST data to check that what the values are coming.

Link to comment
Share on other sites

You really should change this line:if($_POST["pass"]&&$_POST["username"]) {to this:if(isset($_POST['pass']) && isset($_POST['username']) ) {If either of those values has not been sent by the form, you will generate the first notice. So maybe you tested the documents by leaving the password field empty?$user has not been initialized. This means that if the first condition fails, this line:if($user){will be attempting to access a variable that does not exist. The same is true here:if($ok=="Fail!")I don't see any line in your code that sets the value of $ok to anything. This could be a serious problem.In looks like $status is not echoing. Be aware that if file_get_contents cannot open your file, it will return FALSE. PHP echoes the value of TRUE as 1. You might think it would echo the value of FALSE as 0, but instead it echoes nothing. So something could be wrong with the address you are passing to file_get_contentsIn this case, however, if $_POST["pass"] has no value, or is not set, $status does not get set, and that will cause your final notice.You should try to var_dump($_POST) at the top of your script to see if it contains what it should contain. Make sure that 'pass' and 'username' are named fields in your POST form.

Link to comment
Share on other sites

<?phpif(isset($_POST['pass']) && isset($_POST['username']) ) {$status=file_get_contents("http://192.168.0.197/login.php?username=".$_POST["username"]."&password=".$_POST["pass"]);$user=file_get_contents("http://192.168.0.197/login.php?username=".$_POST["username"]."&password=".$_POST["pass"]."&c=username");$mission=file_get_contents("http://192.168.0.197/login.php?username=".$_POST["pass"]."&password=".$_POST["pass"]."&c=mission");}if(isset($status)){setcookie("nick",$user);setcookie("mission",$mission);// header("location:chat");}else{if($status=="Fail!") {// header("location:chat?action=errormsg"); }else {// header("location:chat?action=errormsg_offline"); }}echo "<p>Debugging: " . $status . "</p>";?>

Still not working...

Link to comment
Share on other sites

Add these temporary statements to your code. (Don't add the statements that are identical to your existing statements)

<?phperror_reporting(E_ALL);ini_set('display_errors', 1);var_dump($_POST); // just to see; please copy the text and show us.if(isset($_POST['pass']) && isset($_POST['username']) ) {$status=file_get_contents("http://192.168.0.197/login.php?username=".$_POST["username"]."&password=".$_POST["pass"]);if ($status) {   echo $status;}else {   echo '$status has no value';}exit; // just terminate execution here so you can see what is happening. Please show us what get's echoed.

If this goes on much longer we'll need to see the contents of login.php

Link to comment
Share on other sites

you missed one of the biggest piece's of advice DD gave you

You should try to var_dump($_POST) at the top of your script to see if it contains what it should contain. Make sure that 'pass' and 'username' are named fields in your POST form.
making sure the form is even submitting properly should be the first step in debugging in these kinds of situations.
Link to comment
Share on other sites

Add these temporary statements to your code. (Don't add the statements that are identical to your existing statements)
<?phperror_reporting(E_ALL);ini_set('display_errors', 1);var_dump($_POST); // just to see; please copy the text and show us.if(isset($_POST['pass']) && isset($_POST['username']) ) {$status=file_get_contents("http://192.168.0.197/login.php?username=".$_POST["username"]."&password=".$_POST["pass"]);if ($status) {   echo $status;}else {   echo '$status has no value';}exit; // just terminate execution here so you can see what is happening. Please show us what get's echoed.

If this goes on much longer we'll need to see the contents of login.php

Parse error: syntax error, unexpected $end in /var/www/htl/retro/include/log_in.php on line 49 Huh? The PHP end tag is at line 49 - nothing else.
Link to comment
Share on other sites

That usually mean a (parenthesis) or a {brace} did not get closed somewhere in the middle of the script. It might have happened when you added the code I gave you.BTW, if you are getting reports of parse errors, you do not need to turn on error reporting at the top of your script. It must already be on, or you are using the shell script I linked you to.

Link to comment
Share on other sites

That file is just an included file that's being included if the cookie "nick" and the GET "action=dologin", so I added the error reporting to the file the users are accessing.

Link to comment
Share on other sites

Just changed the code a little bit:

<?phpif(isset($_POST['pass']) && isset($_POST['username']) ) {$status=file_get_contents("http://192.168.0.197/login.php?username=".$_POST["username"]."&password=".$_POST["pass"]);$user=file_get_contents("http://192.168.0.197/login.php?username=".$_POST["username"]."&password=".$_POST["pass"]."&c=username");$mission=file_get_contents("http://192.168.0.197/login.php?username=".$_POST["pass"]."&password=".$_POST["pass"]."&c=mission");}if(isset($status)){setcookie("nick",$user);setcookie("mission",$mission);// header("location:chat");}else{if($status=="Fail!") {// header("location:chat?action=errormsg"); }else {// header("location:chat?action=errormsg_offline"); }}if(!isset($status)){$status="<i>\$status</i> isn't set";}echo "<p>Debugging: " . $status . "</p>";print_r($_POST);?>

This is it's result:

Notice: Undefined variable: status in /var/www/htl/retro/include/log_in.php on line 15<p>Debugging: <i>$status</i> isn't set</p>Array(    [username] => Sami    [password] => *************)

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...