Html Quelltext in PHP
lima-city → Forum → Programmiersprachen → PHP, MySQL & .htaccess
code
dank
einfachste variante code
erfolgreichem login
form
leute
login
not
problem
same
see
session
set
show
-
Hallo Leute ich hab mal wieder nen problem:
ich habe diesen quelltext<?php session_start(); //allows session include "config.php"; echo "<center>"; if($logged[id]) { //welcomes the member echo "Hallo $logged[username]<br><br>"; //shows the user menu -----------------------hier soll normaler html quelltext rein----------------------------------------------------------------- }else //if there trying to login if(isset($_GET['login'])) { //removes sql injections from the data $username= htmlspecialchars(addslashes($_POST[username])); //encrypts the password $password = sha1(md5(md5(sha1(md5(sha1(sha1(md5($_POST[password])))))))); //gets the username data from the members database $uinfo = mysql_query("SELECT * FROM `members` WHERE `username` = '$username'") or die(mysql_error()); //see if the user exists $checkuser = mysql_num_rows($uinfo); //if user name not found in database error if($checkuser == '0') { echo "Username not found"; }else{ //fetch the sql $udata = mysql_fetch_array($uinfo); //checks see if the account is verified if($udata[userlevel] == 1) { echo "This account had not been verified."; } //if it is continue else //if the db password and the logged in password are the same login if($udata[password] == $password) { $query = mysql_query("SELECT * FROM `members` WHERE `username` = '$username'") or die(mysql_error()); //fetchs the sql $user = mysql_fetch_array($query); //sets the logged session $_SESSION['id'] = "$user[id]"; $_SESSION['password'] = "$user[password]"; echo "You are now logged in, Please wait. . ."; //redirects them echo "<meta http-equiv='Refresh' content='2; URL=login.php'/>"; } //wrong password else{ echo "Incorrect username or password!"; } } }else{ //If not the above show the login form echo "<form action='login.php?login' method='post'> <table width='312'> <tr> <td width='120'></td> <td width='180'><input type='text' name='username' size='30' maxlength='25'></td> </tr> <tr> <td></td> <td><input type='password' name='password' size='30' maxlength='25'></td> </tr> <tr> <td colspan='2'><center><input type='submit' value='Login'></center></td> </tr> </table> </form>"; } echo "<center>"; ?>
also ich möchte das bei erfolgreichem login eine ganz normale html seite angezeigt wird. wie geht das??? -
Diskutiere mit und stelle Fragen: Jetzt kostenlos anmelden!
lima-city: Gratis werbefreier Webspace für deine eigene Homepage
-
Das ist die einfachste Variante:
<?php session_start(); //allows session include "config.php"; echo "<center>"; if($logged[id]) { //welcomes the member echo "Hallo $logged[username]<br><br>"; //shows the user menu ?> --- HTML-QUELLTEXT --- <?php }else //if there trying to login if(isset($_GET['login'])) { //removes sql injections from the data $username= htmlspecialchars(addslashes($_POST[username])); //encrypts the password $password = sha1(md5(md5(sha1(md5(sha1(sha1(md5($_POST[password])))))))); //gets the username data from the members database $uinfo = mysql_query("SELECT * FROM `members` WHERE `username` = '$username'") or die(mysql_error()); //see if the user exists $checkuser = mysql_num_rows($uinfo); //if user name not found in database error if($checkuser == '0') { echo "Username not found"; }else{ //fetch the sql $udata = mysql_fetch_array($uinfo); //checks see if the account is verified if($udata[userlevel] == 1) { echo "This account had not been verified."; } //if it is continue else //if the db password and the logged in password are the same login if($udata[password] == $password) { $query = mysql_query("SELECT * FROM `members` WHERE `username` = '$username'") or die(mysql_error()); //fetchs the sql $user = mysql_fetch_array($query); //sets the logged session $_SESSION['id'] = "$user[id]"; $_SESSION['password'] = "$user[password]"; echo "You are now logged in, Please wait. . ."; //redirects them echo "<meta http-equiv='Refresh' content='2; URL=login.php'/>"; } //wrong password else{ echo "Incorrect username or password!"; } } }else{ //If not the above show the login form echo "<form action='login.php?login' method='post'> <table width='312'> <tr> <td width='120'></td> <td width='180'><input type='text' name='username' size='30' maxlength='25'></td> </tr> <tr> <td></td> <td><input type='password' name='password' size='30' maxlength='25'></td> </tr> <tr> <td colspan='2'><center><input type='submit' value='Login'></center></td> </tr> </table> </form>"; } echo "<center>"; ?>
-
Diskutiere mit und stelle Fragen: Jetzt kostenlos anmelden!
lima-city: Gratis werbefreier Webspace für deine eigene Homepage