registration page error

Discussion in 'PHP' started by buddingphp, Jun 14, 2008.

  1. #1
    Hi

    I'm trying to set up a simple registration page. It seems I'm missing the corefuncs.php file but cant locate it anywhere. Is there anyone who is familiar with this? Thanks. (hopefully the codes are ok otherwise).
    My errors are:

    Warning: include(../includes/corefuncs.php) [function.include]: failed to open stream: No such file or directory in /home/crikle/public_html/register.php on line 5

    Warning: include(../includes/corefuncs.php) [function.include]: failed to open stream: No such file or directory in /home/crikle/public_html/register.php on line 5

    Warning: include() [function.include]: Failed opening '../includes/corefuncs.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/crikle/public_html/register.php on line 5

    Fatal error: Call to undefined function nukemagicquotes() in /home/crikle/public_html/register.php on line 6

    My code is:

    <?php
    // execute script only if form has been submitted
    if (array_key_exists('register', $_POST)) {
    // remove backslashes from the $_POST array
    include('../includes/corefuncs.php');
    nukeMagicQuotes();
    // check length of username and password
    $username = trim($_POST['user_name']);
    $pwd = trim($_POST['password']);
    if (strlen($username) < 6 || strlen($pwd) < 6) {
    $result = 'Username and password must contain at least 6 characters';
    }
    // check that the passwords match
    elseif ($pwd != $_POST['conf_pwd']) {
    $result = 'Your passwords don\'t match';
    }
    // continue if OK
    else {
    // encrypt password, using username as salt
    $pwd = sha1($username.$pwd);
    // define filename and open in read-write append mode
    $filename = 'C:/private/encrypted.txt';
    $file = fopen($filename, 'a+');
    // if filesize is zero, no names yet registered
    // so just write the username and password to file
    if (filesize($filename) === 0) {
    fwrite($file, "$username, $pwd");
    }
    // if filesize is greater than zero, check username first
    else {
    // move internal pointer to beginning of file
    rewind($file);
    // loop through file one line at a time
    while (!feof($file)) {
    $line = fgets($file);
    // split line at comma, and check first element against username
    $tmp = explode(', ', $line);
    if ($tmp[0] == $username) {
    $result = 'Username taken - choose another';
    break;
    }
    }
    // if $result not set, username is OK
    if (!isset($result)) {
    // insert line break followed by username, comma, and password
    fwrite($file, "\r\n$username, $pwd");
    $result = "$username registered";
    }
    // close the file
    fclose($file);
    }
    }
    }
    ?>


    HTML code is:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Register user</title>
    </head>

    <body>
    <h1>Register user</h1>
    <?php
    if (isset($result)) {
    echo "<p>$result</p>";
    }
    ?>
    <form method="POST" action="register.php">
    <p>
    <label for="user_name">Username:</label>
    <input type="text" name="user_name" id="user_name" />
    </p>
    <p>
    <label for="password">Password:</label>
    <input type="password" name="password" id="password" />
    </p>
    <p>
    <label for="conf_pwd">Confirm password:</label>
    <input type="password" name="conf_pwd" id="conf_pwd" />
    </p>
    <p>
    <input name="register" type="submit" id="register" value="Register" />
    </p>
    </form>
    </body>
    </html>
     
    buddingphp, Jun 14, 2008 IP
  2. RyanDoubleyou

    RyanDoubleyou Peon

    Messages:
    86
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Does it really exist? If so try:
    include("YOUR FULL SITE URL/includes/corefuncs.php");
    Code (markup):
    Or try it without the full URL and without the "/" before includes
     
    RyanDoubleyou, Jun 17, 2008 IP