[ Поиск ] - [ Пользователи ] - [ Календарь ]
Полная Версия: помогите разобраться с формами
Floyd
Доброго времени суток.Постараюсь более детально объяснить суть проблемы.

Есть страничка "Личный кабинет" в нем форма авторизации и кнопка регистрации.При нажатии на кнопку "Регистрация" запускается скрипт с формой регистрации.Все скрипты работают в одном диве этой странички по принципу условие->остановка текущего скрипта->запуск нового скрипта.

Проблема заключается в том,что если я нажимаю кнопку подтверждения регистрации меня перебрасывает на скрипт авторизации,тоесть на начало.

Скрипт авторизации:

<?php
$rezultat="";
if(isset($_POST['registration']))
{
include "scripts/registration.php";
exit();
}

if(isset($_POST['button']))
{
include "scripts/connection.php";

$query = sprintf("SELECT * FROM `accounts` WHERE `login`=%s AND `pass`=%s",
quote_smart($_POST['name']),
quote_smart($_POST['pass']));

$result=mysql_query($query);

if(mysql_num_rows($result) > 0)
{
include "scripts/information.php";
exit();
} else
{
$rezultat="Извините! Такой пользователь не зарегистрирован, либо логин или пароль введены неверно!";
}

}

?>
<html>
<table
border="0" align="center" width="600">


<tr>
<td
height="50px" colspan="3">
<p><font
color="navy" size="3">Для входа в личный кабинет необходима авторизация</font></p>
</td>
</tr>
<tr>
<td
width="200">
<img
src="Images/key.png" />
</td>

<td
height="200">
<form
id=form"3" name=form"3" method="post" action="">

<p><font
color="navy" size="3">Введите логин</font>
<br>
<input
name="name" type="text" maxlength="16" size="25"/>
</br>
</p>

<p><font
color="navy" size="3">Введите пароль</font>
<br>
<input
name="pass" type="password" maxlength="16" size="25"/>
</br>
</p>

<p>
<input
type="submit" name="button" id="button" value="Подтвердить" />
</p>
</form>
</td>

<td
width="200">
<img
src="Images/Locker.png" />
</td>

</tr>

<tr>
<td
colspan="3" height="30">
<form
id=form"4" name=form"4" method="post" action="">
<input
type="submit" name="registration" id="registration" value="Зарегистрироваться" />
</form>
</td>
</tr>

<tr>
<td
height="80px" colspan="3">
<p><font
color="red" size="3"><?php echo"$rezultat"; ?></font></p>
</td>
</tr>
</table>
</html>



Скрипт регистрации:

<?php
$result_registration="";

if(isset($_POST['submitregistration']))
{
if(!isset($_POST['license']))
{
$result_registration="Регистрация невозможна! Вы отклонили лицензию!";
}else
{

}
}

?>
<html>
<form
id=form"registr" name=form"registr" method="post" action="">

<font
color="navy" size="3">Введите логин</font>
<br>
<input
name="login" type="text" maxlength="16" size="25"/>
</br>

<p><font
color="navy" size="3">Введите пароль</font>
<br>
<input
name="pass" type="password" maxlength="16" size="25"/>
</br>
</p>

<p><font
color="navy" size="3">Повторите пароль</font>
<br>
<input
name="confirmpass" type="password" maxlength="16" size="25"/>
</br>
</p>

<p><font
color="navy" size="3">Адрес почтового ящика</font>
<br>
<input
name="email" type="text" maxlength="25" size="25"/>
</br>
</p>

<p><font
color="navy" size="3">Псевдоним(ник) в игре</font>
<br>
<input
name="nick" type="text" maxlength="16" size="25"/>
</br>
</p>

<p>
<input
name="license" type="checkbox" name="license"><font color="navy" size="3">С условиями <a href="index.php">лицензии</a> согласен(на)</font>
</p>

<html>
<p>
<input
type="submit" name="submitregistration" id="submitregistration" value="Подтвердить" />
</p>
</form>

<p><font
color="red" size="3"><?php echo"$result_registration"; ?></font></p>
</html>





Спустя 8 минут, 51 секунда (18.05.2011 - 22:53) Krevedko написал(а):
сурово как-то. скриншот можешь сделать ?
что бросилось в глаза. непонял смысл этого:
}else
{
}

а также то, что теги <html> постоянно закрываются-открываются

Спустя 12 минут, 35 секунд (18.05.2011 - 23:06) Floyd написал(а):
Цитата (Krevedko @ 18.05.2011 - 19:53)
сурово как-то. скриншот можешь сделать ?
что бросилось в глаза. непонял смысл этого:
}else
{
}

а также то, что теги <html> постоянно закрываются-открываются

Цитата
  }else     
{           
}

Это можно игнорировать привычка обрабатывать исключения,пишу на автомате)

теги <html> постоянно закрываются-открываются

Можно поподробнее.

user posted image

user posted image

Спустя 11 минут, 57 секунд (18.05.2011 - 23:18) Krevedko написал(а):
я стркутуру не пойму. это все в одном файле чтоли ?

