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
https://forums.phpfreaks.com/topic/25527-help-whats-wrong-with-this-login/
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 );
}
?>
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]
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' );.
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
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    ?>

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.