Einfacher Login Screen

Dieses Thema im Forum "Hosting & Server" wurde erstellt von zeldaaa, 9. Januar 2010 .

Status des Themas:
Es sind keine weiteren Antworten möglich.
  1. 9. Januar 2010
    Tag zusammen,

    Ich soll für Family Geburtstagsbilder hochladen... habe schon ein Flashalbum mit den Bildern angelegt alles schon fertig ich will aber nicht das jeder der auf den Link geht die Bilder sehn kann daher wollte ich einen kleinen Login Screen anlegen indem ich mich dann mit Name und Passwort einloggen könnte, ist das Passwort richtig leitet es mich weiter zu dem Fotoalbum..

    Wie erstelle ich jetzt so einen einfachen Login Screen, der mich dann zu meiner definierten Seite album.html weiterleitet. Das ganze ist auf nem FTP von funpic.de
    Habs mit PHPmyAdmin probiert da ich haber 0 PHP Kenntnisse habe und myAdmin net verstehe ist das gescheitert.

    Das ganze muss nichts großartiges sein ist eh nur temporär...

    //EDIT:

    Habe gerade einen Code gefunden der schon halb funktioniert (vllt kann jmd mal drübergucken):

    Code:
    <?
    // This first if statement checks to see if we have a username/pass submited by the form, if it does then it attempts to validate it.
    if($username && $password) {
    mysql_connect() or die ("Whoops"); // Connect to the database, or if connection fails print error message.
    $password = md5($password); // encode submited password with MD5 encryption and store it back in the same variable. If not on a windows box, I
    suggest you use crypt()
    $sql = "select * from login where username='$username'"; // query statment that gets the username/password from 'login' where the username is the same as
    the one you
    submited
    $r = mysql_db_query("register",$sql); // Execute Query
    
    // if no rows for that database come up, redirect.
    if(!mysql_num_rows($r))
    header("Location: $SCRIPT_NAME"); // This is the redirection, notice it uses $SCRIPT_NAME which is a predefined variable with the name of the script in it.
    
    $user = mysql_fetch_array($r); // if we got passed the last if statment means we have a registered username, get the rest of the info and put it in an array
    named $user
    if($user["password"] == $password) { // If the password stored in the database is the same as the password the user entered (which is now encryped with MD5)
    $password = serialize($password); // if we get this far we know we have a registered username, and the password matches.
    // serialize() the already incrypted password just for fun and mabey some extra security for when we
    store it in a cookie
    setcookie("candle_login","$username $password"); // Set the cookie named 'candle_login' with the value of the username (in plain text) and the password (which has been encrypted and serialized.)
    
    // set variable $msg with an HTML statement that basically says redirect to the next page. The reason we didn't use header() is that using setcookie() and header() at the same time isn't 100% compatible with all browsers, this is more compatible.
    }
    }
    if($msg) echo $msg;
    ?>
    <html>
    <title>Login.</title>
    <body bgcolor="black" text="white">
    <form method="post" action="<?echo $SCRIPT_NAME;?>"> 
    
    <center><font size=+3><b>Herzlich Wilkommen!</b></font></center>
    <br>
    <br>
    <br>
    <table cellspacing=0 cellpadding=0 width=320 align="center">
    <tr><td>
    Username:
    </td><td>
    <input name="username" type="text" width=10>
    </td></tr>
    <tr><td>
    Password:
    </td><td>
    <input name="password" type="password" width=10>
    </td></tr>
    <tr><td colspan=2 align="center">
    <input name="login" type="submit">
    </td></tr>
    </table>
    </form>
    </html>
    
    <?
    // if the cookie doesn't exsist means the user hasn't been verified by the login page so send them back to the login page.
    if(!$candle_login)
    header("Location: ./login.php");
    
    if($phpcoders) { // if the cookie does exsist
    mysql_connect() or die ("Whoops"); //connect to db
    $user = explode(" ","$phpcoders"); //explode cookie value (which is the '$username $password (note seperated by space)) and store values in $user. Check
    manual for more info
    on explode()
    
    $sql = "select * from login where username='$user[0]'"; //sql statment that uses the username from the cookie.
    $r = mysql_db_query("register",$sql); //execute sql
    
    if(!mysql_num_rows($r)) { // if there are no rows, means no matches for that username
    header("Location: ./login.php"); // so go back to the login page
    }
    
    $chkusr = mysql_fetch_array($r); //if we got passed the last part, then get the username/password set that match that username
    if(unserialize($user[1]) != $chkusr[1]) //if the password from cookie (notice we have to unserialize it) doesn't match the one from the database
    header("Location: ./login.php"); // go back to the login page
    } // if it did match then continue on to page and this ends up doing nothing :)
    ?>

    Gruß

    - zeldaaa
     
  2. 10. Januar 2010
    AW: Einfacher Login Screen

    Kann funpic mit htaccess-Dateien umgehen? Wenn ja, ist das die einfachste Möglichkeit die Seite eben abzusichern.

    .htaccess Generator | fueralles.de Homepage-Tools
     
  3. 10. Januar 2010
    AW: Einfacher Login Screen

    Alles klar habs hingekriegt zwar nicht mit htaccess habe aber einen einfachen Login Screen gefunden der völlig ausreicht, trotzdem vielen Dank BW haste.

    Falls interesse an dem Code besteht PM an mich.
     
  4. Video Script

    Videos zum Themenbereich

    * gefundene Videos auf YouTube, anhand der Überschrift.