bugmenot
7.03.2009 - 20:33
Идея такая: человек вводит пароль, указанный в config.php и ему открывается спрятанная часть страницы. Вводит неправильно - пишет ошибку.
Скрипт пароля я откуда-то стырил. Сейчас когда ввожу пароль и тыкаю войти, страница просто обновляется.
config.php:
Код |
<?php $admpassword="123456"; // пароль админа ?>
|
index.php:
Код |
<html>
<head> <meta http-equiv="Content-Language" content="ru"> <meta http-equiv="Content-Type" content="text/html; charset=windows-1251"> <title>Добавить картинку</title> </head>
<body text="#FFFFFF" bgcolor="#000000"> <?php include("config.php"); if(empty($_SESSION['login'])){ print "<form action='index.php' method='post'>"; print "Пароль: <input type='text' name='ppp' id='ppp'>"; print "<input type='submit' value='Войти'>"; print "</form>"; } else{ if(empty($_SESSION['login']) AND !empty($_POST['ppp'])){ session_register('login'); if($_POST['ppp'] != $admpassword){ print "Пароль не верен! <a href='index.php'>Вернуться</a>"; } else{ $_SESSION['login'] = $_POST['ppp']; print "<a href='index.php'>Парольверенвходим</a>"; } } echo "<form action=upload.php method=post enctype=multipart/form-data> <div align=center> <table border=1 width=427 height=212 bordercolordark=#808080 bordercolorlight=#808080 style=border-collapse: collapse> <tr> <td height=71 width=423 colspan=2> <p align=center><font face=Arial Black size=4><b>Добавить новую картинку</b></font></td> </tr> <tr> <td height=49 width=423 colspan=2> <p align=center><input type=file name=uploadfile size=30></td> </tr> <tr> <td height=24 width=262 align=right><b> <font face=Arial size=2>Введите название</font></b></td> <td height=24 width=158 align=left><input type=text name=pname size=30></td> </tr> <tr> <td height=24 width=262 align=right><b> <font face=Arial size=2>Введите комментарий</font></b></td> <td height=24 width=158 align=left><input type=text name=comment size=30></td> </tr> <tr> <td height=24 width=262 align=right><b> <font face=Arial size=2>Введите технику\размер\год</font></b></td> <td height=24 width=158 align=left><input type=text name=style size=30></td> </tr> <tr> <td height=25 width=262 align=right><b> <font face=Arial size=2>Введите цену</font></b></td> <td height=25 width=158 align=left><input type=text name=cost size=30></td> </tr> </table> </div> <p align=center> <input type=submit value=Загрузить></form> </p> "; } ?></body> </html>
|
Заранее скапибо за помощь
Спустя 1 час, 17 минут, 21 секунда (7.03.2009 - 20:50) kirik написал(а):
Как-то так:
PHP |
<?php session_start(); $msg = null; if(empty($_SESSION['login'])) { $msg = '<form action="index.php" method="post"> Пароль: <input type="text" name="ppp" id="ppp"> <input type="submit" value="Войти"> </form>'; } else { if(isset($_POST['ppp']) && $_POST['ppp'] == $admpassword) { $_SESSION['login'] = true; header('Location: ./index.php'); } elseif(isset($_POST['ppp'])) { $msg = 'Пароль не верен! <a href="index.php">Вернуться</a>'; } } ?> <html> <head> <meta http-equiv="Content-Language" content="ru"> <meta http-equiv="Content-Type" content="text/html; charset=windows-1251"> <title>Добавить картинку</title> </head> <body text="#FFFFFF" bgcolor="#000000"> <?php include('config.php'); echo $msg; if(!empty($_SESSION['login'])) { echo "<form action=upload.php method=post enctype=multipart/form-data> <div align=center> <table border=1 width=427 height=212 bordercolordark=#808080 bordercolorlight=#808080 style=border-collapse: collapse> <tr> <td height=71 width=423 colspan=2> <p align=center><font face=Arial Black size=4><b>Добавить новую картинку</b></font></td> </tr> <tr> <td height=49 width=423 colspan=2> <p align=center><input type=file name=uploadfile size=30></td> </tr> <tr> <td height=24 width=262 align=right><b> <font face=Arial size=2>Введите название</font></b></td> <td height=24 width=158 align=left><input type=text name=pname size=30></td> </tr> <tr> <td height=24 width=262 align=right><b> <font face=Arial size=2>Введите комментарий</font></b></td> <td height=24 width=158 align=left><input type=text name=comment size=30></td> </tr> <tr> <td height=24 width=262 align=right><b> <font face=Arial size=2>Введите технику\размер\год</font></b></td> <td height=24 width=158 align=left><input type=text name=style size=30></td> </tr> <tr> <td height=25 width=262 align=right><b> <font face=Arial size=2>Введите цену</font></b></td> <td height=25 width=158 align=left><input type=text name=cost size=30></td> </tr> </table> </div> <p align=center> <input type=submit value=Загрузить></form> </p> "; } |
Спустя 6 минут, 53 секунды (7.03.2009 - 20:57) bugmenot написал(а):
kirikЗачот, терь даже поля ввода пароля нету
Спустя 23 минуты, 46 секунд (7.03.2009 - 21:21) kirik написал(а):
Точняк, забыл

