Answer the question
In order to leave comments, you need to log in
No data is sent to the table. What is wrong in the code?
The data entered from the form is not added to the table:
<?php
session_start();
include("../include/db_connect.php");
include("../functions/functions.php");
$error = array();
$login = iconv("UTF-8", "cp1251",strtolower(clear_string($_POST['reg_login'])));
$pass = iconv("UTF-8", "cp1251",strtolower(clear_string($_POST['reg_pass'])));
$surname = iconv("UTF-8", "cp1251",clear_string($_POST['reg_surname']));
$name = iconv("UTF-8", "cp1251",clear_string($_POST['reg_name']));
$patronymic = iconv("UTF-8", "cp1251", clear_string($_POST['reg_patronymic']));
$email = iconv("UTF-8", "cp1251",clear_string($_POST['reg_email']));
$phone = iconv("UTF-8", "cp1251",clear_string($_POST['reg_phone']));
$address = iconv("UTF-8", "cp1251",clear_string($_POST['reg_address']));
if (strlen($login) < 5 or strlen($login) > 15)
{
$error[] = "Login must be between 5 and 15 characters!";
}
else
{
$result = mysql_query("SELECT login FROM reg_user WHERE login = '$login'",$link);
If (mysql_num_rows($result) > 0)
{
$error[] = "Login busy!";
}
}
if (strlen($pass) < 6 or strlen($pass) > 15) $error[] = "Please enter a password between 7 and 15 characters!
if (strlen($surname) < 3 or strlen($surname) > 20) $error[] = "Please enter a Last Name between 3 and 20 characters!";
if (strlen($name) < 3 or strlen($name) > 15) $error[] = "Please enter a Name between 3 and 15 characters!";
if (strlen($patronymic) < 3 or strlen($patronymic) > 25) $error[] = "Enter Middle Name between 3 and 25 characters!";
if (!preg_match("/^(?:[a-z0-9]+(?:[-_.]?[a-z0-9]+)[email protected][a-z0-9_.-]+( ?:\.?[a-z0-9]+)?\.[az]{2,5})$/i",trim($email))) $error[] = "Please enter a valid email!";
if (!$phone) $error[] = "Please enter a phone number!";
if (!$address) $error[] = "You must provide a shipping address!";
if($_SESSION['img_captcha'] != strtolower($_POST['reg_captcha' ])) $error[] = "Invalid code from image!";
unset($_SESSION['img_captcha']);
if (count($error))
{
echo implode('
',$error);
}else
{
$pass = md5($pass);
$pass = strrev($pass);
$pass = "9nm2rv8q".$pass."2yo6z";
$ip = $_SERVER['REMOTE_ADDR'];
$result = mysql_query(" INSERT INTO reg_user ('login', 'pass', 'surname', 'name', 'patronymic', 'email', 'phone' , 'address', 'datetime', 'ip')
VALUES(
'".$login."',
'".$pass."',
'".$surname."',
'".$name."',
'
'".$address."',
NOW(),
'".$ip."'
)",$link);
echo 'true';
}
?>
Answer the question
In order to leave comments, you need to log in
db_connect.php:
<?php
$db_host = 'localhost';
$db_user = 'admin';
$db_pass = 'adminadmin';
$db_database = 'db_shop';
$link = mysql_connect($db_host,$db_user,$db_pass);
mysql_select_db ($db_database,$link) or die("No connection to db".mysql_error());
mysql_query("SET names cp1251");
?>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question