Jump to content


Photo

Help whats wrong with this login?


  • Please log in to reply
11 replies to this topic

#1 silentg0d

silentg0d
  • Members
  • PipPip
  • Member
  • 23 posts

Posted 29 October 2006 - 11:19 PM

help this isnt workin whats wrong??

<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 );
			}
			?>


#2 Wintergreen

Wintergreen
  • Members
  • PipPipPip
  • Advanced Member
  • 107 posts

Posted 29 October 2006 - 11:29 PM

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

#3 silentg0d

silentg0d
  • Members
  • PipPip
  • Member
  • 23 posts

Posted 29 October 2006 - 11:43 PM

no <php? is rite becuz when i change it to <?php it errors the whole page

#4 silentg0d

silentg0d
  • Members
  • PipPip
  • Member
  • 23 posts

Posted 29 October 2006 - 11:53 PM

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 );
}
?>

#5 sinisake

sinisake
  • Members
  • PipPipPip
  • Advanced Member
  • 63 posts
  • LocationSerbia,

Posted 30 October 2006 - 12:03 AM

This should work:
<?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);
}
?>


#6 silentg0d

silentg0d
  • Members
  • PipPip
  • Member
  • 23 posts

Posted 30 October 2006 - 01:33 AM

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


#7 trq

trq
  • Staff Alumni
  • Advanced Member
  • 31,041 posts

Posted 30 October 2006 - 01:43 AM

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.

<?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);
  }
?>

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

#8 silentg0d

silentg0d
  • Members
  • PipPip
  • Member
  • 23 posts

Posted 30 October 2006 - 02:12 AM

ty and i would debug it myself but im just learning php, my friend made this for me and hes rarely on..

#9 silentg0d

silentg0d
  • Members
  • PipPip
  • Member
  • 23 posts

Posted 30 October 2006 - 02:20 AM

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

#10 silentg0d

silentg0d
  • Members
  • PipPip
  • Member
  • 23 posts

Posted 30 October 2006 - 02:42 AM

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

#11 sinisake

sinisake
  • Members
  • PipPipPip
  • Advanced Member
  • 63 posts
  • LocationSerbia,

Posted 30 October 2006 - 08:45 AM

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.

#12 silentg0d

silentg0d
  • Members
  • PipPip
  • Member
  • 23 posts

Posted 01 November 2006 - 10:11 PM

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




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users