L
L
luque2014-10-25 16:05:14
PHP
luque, 2014-10-25 16:05:14

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

6 answer(s)
A
akarin, 2014-10-25
@luque

www.php.su/mysql_error post

V
Vladislav, 2014-10-25
@DubecZ

Stop using mysql_query....it's time to get familiar with PDO....

A
Alexander Wolf, 2014-10-25
@mannaro

Check out the code

D
Dmitry Cherednichenko, 2014-10-25
@likeapimp

Show the contents of the db_connect.php file

L
luque, 2014-10-25
@luque

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 question

Ask a Question

731 491 924 answers to any question