Преработване на логин/регистер система

kokito

Registered
Използвам http://web-tourist.net/login/login/view.php?st=802 , но
забелязах един пропуск , да речем , че съм логнат и отида в register.php аз пак мога да се регистрирам, нужно е да се преправи така ,че като съм логнат и отида в register.php да показва "Вие сте вече логнат" или нещо от сорта.


И второто да се преработи една моя страница , че когато потребителя не е логнат да му изкарва грешка "Първото се логнете" или нещо такова



PHP:
<?ob_start();?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">


<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf8" />
	<link rel="shortcut icon" href="/images/favicon.gif" />
	<title>SMS Аммо</title>
	<link href="/sms/css/style.css" rel="stylesheet" type="text/css" />
	</head>


<body>
<div id="hld">
		<div class="wrapper">
			<div id="top-header">
				<h2>SMS Аммо</h2>
			</div>

<div id="header">
				<div class="inner-container clearfix">
					<div class="hdrl"></div>
					<div class="hdrr"></div>
					
						<?php include("includes/menu.php"); ?>
									
				</div>
</div>



<div id="sidebar-container">



<div class="block">
	<div class="block_head">
		<div class="bheadl"></div>
		<div class="bheadr"></div>
			<h2>ПОТРЕБИТЕЛСКО ПОЛЕ</h2>
	</div>
	<div class="block_content">
		<div align="center" id="nocontent">
			<?php include("loginsystem/login.php"); ?>
		</div>
	</div>

	<div class="bendl"></div>
	<div class="bendr"></div>
</div>





</div>


<div id="content-container">
	<div class="block">
		<div class="block_head">

			<div class="bheadl"></div>
			<div class="bheadr"></div>
			<h2>SMS АММО</h2>
		</div>

			<div class="block_content">
			
<div class="smsbox"><h3><center><br>Изпратете SMS с текст <font color=red>%</font> на номер <font color=red>%</font> (<font color="red">цена % с ДДС</font>) <BR> До 2 минути ще получите SMS с код <br> <font color=red><font size=2.5>Задължително трябва да сте излезнали от сървъра <br><br></font></center></h3></div>
<br><center></font>
<?php include ("includes/smsammo.php") ?>

</h3></div>
<br /> <br>
</div>


			

		<div class="bendl"></div>
		<div class="bendr"></div>
	</div>
	

		<div class="block_head">
			<div class="bheadl"></div>
			<div class="bheadr"></div>

		</div>


		<div class="bendl"></div>
		<div class="bendr"></div>
	</div>
	
		
</div>
			
		</div>
</div>
	<div id="footer">
		<p class="left">
		</p>
		<p class="right">

	</div>
</body>
</html>
 
