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>
|