<?php echo "<h1>Регистрация</h1>"; $submit = strip_tags($_POST['submit']); $name = strip_tags($_POST['name']); $password = strip_tags($_POST['password']); $repeatpassword = strip_tags($_POST['repeatpassword']); $email = strip_tags($_POST['email']); $date = date("Ymd"); $ip = $_SERVER['REMOTE_ADDR']; $ip = $_POST['ip']; if ($submit) { // check for existans if($name&&$password&&$repeatpassword&&$email) { if ($password==$repeatpassword) { //check name if(strlen($name)>15||strlen($name)<4) { echo "Логин должен быть от 4 до 15 символов!"; } else { //check password if (strlen($password)>25||strlen($password)<6) { echo "Пароль должен быть от 6 до 25 символов"; } else { if (isset($_POST['name'])) { $name = $_POST['name']; } if (isset($_POST['password'])) { $password = $_POST['password']; } if (isset($_POST['email'])) { $email = $_POST['email']; } if (isset($_POST['date'])) { $date = $_POST['date']; } if (isset($_POST['ip'])) { $ip = $_POST['ip']; } //encrypt password $password =md5($password); $repeatpassword =md5($repeatpassword); //open database $db = mysql_connect("localhost","root","vladon12"); mysql_select_db("testgame"); $result = mysql_query ("INSERT INTO `users` (name,password,email,date,ip) values('$name','$password','$email','$date','$ip')"); die ("Добро пожаловать в игру =) Нажми <a href='index.php'>здесь</a> для продолжения <html> <head> <style> body{ background-color: #A6CAF0 ; color: #330033 ; font-size: 18px; text-align: center; padding-top: 2%; } </style> </head> </html>"); } } } else echo "Пароли не совпадают!"; } else echo "Введите <b>все</b> поля"; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xml:lang="ru" dir="ltr"> <p> <head> <style> body{ background-color: #A6CAF0 ; color: #330033 ; font-size: 18px; text-align: center; padding-top: 2%; } </style> <title><?php echo $config['title'];?></title> <meta http-equiv = "content-type" content = "text/html; charset = <?php echo $config['coder'] ; ?>" /> </head> <body "alink = '#0000ff' link = '#0000ff' vlink = '#0000ff' "> <p style ="text-align: center;"> <form action="index.php?page=register" method="post" name="form"> <p>*Логин: <br><input name="name" type="text" size="20" maxlenght="40"></p> <p>*Пароль:<br><input name="password" type="password" size="20" maxlenght="40"></p> <p>*Пароль:<br><input name="repeatpassword" type="password" size="20" maxlenght="40"></p> <p>e-Mail:<br><input name="email" type="text" size="20" maxlenght="40"></p> <p><br><input name="submit" type="submit" value="Зарегистрироваться"></p><br> <br><a href="index.php"><<назад</a> </body> </html> 

Does not bring the user to the database, what to do? Tell me please.

  • @Prikol, Array the code. Your code is currently unreadable. - Nicolas Chabanovsky

2 answers 2

 $result = mysql_query ("INSERT INTO `users` (name,password,email,date,ip) values('$name','$password','$email','$date','$ip')"); 

Change to

 $result = mysql_query ("INSERT INTO `users` (name,password,email,date,ip) values('$name','$password','$email','$date','$ip')") or die(mysql_error()); 

What will bring?

  • Unknown column 'password' in 'field list' - k0mar
  • Oh sorry =) I made a pass in the database and write password in pkhp =) - k0mar
  • Well, you see) Always use this to debug queries, anything can happen) - iproger

Do this:

 $sql = "INSERT INTO `users` (name,password,email,date,ip) values('$name','$password','$email','$date','$ip')"; echo $sql; $result = mysql_query ($sql); if (!$result) echo mysql_error(); 

As a result, you will see which request is sent to the database. Surely something is wrong with him. And also, if the request failed, then the output will also be an error. Those. You will know exactly where the error in the request.