Ответов: 1 Просмотров: 148
|
Есть форма PHP:
скопировать код в буфер обмена
<? top ('register') ?> <h1>Регистрациястрацыя</h1> <p><input type="email" placeholder="E-mail" id="email"></p> <p><input type="password" placeholder="password" id="password"></p> <p><button onclick="post_query('gform','register','email.password')">Регистрация</button> <? bottom() ?>
Есть файл index.php в котором есть функция проверки email function email_valid();
PHP:
скопировать код в буфер обмена
<? if($_SERVER['REQUEST_URI']=='/') $page = 'home'; else{ $page =substr($_SERVER['REQUEST_URI'],1 ); } $CONECT = mysqli_connect('localhost', 'fedy','1111','fedy'); //подключаем базу даных if (!$CONECT) exit('MySQL error') ; if (file_exists('all/'.$page.'.php')) include 'all/'.$page.'.php'; else if ($_SESSION['ulogin']==1 and file_exists('auth/'.$page.'.php')) include 'auth/'.$page.'.php'; else if ($_SESSION['ulogin']!=1 and file_exists('guest/'.$page.'.php')) include 'guest/'.$page.'.php'; function message($text){ exit( '{"message" : "'.$text.'"}'); } function go($url){ exit('{"go" : "'.$url.'"}'); } function random_str($num = 30){ return substr(str_shuffle('0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNJPQRSTUVWXZYZ'),0 ,$num); } function email_valid(){ if(!filter_var($_POST['email'], FILTER_VALIDATE_EMAIL )) message('E-mail указан не верно'); } function top ($title){ echo'<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>'.$title.'</title> <link rel="stylesheet" href="/style.css" > <script src="/jQuery.js"></script> <script src="/script.js"></script> </head> <body> <div class="wrapper"> <div class="menu"> <a href="/">√лавна¤</a> <a href="/login">¬ход</a> <a href="/register">–егистрацы¤</a> </div> <div class="content"> <div class="block"> '; } function bottom(){ echo' </div> </div> </div> </body> </html>'; } ?>
есть обработчик формы только он на java
CODE ( javascript):
скопировать код в буфер обмена
function post_query(url, name, data){ var str=''; $.each(data.split('.'),function(k,v){ }); $.ajax({ url: '/'+url, type: 'POST', data: name + '_f=1' + str, cache: false, success: function(result){ obj = jQuery.parseJSON(result); if (obj.go) go(obj.go); else alert(obj.message); } } ); } function go(url){ window.location.href='/' + url; }
Собственно файл который работает с формами
PHP:
скопировать код в буфер обмена
<? if ($_POST['login_f']){ message ('Авторизация'); } else if ($_POST['register_f']){ message ($_POST['email']); } else if ($_POST['recovery_f']){ message ('Востановление'); } else if ($_POST['confirm_f']){ message ('Регистрация'); } ?>
Проверяю что приходит из формы, на экране пустота. Помогите пожалуйста найти ошибку. Почему форма ничего не передает? |