Jump to content

Help whats wrong with this login?


silentg0d

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]
Link to comment
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 );
}
?>
Link to comment
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]
Link to comment
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' );.
Link to comment
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
Link to comment
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    ?>
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.