Results 1 to 5 of 5

Thread: looking for a really simple login solution

  1. #1
    Join Date
    Sep 2011
    Posts
    9
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default looking for a really simple login solution

    Hi,

    I'm not actually sure where to begin with this or what form it should take.

    I'm just looking for a really simple login solution.

    1. I will be providing my users with a customer ID. So, they don't even create a username. I'll just give them an ID like d8a798-001.

    2. I will create their customer page. It's not a dynamic page. It's just simply a page that has what service of mine they're using, when their next payment is due and stuff like that. I simply edit that page and upload it to the server.

    3. On each page of my site is just a simple login form with one field for the customer ID and the login button. So they just simply enter their customer ID into that form and hit 'login' and it takes them to their page.

    So basically I just need the customer ID to match up with the customer page in some way (but not visible to the public), and then when someone enters their customer ID, it will take them to their customer page.

    It's sort of so simple that I don't know where to begin I'm finding lots of stuff about PHP and databases and validation and the usual login solutions, but can't find something along these lines. I don't really mind what form it takes, I'm just looking for a simple solution for the above. Would really appreciate your thoughts. Thanks.

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    29,213
    Thanks
    44
    Thanked 3,245 Times in 3,206 Posts
    Blog Entries
    12

    Default

    Sounds like you will need a separate page for each customer anyway. If so and you have PHP, just make them each a page with this on it (just use a different id for each customer - you can even have their name in the title):

    PHP Code:
    <!DOCTYPE html>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <?php 

    // Define the customer id 
    $password "d8a798-001"

    if (!isset(
    $_POST['txtPassword']) || $_POST['txtPassword'] != $password) { 

    ?> 
    <title>Login for Cutomer Name</title>
    <h1>Login</h1> 

    <form name="form" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> 

        <p><label for="txtpassword">Customer ID:</label> 
        <br /><input type="password" title="Enter your ID" name="txtPassword" /></p> 

        <p><input type="submit" name="Submit" value="Login" /></p> 

    </form> 

    <?php 


    else { 

    ?>

    The rest of the 'real' head and the body of the page go here

    <?php ?>
    </body></html>
    Last edited by jscheuer1; 02-01-2012 at 08:48 PM.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. The Following User Says Thank You to jscheuer1 For This Useful Post:

    waterprism (02-01-2012)

  4. #3
    Join Date
    Sep 2011
    Posts
    9
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default

    Hi, John. Thanks so much. That looks really good. It might be just the ticket. I will try that out soon. Thanks a lot for your time on this.

  5. #4
    Join Date
    Nov 2014
    Posts
    15
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Default

    Quote Originally Posted by jscheuer1 View Post
    Sounds like you will need a separate page for each customer anyway. If so and you have PHP, just make them each a page with this on it (just use a different id for each customer - you can even have their name in the title):

    PHP Code:
    <!DOCTYPE html>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <?php 

    // Define the customer id 
    $password "d8a798-001"

    if (!isset(
    $_POST['txtPassword']) || $_POST['txtPassword'] != $password) { 

    ?> 
    <title>Login for Cutomer Name</title>
    <h1>Login</h1> 

    <form name="form" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> 

        <p><label for="txtpassword">Customer ID:</label> 
        <br /><input type="password" title="Enter your ID" name="txtPassword" /></p> 

        <p><input type="submit" name="Submit" value="Login" /></p> 

    </form> 

    <?php 


    else { 

    ?>

    The rest of the 'real' head and the body of the page go here

    <?php ?>
    </body></html>
    I am building a simple uploader to add and delete notices to our village noticeboard which is embedded in a Joomla! site (see corrieandsannox.org). I have based the login page on the above code and the file calls "uploader.php" to verify the file and perform the actual upload. I would like to be able to return to the login page once the upload is complete and can do this in one of two ways.

    Firstly, using the browser back button goes back to the login page and remains logged in, but doesn't show the most recently uploaded file in the list; so the page has to be refreshed. The second method is simply calling the login page from the uploader using the button at the end. This returns to the login page but requires a new login.

    Is there any way I could return to the login page whilst remaining logged in but without resorting to the browser back button?

    The two files are attached and will run fine under "xampp" or on a server.

    nbmanager.php
    PHP Code:
    <!doctype html>
    <html lang="en">
     <head>
      <meta charset="UTF-8">
      <meta name="Generator" content="EditPlus">
      <meta name="Author" content="">
      <meta name="Keywords" content="">
      <meta name="Description" content="">
      <title>Noticeboard Manager</title>
        <style type="text/css">
          body {
                background-color: #66cc66;
            }
        </style>
     </head>
     <body>
    <?php 
    /* Define the password */ 
      
    $password "Password"

      if (!isset(
    $_POST['txtPassword']) || $_POST['txtPassword'] != $password) { 

      
    ?> 

    <h1>Login</h1> 

    <form name="form" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> 
    <!--
        <p><label for="txtUsername">Username:</label> 
        <br /><input type="text" title="Enter your Username" name="txtUsername" /></p> 
    -->
        <p><label for="txtPassword">Password:</label> 
        <br /><input type="password" title="Enter your password" name="txtPassword" /></p> 

        <p><input type="submit" name="Submit" value="Login" /></p> 

    </form> 

    <?php 

      
    } else { 

    ?> 

      <h1>Village noticeboard manager.</h1>

      
      <?php
        $path 
    'images';
        
    $fileList array_diff(scandir($path), array('..''.''.ftpquota'));
        
    rsort($fileList);
        
    $fileCount count($fileList);
        if(
    $fileCount 0) {
          echo 
    "<p>There are $fileCount notices on the noticeboard</p>";
          foreach (
    $fileList as $fileName) {
            echo 
    '<p>'.$fileName.'&nbsp;&nbsp;&nbsp;Uploaded on '.date("F d Y H:i"filemtime($path.'/'.$fileName)).'</p>';
          }
        }
        else {
          echo 
    '<p>The noticeboard is empty.</p>';
        }
      
    ?>

      <form action="uploader.php" method="post" enctype="multipart/form-data">
        Select image to upload:
        <input type="file" name="fileToUpload" id="fileToUpload">&nbsp;&nbsp;&nbsp;<input type="submit" value="Upload Image" name="submit">
      </form> 

    <?php 

    }

    ?>

      </body>
    </html>

    uploader.php
    PHP Code:
    <!doctype html>
    <html lang="en">
     <head>
      <meta charset="UTF-8">
      <meta name="Generator" content="EditPlus">
      <meta name="Author" content="">
      <meta name="Keywords" content="">
      <meta name="Description" content="">
      <title>Noticeboard - file upload</title>
        <style type="text/css">
          body {
                background-color: #66cc66;
            }
        </style>
     </head>
     <body>
      <h1>File upload.</h1>

    <?php
    $targetDir 
    "images/";
    $targetFile "nb".time();
    $fileType pathinfo(basename($_FILES["fileToUpload"]["name"]),PATHINFO_EXTENSION);
    $uploadOk 0;

    // Check if image file is a actual image or fake image
    if(isset($_POST["submit"])) {
        
    $check getimagesize($_FILES["fileToUpload"]["tmp_name"]);
        if(
    $check !== false) {
            echo 
    "<p>File is an image - " $check["mime"] . ".</p>";
            
    $uploadOk 1;
        } else {
            echo 
    "<p>File is not an image.</p>";
            
    $uploadOk 0;
        }

        
    // Allow certain file formats
        
    if($fileType != "jpg" && $fileType != "png" && $fileType != "jpeg"
        
    && $fileType != "gif" ) {
            echo 
    "<p>Sorry, only JPG, JPEG, PNG & GIF files are allowed.</p>";
            
    $uploadOk 0;
        }

        
    // Check file size
        
    if ($_FILES["fileToUpload"]["size"] > 100000) {
            echo 
    "<p>Sorry, your file is too large.<br />The maximum size allowed is 100kB.</p>";
            
    $uploadOk 0;
        }

        if(
    $check[0] > 800) {
            echo 
    "<p>Sorry, your image is too wide.<br />The maximum image width is 800 pixels.</p>";
            
    $uploadOk 0;
        }

        if(
    $check[1] > 600) {
            echo 
    "<p>Sorry, your image is too high.<br />The maximum image height is 600 pixels.</p>";
            
    $uploadOk 0;
        }
    }

    // Check if $uploadOk is set to 0 by an error
    if ($uploadOk == 0) {
        echo 
    '<p style="color:red;"><b>There was an error and your file was NOT uploaded.</b></p>';

    // if everything is ok, try to upload file
    } else {
        if (
    move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $targetDir.$targetFile.".".$fileType)) {
            echo 
    "<p>The file "basename$_FILES["fileToUpload"]["name"]). " has been uploaded.<br />";
            echo 
    "The file has been renamed as - ".$targetFile.".".$fileType.".</p>";
        } else {
            echo 
    '<p style="color:red;">Sorry, there was an error and your file could not be uploaded.</p>';
        }
    }
    ?>
    <form action="nbmanager.php">
        <input type="submit" value="Go Back to Noticeboard Manager Page">
    </form>

     </body>
    </html>

  6. #5
    Join Date
    Nov 2014
    Posts
    15
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Default

    It looks like I might have to use a PHP session, but I'm not to sure of how it works. Back to Google I guess.

Bookmarks

Posting Permissions

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