Results 1 to 6 of 6
  1. #1
    Join Date
    Aug 2003
    Posts
    19

    Unanswered: The Page Cannot Be Found ...

    I am trying to use this login script that has the login and password in a mysql database called Clamps. The data is located in the table customers within the Clamps database.

    Can anybody tell me when I click on the submit button, I get the famous "The Page Cannot Be Found" screen?

    Richard M

    PHP Code:
    <?php
    echo "YOu got this far!";  //this message appears on the sceen when page loads
    if (isset($_POST['ccust']) || isset($_POST['cpass'])) {
    echo 
    "YOu got this far2!";  // This part is skipped
    // form submitted
    // check for required values
    if (empty($_POST['ccustomer'])) {
        die (
    "ERROR: Please enter username!");
    }
    if (empty(
    $_POST['cpassword'])) {
        die (
    "ERROR: Please enter password!");
    }

    // set server access variables
    $host "localhost";
    $user "";
    $pass "";
    $db "clamps";

    // open conection
    $connection mysql_connect($host$user$pass) or die ("Unable to connect!");

    // select database
    mysql_select_db($db) or die ("Unable to select database!");

    // check for db


    // create query
    $query "SELECT * FROM customers WHERE ccustomer = '" $_POST['ccustomer'] . "' AND cpassword = SHA1('" $_POST['cpassword'] . "')";

    // execute query
    $result mysql_query($query) or die ("ERROR in query: $query. " mysql_error());

    // see if any rows were returned
    if (mysql_num_rows($result) == 1) {
        
    // if a row was returned
        // authentication was successful
        // create session and set cookiewith username
        
    session_start();
        

        
    $_SESSION['auth'] = 1;
        
    //setcookie("username", $_POST['ccustomer'], time()+(84600*30));
        
    echo "Access granted!";
        }
    else {
        
    // no results
        // authentication failed
        
    echo "ERROR: Incorrect username or password!";
        }
        
        
    // free result set memory
        
    mysql_free_result($result);
        
        
    // close connection
        
    mysql_close($connection);
        }
        else {
        
    // no submission
        // display login form
        
        
    echo "YOu got this far3!"//this message appears on the sceen when page loads
        
    ?>
            <html>
            <head></head>
            <body><form method="post" action="<?php echo $_server['PHP_SELF']; ?>"> 
    <p><div align="center">
    Username <input type="text" name="ccust">
    </div><br>
    <div align="center">
            Password <input type="password" name="cpass">
            </div><br>
             
            <div align="center">
            <input type="submit" name="submit" value="Log In">
            
            </div></p>
            </body>
            
            
            
            </html>
    <?php
    }

    ?>

  2. #2
    Join Date
    Jul 2003
    Posts
    73
    When you are viewing your form - do a View Source - to see if the action is actually being populated.

    I can't test from work - but I think it's the lower case $_server that's causing you grief. Try it in uppercase ($_SERVER['PHP_SELF']) and see if that works.
    Joel Dixon
    Analyst Programmer
    Melbourne, Australia

  3. #3
    Join Date
    Aug 2003
    Posts
    19
    Joe,

    I changed the server to SERVER and it is now working but I still have a problem with having the correct username. I will be working on this tomorrow. Thanks for looking at the script. I new at this mysql and php.

    Richard M

  4. #4
    Join Date
    Aug 2003
    Posts
    19
    Joe

    I got past the username and password, but the script hangs up on "Unable to select database".

    The database "Clamps" is a Mysql database and is a folder with tables (text and frm) in it. It works great in Mysql. I loaded this to the same folder the script is in on the server. I must be missing something that I do not understand.

    Right now the path in the server goes like this:

    /
    Customers
    .....Clamps
    .........customer1.txt
    .........customers.frm
    .....login1.php // my script

    Richard M
    Last edited by Richard m; 12-23-04 at 13:09. Reason: Add more information

  5. #5
    Join Date
    Jul 2003
    Posts
    73
    Good question - I still haven't migrated a MySQL database to a web server yet (other than my server at home) - so I'm not sure of the process for copying your tables to the one host.

    Anyone got any ideas?
    Joel Dixon
    Analyst Programmer
    Melbourne, Australia

  6. #6
    Join Date
    Aug 2003
    Posts
    19
    Joe,

    I also saw that I was missing two files in Clamps. I did an alter table engine and type to myisam and this got my two missing files MYD and MYI. Uploaded to the server and still hung up unable to select database.

    Richard M

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •