HELP! Question about PHP/mySQL login system!

Discussion in 'PHP' started by priver, Jan 10, 2010.

  1. #1
    Hello to everyone! I'm new here.
    I'm an artist (a 2d animator to be precise) and I like making websites too, more on the design part, yet I know a little bit of programming to survive.

    I've been trying some new things besides actionscript and HTML, such as PHP and CSS to improve my sites.
    Yesterday I downloaded a really good login/membership system in PHP/mySQL:

    http://www.awesomephp.com/index.php?Membership-2

    I was able to install the database and everything, but when I tried implementing the PHP into the HTML of my website, I get this:

    Warning: fread(): supplied argument is not a valid stream resource in /home/httpd/html/uol2661anx.plugin.com.br/html/login.php on line 95

    Warning: fclose(): supplied argument is not a valid stream resource in /home/httpd/html/uol2661anx.plugin.com.br/html/login.php on line 98

    Fatal error: Call to undefined function: encode_decode() in /home/httpd/html/uol2661anx.plugin.com.br/html/login.php on line 105



    On the readme file, he states:

    Implement the following files on your site:

    register.php
    login.php
    forgotpass.php
    profile.php
    upgrade.php
    logout.php

    ******************IMPORTANT NOTICE************************
    - Each one of the 6 above files contain ONLY the HTML to display the info. You MUST include each file's extensions on top-most of the page you are implementing it on.
    - If you are not implementing this script into your current application, then simply uncomment the :

    require_once('extensions/file.php');

    in each of the above 6 files.



    So what I did was, in the index.php (my home page), I added this before the <html> tag:
    <?php
    require_once('extensions/login.php');
    require_once('extensions/forgotpass.php');
    require_once('extensions/upgrade.php');
    require_once('extensions/register.php');
    require_once('extensions/profile.php');
    require_once('headers/database.php');
    ?>



    All the files are on my server... I have no idea what I need to do, I tried many things and it always gives me these kinds of errors! :confused:

    Thank you so much in advance!!

    Priscila
     
    priver, Jan 10, 2010 IP
  2. Bohra

    Bohra Prominent Member

    Messages:
    12,573
    Likes Received:
    537
    Best Answers:
    0
    Trophy Points:
    310
    #2
    post the code of login.php here
     
    Bohra, Jan 10, 2010 IP
  3. priver

    priver Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    <?php
    /************* Membership V2.0 *******************/
    /*
    Released by AwesomePHP.com, under the GPL License, a
    copy of it should be attached to the zip file, or
    you can view it on http://AwesomePHP.com/gpl.txt
    */
    /************* Membership V2.0 *******************/

    /*
    Login header - The following line MUST be included on TOPMOST of your website
    then put the form whereever you want. This is so, because we might need to redirect
    and PHP CAN NOT redirect after any output to the browser
    */

    /*
    The next line is to be placed on top-most of your site:
    */
    //require_once('extensions/login.php');


    require_once('languages/language.php');


    ?>
    <form name="login" id="login" method="post" action="<?php echo $_SERVER['PHP_SELF'];?>" style="display:inline;">
    <table width="100%" border="1" cellspacing="0" cellpadding="5">
    <tr bgcolor="#BEDEDE">
    <td colspan="2"><div align="center"><font color="#999999" size="4">User Login </font></div></td>
    </tr>
    <?php
    if($message != NULL){
    ?>
    <tr bgcolor="#FFDDDD">
    <td colspan="2"><strong><font color="#FF0000"><?php echo $message;?></font></strong></td>
    </tr>
    <?php } ?>
    <tr>
    <td>Select Membership: </td>
    <td width="50%"><font size="2">
    <select id="membership_id" name="membership_id" class="hiddenText">
    <?php
    foreach($membershipList as $em){
    if($_POST['membership_id'] == $em['membership_id']){ $sel= ' selected';}else{$sel=NULL;}
    echo '<option value="'.$em['membership_id'].'"'.$sel.'>'.$em['membership_title'].'</option>';
    }
    ?>
    </select>
    </font></td>
    </tr>
    <tr>
    <td width="50%">Please enter Email: </td>
    <td width="50%"><input name="user_email" type="text" id="user_email" value="<?php echo $_POST['user_email'];?>">
    </td>
    </tr>
    <tr>
    <td>Please enter Password: </td>
    <td width="50%"><input name="user_password" type="password" id="user_password"></td>
    </tr>
    <?php
    if($CF_CAPTHCA == 'IMAGE'){?>
    <tr>
    <td>Enter Verification Code: </td>
    <td><table border="0" cellspacing="0" cellpadding="5">
    <tr>
    <td class="acont"><div align="center">
    <?php
    $referenceid = md5(mktime()*rand());
    //Generate the random string
    $chars = array("a","A","b","B","c","C","d","D","e","E","f","F","g","G","h","H","i","I","j","J","k",
    "K","l","L","m","M","n","N","o","O","p","P","q","Q","r","R","s","S","t","T","u","U","v",
    "V","w","W","x","X","y","Y","z","Z","1","2","3","4","5","6","7","8","9");
    $length = $CF_LENGH;
    $textstr = "";
    for ($i=0; $i<$length; $i++) {
    $textstr .= $chars[rand(0, count($chars)-1)];
    }
    $new_string = encode_decode($textstr,$CF_ENCDEC);
    $image_link = bin2hex($new_string);
    ?>
    <img src="captcha.php?code=<?php echo $image_link;?>">
    <input name="registration_id" type="hidden" id="registration_id" value="<?php echo $image_link;?>">
    </div></td>
    </tr>
    <tr>
    <td class="acont"><div align="center">
    <input name="answer" type="text" id="answer">
    </div></td>
    </tr>
    </table></td>
    </tr>
    <?php
    } else {
    $f = fopen($CF_QUESTIONFILE,'r');
    while($t = fread($f,102465)){
    $content .= $t;
    }
    fclose($f);
    $content = trim(preg_replace('/\/\*.*\*\//ism', '', $content));

    $temp = explode("\n",$content);
    $random = rand(0,count($temp)-1);
    $rand = $temp[$random];
    list($question,$registration_id) = explode('\n\\',$rand);
    $registration_id = bin2hex(encode_decode($registration_id,$CF_ENCDEC));
    ?>
    <tr>
    <td>Answer this: <strong><?php echo $question;?></strong> </td>
    <td><input name="answer" type="text" id="answer" value="<?php echo $_POST['answer'];?>">
    <input name="registration_id" type="hidden" id="registration_id" value="<?php echo $registration_id;?>"></td>
    </tr>
    <tr>
    <td colspan="2"><div align="center">
    <input id="persistent" name="persistent" value="yes" checked="checked" type="checkbox">
    Keep me signed in<br>
    <font color="#999999" size="2">for
    <select name="persistentFor" id="persistentFor" style="border:0px;color:#999999;font-size:10px;">
    <?php
    if($_POST['persistentFor'] == NULL){$_POST['persistentFor'] = 2;}
    for($x=1;$x<=480;$x++){
    if($x == $_POST['persistentFor']){$sel= ' selected';}else{$sel=NULL;}
    echo '<option value="'.$x.'"'.$sel.'>'.$x.'</option>';
    }
    ?>
    </select> week unless I sign out.<br/>
    [Uncheck if on a shared computer] </font>
    </div></td>
    </tr>
    <?php } ?>
    <tr bgcolor="#BEDEDE">
    <td colspan="2"><div align="center">
    <input type="submit" name="Submit" id="Submit" value="Login">
    <input name="S_ID" type="hidden" id="S_ID" value="2">
    </div></td>
    </tr>
    <tr bgcolor="#CAFFCA">
    <td colspan="2"><div align="center">[<a href="forgotpass.php">Forgot Password </a> - <a href="register.php">Register</a>] </div></td>
    </tr>
    </table>
    </form>
     
    priver, Jan 10, 2010 IP
  4. smartknight

    smartknight Active Member

    Messages:
    12
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    86
    #4
    Can you plz send me your server details like php version etc etc.

    Thanks
     
    smartknight, Jan 10, 2010 IP
  5. danx10

    danx10 Peon

    Messages:
    1,179
    Likes Received:
    44
    Best Answers:
    2
    Trophy Points:
    0
    #5
    danx10, Jan 10, 2010 IP
  6. LINUXADDICT

    LINUXADDICT Peon

    Messages:
    1
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    The developer placed the logic in a separated location that is not being called within the script. There is a simple solution for this issue:

    At the very top there are a few lines of comments like the following:

    
    <?php
    /************* Membership V2.0 *******************/
    /*
    Released by AwesomePHP.com, under the GPL License, a
    copy of it should be attached to the zip file, or
    you can view it on http://AwesomePHP.com/gpl.txt
    */
    /************* Membership V2.0 *******************/	
    
    /*
    Login header - The following line MUST be included on TOPMOST of your website
    then put the form whereever you want. This is so, because we might need to redirect
    and PHP CAN NOT redirect after any output to the browser
    */
    
    /*
    The next line is to be placed on top-most of your site:
    */
    //require_once('extensions/login.php');
    
    
    PHP:
    Find the very last comment (done placing the "//" before) and uncomment it (delete the "//") like this:
    
    <?php
    /************* Membership V2.0 *******************/
    /*
    Released by AwesomePHP.com, under the GPL License, a
    copy of it should be attached to the zip file, or
    you can view it on http://AwesomePHP.com/gpl.txt
    */
    /************* Membership V2.0 *******************/	
    
    /*
    Login header - The following line MUST be included on TOPMOST of your website
    then put the form whereever you want. This is so, because we might need to redirect
    and PHP CAN NOT redirect after any output to the browser
    */
    
    /*
    The next line is to be placed on top-most of your site:
    */
    require_once('extensions/login.php');
    
    
    PHP:
    You might want to do the same for other files with the same problems as most likely the same thing is happening in those. Just browse the site and see if others pages have the same error.

    Let me know if that works for you ;)
     
    LINUXADDICT, Mar 14, 2010 IP