silentg0d Posted October 29, 2006 Share Posted October 29, 2006 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] Quote Link to comment Share on other sites More sharing options...
Wintergreen Posted October 29, 2006 Share Posted October 29, 2006 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"; Quote Link to comment Share on other sites More sharing options...
silentg0d Posted October 29, 2006 Author Share Posted October 29, 2006 no <php? is rite becuz when i change it to <?php it errors the whole page Quote Link to comment Share on other sites More sharing options...
silentg0d Posted October 29, 2006 Author Share Posted October 29, 2006 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 91which 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 ); } ?> Quote Link to comment Share on other sites More sharing options...
sinisake Posted October 30, 2006 Share Posted October 30, 2006 This should work:[code]<?phpif(!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] Quote Link to comment Share on other sites More sharing options...
silentg0d Posted October 30, 2006 Author Share Posted October 30, 2006 i tried tht and got this error Parse error: syntax error, unexpected $end in /home/xploit/public_html/home/index.php on line 275 Quote Link to comment Share on other sites More sharing options...
trq Posted October 30, 2006 Share Posted October 30, 2006 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' );. Quote Link to comment Share on other sites More sharing options...
silentg0d Posted October 30, 2006 Author Share Posted October 30, 2006 ty and i would debug it myself but im just learning php, my friend made this for me and hes rarely on.. Quote Link to comment Share on other sites More sharing options...
silentg0d Posted October 30, 2006 Author Share Posted October 30, 2006 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 102Warning: fwrite(): supplied argument is not a valid stream resource in /home/xploit/public_html/home/index.php on line 103Warning: fclose(): supplied argument is not a valid stream resource in /home/xploit/public_html/home/index.php on line 104 Quote Link to comment Share on other sites More sharing options...
silentg0d Posted October 30, 2006 Author Share Posted October 30, 2006 80 <?php8182 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 ?> Quote Link to comment Share on other sites More sharing options...
sinisake Posted October 30, 2006 Share Posted October 30, 2006 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. Quote Link to comment Share on other sites More sharing options...
silentg0d Posted November 1, 2006 Author Share Posted November 1, 2006 ive resolved this i had to change <form action="bbb.php" or whatever you put init to <form action="' . $_SERVER['PHP_SELF'] . '" plz lock Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.