PHP:
<?php
ob_start();
// allows you to use cookies
include("config.php");
//gets the config page
if (!$logged[username]){
if ($_POST[register]) {
// the above line checks to see if the html form has been submitted
$username = $_POST[username];
$password = $_POST[pass];
$cpassword = $_POST[cpass];
$email = $_POST[emai1];
//the above lines set variables with the user submitted information
if($username==NULL|$password==NULL|$cpassword==NULL|$email==NULL) {
//checks to make sure no fields were left blank
echo "A field was left blank.";
}else{
//none were left blank! We continue...
if($password != $cpassword) {
// the passwords are not the same!
echo "Passwords do not match";
}else{
// the passwords are the same! we continue...
$password = md5($password);
// encrypts the password
$checkname = mysql_query("SELECT username FROM users WHERE username='$username'");
$checkname= mysql_num_rows($checkname);
$checkemail = mysql_query("SELECT email FROM users WHERE email='$email'");
$checkemail = mysql_num_rows($checkemail);
if ($checkemail>0|$checkname>0) {
// oops...someone has already registered with that username or email!
echo "The username or email is already in use";
}else{
// noone is using that email or username! We continue...
$username = htmlspecialchars($username);
$password = htmlspecialchars($password);
$email = htmlspecialchars($email);
// the above lines make it so that there is no html in the user submitted information.
//Everything seems good, lets insert.
$query = mysql_query("INSERT INTO users (username, password, email) VALUES('$username','$password','$email')");
// inserts the information into the database.
echo "You have successfully registered!";
}
}
}
}
else
{
// the form has not been submitted...so now we display it.
echo ("
<center>
<form method=\"POST\">
Потребителско име: <input type=\"text\" size=\"15\" maxlength=\"25\" name=\"username\"><br />
Парола: <input type=\"password\" size=\"15\" maxlength=\"25\" name=\"pass\"><br />
Повторете паролата: <input type=\"password\" size=\"15\" maxlength=\"25\" name=\"cpass\"><br />
Email адрес: <input type=\"text\" size=\"15\" maxlength=\"25\" name=\"emai1\"><br />
<input name=\"register\" type=\"submit\" value=\"Регистрирай се\">
</form>
</center>
");
}
}else{
header('Location:index.php');
exit();
?>
замени твоя register.php с този и си готов :)
 
goshkoy каза:
PHP:
<?php
ob_start();
// allows you to use cookies
include("config.php");
//gets the config page
if (!$logged[username]){
if ($_POST[register]) {
// the above line checks to see if the html form has been submitted
$username = $_POST[username];
$password = $_POST[pass];
$cpassword = $_POST[cpass];
$email = $_POST[emai1];
//the above lines set variables with the user submitted information
if($username==NULL|$password==NULL|$cpassword==NULL|$email==NULL) {
//checks to make sure no fields were left blank
echo "A field was left blank.";
}else{
//none were left blank! We continue...
if($password != $cpassword) {
// the passwords are not the same!
echo "Passwords do not match";
}else{
// the passwords are the same! we continue...
$password = md5($password);
// encrypts the password
$checkname = mysql_query("SELECT username FROM users WHERE username='$username'");
$checkname= mysql_num_rows($checkname);
$checkemail = mysql_query("SELECT email FROM users WHERE email='$email'");
$checkemail = mysql_num_rows($checkemail);
if ($checkemail>0|$checkname>0) {
// oops...someone has already registered with that username or email!
echo "The username or email is already in use";
}else{
// noone is using that email or username! We continue...
$username = htmlspecialchars($username);
$password = htmlspecialchars($password);
$email = htmlspecialchars($email);
// the above lines make it so that there is no html in the user submitted information.
//Everything seems good, lets insert.
$query = mysql_query("INSERT INTO users (username, password, email) VALUES('$username','$password','$email')");
// inserts the information into the database.
echo "You have successfully registered!";
}
}
}
}
else
{
// the form has not been submitted...so now we display it.
echo ("
<center>
<form method="POST">
Потребителско име: <input type="text" size="15" maxlength="25" name="username"><br />
Парола: <input type="password" size="15" maxlength="25" name="pass"><br />
Повторете паролата: <input type="password" size="15" maxlength="25" name="cpass"><br />
Email адрес: <input type="text" size="15" maxlength="25" name="emai1"><br />
<input name="register" type="submit" value="Регистрирай се">
</form>
</center>
");
}
}else{
header('Location:index.php');
exit();
?>
замени твоя register.php с този и си готов :)
Здрасти аз съм приятел на кокито изкарва тази грешка
Parse error: syntax error, unexpected $end in C:\Program www\gsg\loginsystem\register.php on line 65
 
PHP:
<?php
ob_start();
// allows you to use cookies
include("config.php");
//gets the config page
if (!$logged[username]){
if ($_POST[register]) {
// the above line checks to see if the html form has been submitted
$username = $_POST[username];
$password = $_POST[pass];
$cpassword = $_POST[cpass];
$email = $_POST[emai1];
//the above lines set variables with the user submitted information
if($username==NULL|$password==NULL|$cpassword==NULL|$email==NULL) {
//checks to make sure no fields were left blank
echo "A field was left blank.";
}else{
//none were left blank! We continue...
if($password != $cpassword) {
// the passwords are not the same!
echo "Passwords do not match";
}else{
// the passwords are the same! we continue...
$password = md5($password);
// encrypts the password
$checkname = mysql_query("SELECT username FROM users WHERE username='$username'");
$checkname= mysql_num_rows($checkname);
$checkemail = mysql_query("SELECT email FROM users WHERE email='$email'");
$checkemail = mysql_num_rows($checkemail);
if ($checkemail>0|$checkname>0) {
// oops...someone has already registered with that username or email!
echo "The username or email is already in use";
}else{
// noone is using that email or username! We continue...
$username = htmlspecialchars($username);
$password = htmlspecialchars($password);
$email = htmlspecialchars($email);
// the above lines make it so that there is no html in the user submitted information.
//Everything seems good, lets insert.
$query = mysql_query("INSERT INTO users (username, password, email) VALUES('$username','$password','$email')");
// inserts the information into the database.
echo "You have successfully registered!";
}
}
}
}
else
{
// the form has not been submitted...so now we display it.
echo ("
<center>
<form method=\"POST\">
Потребителско име: <input type=\"text\" size=\"15\" maxlength=\"25\" name=\"username\"><br />
Парола: <input type=\"password\" size=\"15\" maxlength=\"25\" name=\"pass\"><br />
Повторете паролата: <input type=\"password\" size=\"15\" maxlength=\"25\" name=\"cpass\"><br />
Email адрес: <input type=\"text\" size=\"15\" maxlength=\"25\" name=\"emai1\"><br />
<input name=\"register\" type=\"submit\" value=\"Регистрирай се\">
</form>
</center>
");
}
}else{
header('Location:index.php');
exit();
}
?>
готово
 
goshkoy каза:
PHP:
<?php
ob_start();
// allows you to use cookies
include("config.php");
//gets the config page
if (!$logged[username]){
if ($_POST[register]) {
// the above line checks to see if the html form has been submitted
$username = $_POST[username];
$password = $_POST[pass];
$cpassword = $_POST[cpass];
$email = $_POST[emai1];
//the above lines set variables with the user submitted information
if($username==NULL|$password==NULL|$cpassword==NULL|$email==NULL) {
//checks to make sure no fields were left blank
echo "A field was left blank.";
}else{
//none were left blank! We continue...
if($password != $cpassword) {
// the passwords are not the same!
echo "Passwords do not match";
}else{
// the passwords are the same! we continue...
$password = md5($password);
// encrypts the password
$checkname = mysql_query("SELECT username FROM users WHERE username='$username'");
$checkname= mysql_num_rows($checkname);
$checkemail = mysql_query("SELECT email FROM users WHERE email='$email'");
$checkemail = mysql_num_rows($checkemail);
if ($checkemail>0|$checkname>0) {
// oops...someone has already registered with that username or email!
echo "The username or email is already in use";
}else{
// noone is using that email or username! We continue...
$username = htmlspecialchars($username);
$password = htmlspecialchars($password);
$email = htmlspecialchars($email);
// the above lines make it so that there is no html in the user submitted information.
//Everything seems good, lets insert.
$query = mysql_query("INSERT INTO users (username, password, email) VALUES('$username','$password','$email')");
// inserts the information into the database.
echo "You have successfully registered!";
}
}
}
}
else
{
// the form has not been submitted...so now we display it.
echo ("
<center>
<form method="POST">
Потребителско име: <input type="text" size="15" maxlength="25" name="username"><br />
Парола: <input type="password" size="15" maxlength="25" name="pass"><br />
Повторете паролата: <input type="password" size="15" maxlength="25" name="cpass"><br />
Email адрес: <input type="text" size="15" maxlength="25" name="emai1"><br />
<input name="register" type="submit" value="Регистрирай се">
</form>
</center>
");
}
}else{
header('Location:index.php');
exit();
}
?>
готово

Благодаря , може ли да ми помогниш по втория въпрос ?
 

Back
Горе