Login forma, objasnjenje

Login forma, objasnjenje

offline
  • Pridružio: 25 Jun 2008
  • Poruke: 72

Evo ovo su kodovi koji sluze za log in i register! Sta ovde nevalja? Ne funkcionise. Ko moze neka ih ispravi i neka mi objasni kako to da stavim u dreamweaver

Login forma
<?php require_once('../../Connections/mysql.php'); ?> <?php // *** Validate request to login to this site. session_start(); $loginFormAction = $_SERVER['PHP_SELF']; if (isset($accesscheck)) { $GLOBALS['PrevUrl'] = $accesscheck; session_register('PrevUrl'); } if (isset($_POST['userName'])) { $loginUsername=$_POST['userName']; $password=$_POST['userPassword']; $MM_fldUserAuthorization = "userPassword"; $MM_redirectLoginSuccess = "restricted.php"; $MM_redirectLoginFailed = "sorry.php"; $MM_redirecttoReferrer = false; mysql_select_db($database_mysql, $mysql); $LoginRS__query=sprintf("SELECT userName, userPassword, userPassword FROM login WHERE userName='%s' AND userPassword='%s'", get_magic_quotes_gpc() ? $loginUsername : addslashes($loginUsername), get_magic_quotes_gpc() ? $password : addslashes($password)); $LoginRS = mysql_query($LoginRS__query, $mysql) or die(mysql_error()); $loginFoundUser = mysql_num_rows($LoginRS); if ($loginFoundUser) { $loginStrGroup = mysql_result($LoginRS,0,'userPassword'); //declare two session variables and assign them $GLOBALS['MM_Username'] = $loginUsername; $GLOBALS['MM_UserGroup'] = $loginStrGroup; //register the session variables session_register("MM_Username"); session_register("MM_UserGroup"); if (isset($_SESSION['PrevUrl']) && false) { $MM_redirectLoginSuccess = $_SESSION['PrevUrl']; } header("Location: " . $MM_redirectLoginSuccess ); } else { header("Location: ". $MM_redirectLoginFailed ); } } ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>Login Page</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> <form ACTION="<?php echo $loginFormAction; ?>" name="form1" method="POST"> <table width="222" border="1" cellspacing="0" bordercolor="#000000"> <tr> <td width="68">user name </td> <td width="144"><input name="userName" type="text" id="userName"></td> </tr> <tr> <td>password</td> <td><input name="userPassword" type="password" id="userPassword"></td> </tr> <tr> <td><a href="registration.php">sign up</a> </td> <td><input type="submit" name="Submit" value="login"></td> </tr> </table> </form> </body> </html> Sign Up new user forma <?php require_once('../../Connections/mysql.php'); ?> <?php // *** Redirect if username exists $MM_flag="MM_insert"; if (isset($_POST[$MM_flag])) { $MM_dupKeyRedirect="taken.php"; $loginUsername = $_POST['userName']; $LoginRS__query = "SELECT userName FROM login WHERE userName='" . $loginUsername . "'"; mysql_select_db($database_mysql, $mysql); $LoginRS=mysql_query($LoginRS__query, $mysql) or die(mysql_error()); $loginFoundUser = mysql_num_rows($LoginRS); //if there is a row in the database, the username was found - can not add the requested username if($loginFoundUser){ $MM_qsChar = "?"; //append the username to the redirect page if (substr_count($MM_dupKeyRedirect,"?") >=1) $MM_qsChar = "&"; $MM_dupKeyRedirect = $MM_dupKeyRedirect . $MM_qsChar ."requsername=".$loginUsername; header ("Location: $MM_dupKeyRedirect"); exit; } } function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue; switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } $editFormAction = $_SERVER['PHP_SELF']; if (isset($_SERVER['QUERY_STRING'])) { $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']); } if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) { $insertSQL = sprintf("INSERT INTO login (userName, userPassword, userMail) VALUES (%s, %s, %s)", GetSQLValueString($_POST['userName'], "text"), GetSQLValueString($_POST['userPassword'], "text"), GetSQLValueString($_POST['userMail'], "text")); mysql_select_db($database_mysql, $mysql); $Result1 = mysql_query($insertSQL, $mysql) or die(mysql_error()); $insertGoTo = "login.php"; if (isset($_SERVER['QUERY_STRING'])) { $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?"; $insertGoTo .= $_SERVER['QUERY_STRING']; } header(sprintf("Location: %s", $insertGoTo)); } ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>Sign Up New User</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> <form name="form1" method="POST" action="<?php echo $editFormAction; ?>"> <p> <input name="userMail" type="text" id="userMail"> e-mail </p> <p> <input name="userName" type="text" id="userName"> user name </p> <p> <input name="userPassword" type="password" id="userPassword"> password </p> <p> <input type="submit" name="Submit" value="Register"> </p> <input type="hidden" name="MM_insert" value="form1"> </form> </body> </html>



Registruj se da bi učestvovao u diskusiji. Registrovanim korisnicima se NE prikazuju reklame unutar poruka.
offline
  • PHP developer
  • Pridružio: 22 Mar 2006
  • Poruke: 3747
  • Gde živiš: 127.0.0.1

Barni, ne ide to tako. Ni HTML ne znas, a vec bi da radis u PHP-u. Zamisli da ne znas da vozis ni obican auto, a hoces da vozis formulu 1, i to trke. Nece moci ove noci.

Bolje lepo zagrej stolicu i procitaj sta je sta u HTML-u, pa onda kreni da se igras sa tim, pa tek kad to savladas, predji na PHP. Dobar start za php mozes da nadjes ovde: http://www.php.net/manual/en/index.php

A ovo ti ne funkcionise iz vise razloga, u stvari, mogu da se kladim da dobijas sledecu gresku (pod pretpostavkom da imas php na serveru):

Citat:Warning: main(../../Connections/mysql.php): failed to open stream: No such file or directory in (...) on line 1

Fatal error: main(): Failed opening required '../../Connections/mysql.php' (include_path=...') in (...) on line 1



offline
  • Pridružio: 25 Jun 2008
  • Poruke: 72

Hvala za link!!

offline
  • Pridružio: 01 Jul 2005
  • Poruke: 181

Ma za ovo ti ne treba neko posebno znanje PHP, treba da editujes skriptu,a cesto je u .txt fajlu koji ide uz skriptu uputstvo sta treba da podesis i editujes da bi ti skripta radila. Ne muci se na php.net, nece ti puno pomoci.

Ko je trenutno na forumu
 

Ukupno su 957 korisnika na forumu :: 56 registrovanih, 10 sakrivenih i 891 gosta   ::   [ Administrator ] [ Supermoderator ] [ Moderator ] :: Detaljnije

Najviše korisnika na forumu ikad bilo je 3466 - dana 01 Jun 2021 17:07

Korisnici koji su trenutno na forumu:
Korisnici trenutno na forumu: _Petar, A.R.Chafee.Jr., Andrija357, anta, babaroga, Bluper, Boris90, Brana01, Bubimir, ccoogg123, dekan.m, Dimitrise93, djboj, Djokislav, doktor123, Dorcolac, DPera, esx66, Fog of War, goxin, havoc995, hawkeye, HrcAk47, ikan, ILGromovnik, ivan1973, kobaja77, Koridor, kubura91, KUZMAR, Levi, Luka Blažević, mercedesamg, Mercury, Metanoja, milenko crazy north, MILICAT, MiroslavD, mrav pesadinac, nemkea71, pera bager, Petarvu, randja26, royst33, ruma, Srki94, Srle993, t84dar, Tas011, theNedjeljko, tmanda323, vathra, voja64, Webb, |_MeD_|, žeks62