Jump to content

Archived

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

silentg0d

Help whats wrong with this login?

Recommended Posts

help this isnt workin whats wrong??

[code]<php? if( !isset( $_POST['submit'] ) )
{

echo( '<form action="' . $_SERVER['PHP_SELF'] . '" method="post">
Username: <input type="text" name="username" /><br />
Password: <input type="password" name="password" /><br />
<input type="submit" name="submit" value="Login" />' );

} else {

if( $file_exists( 'users.db' )
{

$file = file( 'users.db' );

foreach( $file as $info )
{

$explode = explode( '|', $info );
$user = $explode[0];
$pass = $explode[1];
$email = $explode[2];
$usern = $_POST['username'];
$passw = $_POST['password'];
if( ( $usern == $user ) && ( $passw == $pass ) )
{
echo( 'Members Area' );
}
}

} else {

$fopen = fopen( 'users.db', 'w+' )
fwrite( $fopen, '' );
fclose( $fopen );
}
?>[/code]

Share this post


Link to post
Share on other sites
for one, at the very top:  <?php instead of <php?
Also, echo is not a function that uses () as far as I know, it's 

echo "This will be printed";

Share this post


Link to post
Share on other sites
i changed <php? to <?php and i get this error
Parse error: syntax error, unexpected '{' in /home/xploit/public_html/home/index.php on line 91

which would be this line

<?php if( !isset( $_POST['submit'] ) )
{

echo( '<form action="' . $_SERVER['PHP_SELF'] . '" method="post">
Username: <input type="text" name="username" /><br />
Password: <input type="password" name="password" /><br />
<input type="submit" name="submit" value="Login" />' );

} else {

if( $file_exists( 'users.db' )
>>>>>>>>>>>>>>>>>>>>>>>>>>>{

$file = file( 'users.db' );

foreach( $file as $info )
{

$explode = explode( '|', $info );
$user = $explode[0];
$pass = $explode[1];
$email = $explode[2];
$usern = $_POST['username'];
$passw = $_POST['password'];
if( ( $usern == $user ) && ( $passw == $pass ) )
{
echo( 'Members Area' );
}
}

} else {

$fopen = fopen( 'users.db', 'w+' )
fwrite( $fopen, '' );
fclose( $fopen );
}
?>

Share this post


Link to post
Share on other sites
This should work:
[code]
<?php
if(!isset( $_POST['submit'])) {
echo( '<form action="bbb.php" method="post">
Username: <input type="text" name="username" /><br />
Password: <input type="password" name="password" /><br />
<input type="submit" name="submit" value="Login" />' );
}
if(file_exists('users.db' )){
$file = file( 'users.db' );
foreach( $file as $info ) {
$explode = explode( '|', $info );
$user = $explode[0];
$pass = $explode[1];
$email = $explode[2];
$usern = $_POST['username'];
$passw = $_POST['password'];
if( ( $usern == $user ) && ( $passw == $pass ) ){
echo( 'Members Area' );
}
}
}
else{
$fp = fopen ("users.db", "w+");
fwrite ($fp, "");
fclose ($fp);
}
?>
[/code]

Share this post


Link to post
Share on other sites
i tried tht and got this error
Parse error: syntax error, unexpected $end in /home/xploit/public_html/home/index.php on line 275

Share this post


Link to post
Share on other sites
You might want to try formatting the code so its easily readable. Also pointing out which lines are throwing errors helps us to debug, better yet, maybe learn to debug yourself.

[code=php:0]
<?php

  if (!isset( $_POST['submit'])) {
    echo '<form action="bbb.php" method="post">
    Username: <input type="text" name="username" /><br />
    Password: <input type="password" name="password" /><br />
    <input type="submit" name="submit" value="Login" />';
  }
  if (file_exists('users.db')) {
    $file = file('users.db');
    foreach ($file as $info) {
      $explode = explode('|',$info);
      $user = $explode[0];
      $pass = $explode[1];
      $email = $explode[2];
      $usern = $_POST['username'];
      $passw = $_POST['password'];
      if (($usern == $user) && ($passw == $pass)) {
        echo( 'Members Area' );
      }
    }
  } else {
    $fp = fopen ("users.db", "w+");
    fwrite ($fp, "");
    fclose ($fp);
  }
?>
[/code]

As far as I can tell there are no syntax erros in the above code. The logic of it however is pretty out there. You really should have a call to exit() after echo( 'Members Area' );.

Share this post


Link to post
Share on other sites
im sorry to be a pain but you last debug seemed to have worked somewhat it fixed the code sortove but i still get
Warning: fopen(users.db) [function.fopen]: failed to open stream: Permission denied in /home/xploit/public_html/home/index.php on line 102

Warning: fwrite(): supplied argument is not a valid stream resource in /home/xploit/public_html/home/index.php on line 103

Warning: fclose(): supplied argument is not a valid stream resource in /home/xploit/public_html/home/index.php on line 104

Share this post


Link to post
Share on other sites
80    <?php
81
82      if (!isset( $_POST['submit'])) {
83      echo '<form action="bbb.php" method="post">
84      Username: <input type="text" name="username" /><br />
85      Password: <input type="password" name="password" /><br />
86      <input type="submit" name="submit" value="Login" />';
87      }
88      if (file_exists('users.db')) {
89      $file = file('users.db');
90      foreach ($file as $info) {
91      $explode = explode('|',$info);
92      $user = $explode[0];
93      $pass = $explode[1];
94      $email = $explode[2];
95      $usern = $_POST['username'];
96      $passw = $_POST['password'];
97      if (($usern == $user) && ($passw == $pass)) {
98        echo( 'Members Area' );
99      }
100    }
101    } else {
102    $fp = fopen ("users.db", "w+");
103    fwrite ($fp, "");
104    fclose ($fp);
105    }
106    ?>

Share this post


Link to post
Share on other sites
The code i sent you WORKS!(i checked it),but it is obviously just part of some script,and the problem is not in this part-problem is somewhere else.
If you get permission denied message change folder permissions to 777.

Share this post


Link to post
Share on other sites
ive resolved this  i had to change <form action="bbb.php" or whatever you put init to <form action="' . $_SERVER['PHP_SELF'] . '" plz lock

Share this post


Link to post
Share on other sites

×

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.