Спустя 4 минуты, 31 секунда (18.05.2011 - 23:22) Floyd написал(а):
Цитата (Krevedko @ 18.05.2011 - 20:18)
я стркутуру не пойму. это все в одном файле чтоли ?

Прошу прощения,забыл выложить главный файл cabinet.php.В нем есть див и в этом диве при разных условиях выводятся результаты работы скриптов autorization,registration и information.php

Вот код кабинета:

<!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=utf-8" />
<title>
Личный кабинет</title>
<style
type="text/css">
#Main {
position:relative;
width:900px;
height:1000px;
z-index:1;
margin: 0 auto;
top: 0px;
}
body {
background-image: url(Images/BackGround.png);
background-repeat: no-repeat;
background-position: center center;
}
#apDiv1 {
position:absolute;
width:170px;
height:40px;
z-index:1;
left: 3px;
top: 4px;
}
#apDiv2 {
position:absolute;
width:170px;
height:40px;
z-index:2;
left: 178px;
top: 4px;
}
#apDiv3 {
position:absolute;
width:170px;
height:40px;
z-index:3;
left: 354px;
top: 4px;
}
#apDiv4 {
position:absolute;
width:170px;
height:40px;
z-index:4;
left: 530px;
top: 4px;
}
#apDiv5 {
position:absolute;
width:170px;
height:40px;
z-index:5;
left: 706px;
top: 4px;
}
#apDiv6 {
position:absolute;
width:884px;
height:54px;
z-index:6;
left: 11px;
top: 222px;
}
#apDiv7 {
position:absolute;
width:416px;
height:185px;
z-index:7;
left: 3px;
top: 33px;
text-align: center;
color: #036;
}
#apDiv8 {
position:absolute;
width:433px;
height:224px;
z-index:8;
left: 20px;
top: 388px;
}
#apDiv9 {
position:absolute;
width:312px;
height:26px;
z-index:8;
left: 83px;
top: 5px;
font-size: 20px;
color: #FC0;
}
#apDiv10 {
position:absolute;
width:429px;
height:222px;
z-index:9;
left: 455px;
top: 388px;
}
#apDiv11 {
position:absolute;
width:287px;
height:24px;
z-index:1;
font-size: 20px;
color: #FC0;
left: 116px;
top: 4px;
}
#apDiv12 {
position:absolute;
width:416px;
height:181px;
z-index:2;
left: 5px;
top: 32px;
color: #036;
text-align: center;
}
#apDiv13 {
position:absolute;
width:434px;
height:263px;
z-index:10;
left: 20px;
top: 635px;
text-align: justify;
}
#Main #apDiv13 div p {
text-align: center;
}
#apDiv14 {
position:absolute;
width:203px;
height:26px;
z-index:1;
left: 133px;
color: #FC0;
font-size: 20px;
}
#apDiv15 {
position:absolute;
width:416px;
height:229px;
z-index:2;
top: 28px;
left: 3px;
text-align: center;
color: #036;
}
#apDiv16 {
position:absolute;
width:430px;
height:262px;
z-index:11;
left: 456px;
top: 635px;
}
#apDiv17 {
position:absolute;
width:246px;
height:26px;
z-index:1;
left: 130px;
font-size: 20px;
color: #FC0;
}
#apDiv18 {
position:absolute;
width:417px;
height:231px;
z-index:2;
top: 27px;
left: 5px;
}
#Main #apDiv16 #apDiv18 {
text-align: center;
color: #036;
}
#apDiv19 {
position:absolute;
width:229px;
height:22px;
z-index:12;
left: 378px;
top: 963px;
}
#apDiv20 {
position:absolute;
width:822px;
height:307px;
z-index:13;
left: 40px;
top: 462px;
}
#apDiv21 {
position:absolute;
width:197px;
height:163px;
z-index:1;
left: -10px;
top: 60px;
font-size: 24px;
text-align: center;
color: #035;
}
#apDiv22 {
position:absolute;
width:200px;
height:115px;
z-index:2;
left: 325px;
top: 66px;
}
#apDiv23 {
position:absolute;
width:120px;
height:150px;
z-index:2;
left: 302px;
top: 56px;
}
#Main #apDiv20 #apDiv23 {
}

#Main #apDiv20 #apDiv23 {
}

#apDiv20 #apDiv23 {
}

#apDiv23 {
}

#apDiv24 {
position:absolute;
width:316px;
height:255px;
z-index:2;
left: 230px;
top: 60px;
text-align: center;
font-size: 24px;
color: #035;
}
#apDiv25 {
position:absolute;
width:200px;
height:115px;
z-index:2;
}
#apDiv26 {
position:absolute;
width:336px;
height:193px;
z-index:2;
left: 239px;
top: 55px;
font-size: 24px;
text-align: center;
color: #035;
}
#apDiv27 {
position:absolute;
width:200px;
height:115px;
z-index:3;
left: 595px;
top: 68px;
font-size: 24px;
text-align: center;
color: #035;
}
#apDiv28 {
position:absolute;
width:850px;
height:550px;
z-index:13;
left: 25px;
top: 390px;
text-align: center;
}
#apDiv29 {
position:absolute;
width:200px;
height:200px;
z-index:14;
left: 562px;
top: 414px;
}
#apDiv30 {
position:absolute;
width:620px;
height:40px;
z-index:15;
left: 146px;
top: 382px;
color: #300;
font-size: 18px;
text-align: center;
font-weight: bold;
}
#Main #apDiv28 #form1 p {
color: #303;
font-weight: bold;
}
#apDiv31 {
position:absolute;
width:379px;
height:51px;
z-index:16;
left: 261px;
top: 428px;
text-align: center;
color: #C03;
font-weight: bold;
}
</style>
<script
type="text/javascript">
function
MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}


