M
M
MrMim2020-05-05 15:39:22
PHP
MrMim, 2020-05-05 15:39:22

Doodles are entered into the database, what should I do?

There is a form that sends data to the database (mysql), but is saved as a scribble, what should I do?

if (isset($data['btn-reg-in'])) {
          $name = $data['name'];
          $familyname = $data['familyname'];
          $day = $data['day'];
          $month = $data['mes'];
          $year = $data['year'];
          $gender = $data['gender'];
          $login = $data['hide'];
          mysqli_query($link, "UPDATE `users` SET `name`='$name',`familyname`='$familyname',`day`='$day',`month`='$month',`year`='$year',`gender`='$gender' WHERE `login` = '$login'");
          $_SESSION['login']=$login;
          header("Location: /im");}?>


and here is bd:
<?php

if(isset ($_SESSION['login'])){
    header("Location : /im");
    exit();
}

$host = 'localhost';  // Хост, у нас все локально
  $user = 'admin';    // Имя созданного вами пользователя
  $pass = 'тут пароль который есть'; // Установленный вами пароль пользователю
  $db_name = 'msg';   // Имя базы данных
  $link = mysqli_connect($host, $user, $pass, $db_name); // Соединяемся с базой
  // Ругаемся, если соединение установить не удалось
  if (!$link) {
    echo 'Не могу соединиться с БД. Код ошибки: ' . mysqli_connect_errno() . ', ошибка: ' . mysqli_connect_error();
    exit;
  }
  session_start();
?>

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry Entelis, 2020-05-05
@MrMim

https://www.php.net/manual/ru/mysqli.set-charset.php

I
idShura, 2020-05-05
@idShura

What encoding is on the page?
What is the database encoding?
And add to your code:
$link->set_charset("utf8")

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question