Еще раз скопируй, поправил.
Спустя 12 минут, 53 секунды (7.03.2009 - 21:34) Viking написал(а):
вроде так должно быть
PHP |
<?php $msg = ""; session_start(); include('config.php');
if(empty($_SESSION['login']) && empty($_POST["ppp"])) { $msg = '<form action="index.php" method="post"> Пароль: <input type="text" name="ppp" id="ppp"> <input type="submit" value="Войти"> </form>'; } else { if(isset($_POST['ppp']) && $_POST['ppp'] == $admpassword) { $_SESSION['login'] = true;
header('Location: ./index.php'); } elseif(isset($_POST['ppp'])) { $msg = 'Пароль не верен! <a href="index.php">Вернуться</a>'; } } ?> <html> <head> <meta http-equiv="Content-Language" content="ru"> <meta http-equiv="Content-Type" content="text/html; charset=windows-1251"> <title>Добавить картинку</title> </head> <body text="#FFFFFF" bgcolor="#000000"> <?php
echo $msg; if(!empty($_SESSION['login'])) { echo "<form action=upload.php method=post enctype=multipart/form-data> <div align=center> <table border=1 width=427 height=212 bordercolordark=#808080 bordercolorlight=#808080 style=border-collapse: collapse> <tr> <td height=71 width=423 colspan=2> <p align=center><font face=Arial Black size=4><b>Добавить новую картинку</b></font></td> </tr> <tr> <td height=49 width=423 colspan=2> <p align=center><input type=file name=uploadfile size=30></td> </tr> <tr> <td height=24 width=262 align=right><b> <font face=Arial size=2>Введите название</font></b></td> <td height=24 width=158 align=left><input type=text name=pname size=30></td> </tr> <tr> <td height=24 width=262 align=right><b> <font face=Arial size=2>Введите комментарий</font></b></td> <td height=24 width=158 align=left><input type=text name=comment size=30></td> </tr> <tr> <td height=24 width=262 align=right><b> <font face=Arial size=2>Введите технику\размер\год</font></b></td> <td height=24 width=158 align=left><input type=text name=style size=30></td> </tr> <tr> <td height=25 width=262 align=right><b> <font face=Arial size=2>Введите цену</font></b></td> <td height=25 width=158 align=left><input type=text name=cost size=30></td> </tr> </table> </div> <p align=center> <input type=submit value=Загрузить></form> </p> "; }
|
Спустя 40 минут, 46 секунд (7.03.2009 - 22:15) kirik написал(а):
Viking, там редирект POST чистит..
Спустя 9 минут, 57 секунд (7.03.2009 - 22:25) Viking написал(а):