function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

</script>
</head>

<body
bgcolor="#000000" onload="MM_preloadImages('Images/Buttons/WhyPlayingON.png','Images/Buttons/DownloadON.png','Images/But tons/CabinetON.png','Images/Buttons/ForumON.png','Images/Buttons/ContactON.png')">
<div
id="Main">
<div
id="apDiv6">
<div
id="apDiv1"><a href="howtoplay.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('WhyPlaying','','Images/Buttons/WhyPlayingON.png',1)"><img src="Images/Buttons/WhyPlayingOFF.png" name="WhyPlaying" width="170" height="40" border="0" id="WhyPlaying" /></a></div>
<div
id="apDiv2"><a href="#" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Download','','Images/Buttons/DownloadON.png',1)"><img src="Images/Buttons/DownloadOFF.png" name="Download" width="170" height="40" border="0" id="Download" /></a></div>
<div
id="apDiv3"><a href="cabinet.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image4','','Images/Buttons/CabinetON.png',1)"><img src="Images/Buttons/CabinetOFF.png" name="Image4" width="170" height="40" border="0" id="Image4" /></a></div>
<div
id="apDiv4"><a href="forum/index.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Forum','','Images/Buttons/ForumON.png',1)"><img src="Images/Buttons/ForumOFF.png" name="Forum" width="170" height="40" border="0" id="Forum" /></a></div>
<div
id="apDiv5"><a href="contact.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Contact','','Images/Buttons/ContactON.png',1)"><img src="Images/Buttons/ContactOFF.png" name="Contact" width="170" height="40" border="0" id="Contact" /></a></div>
</div>
<img
src="Images/FrontImage.png" width="900" height="1000" border="0" usemap="#Map" />
<map
name="Map" id="Map">
<area
shape="rect" coords="20,27,873,96" href="index.php" />
</map>
<div
id="apDiv19">© 2011</div>
<div
id="apDiv28"><?php error_reporting(E_ALL); include "scripts/authorization.php";?>
</div>
</div>
</div>
</body>
</html>


Спустя 17 минут, 35 секунд (18.05.2011 - 23:40) Krevedko написал(а):
ну правильно перебрасывает. у тебя же стоит грузить ее по дефолту
<div id="apDiv28"><?php error_reporting(E_ALL); include "scripts/authorization.php";?>
и условие
if(isset($_POST['registration']))
{
include "scripts/registration.php";
exit();
}
не выполняется

напиши там чтоли if($_POST['registration'] || $_POST['submitregistration'])

Спустя 9 минут, 30 секунд (18.05.2011 - 23:50) Floyd написал(а):
Цитата (Krevedko @ 18.05.2011 - 20:40)
ну правильно перебрасывает. у тебя же стоит грузить ее по дефолту
<div id="apDiv28"><?php error_reporting(E_ALL); include "scripts/authorization.php";?>
и условие
if(isset($_POST['registration']))
{
include "scripts/registration.php";
exit();
}
не выполняется

напиши там чтоли if($_POST['registration'] || $_POST['submitregistration'])

Спасибо большое,работает нориально,но пишет нотисы Notice: Undefined index: registration при загрузке личного кабинета и в регистрации когда по кнопке кликаю Notice: Undefined index: registration

Спустя 6 минут, 39 секунд (18.05.2011 - 23:56) Krevedko написал(а):
напиши тогда isset )

Спустя 1 минута, 27 секунд (18.05.2011 - 23:58) Floyd написал(а):
Как-то это все у меня корявенько получается,мутная структура вышла.Может в главном файле поставить оператор выбора,к примеру

switch($comand) {
case registration: include "registration.php"; [break;]
case autorization: include "autorization.php"; [break;]

и в самих скриптах при каких-либо действиях менять значение переменной $comand.Как-то так....

Спустя 10 минут, 14 секунд (19.05.2011 - 00:08) Krevedko написал(а):
так никто и не говорил, что некорявенько ))
ты спросил, почему не работает-я ответил.
да, свич-кейсы было бы хорошо. и разбей пхп и хтмл код по разным файлам. а потом подключай

т.е. сделай главный файл- index.php и в нем уже структуру подключений
case registration:
include "registration.php";
include "registration.html";
break;

case autorization:
.....

Спустя 28 минут, 25 секунд (19.05.2011 - 00:36) Игорь_Vasinsky написал(а):
mvc....mvc wink.gif сразу уж на ирбис линк дал чтоли...
Быстрый ответ:

 Графические смайлики |  Показывать подпись
Здесь расположена полная версия этой страницы.
Invision Power Board © 2001-2025 Invision Power Services, Inc.