You cannot send to the database is entered into the website data. How to fix?

Please do not throw sticks, I'm a sucker for level F.
There is a piece of HTML code with forms to enter data and submit these data in the database
<form action="php/rec.php" method="post" class="input_field">
 <input type="text" class="form-control" name="client_name" placeholder="Enter Your name">
 <input type="text" class="form-control" name="client_surename" placeholder="Enter Your name">
 <input type="text" class="form-control" name="client_tel" placeholder="Enter Your phone">
 <input type="text" class="form-control" name="client_email" placeholder="Enter Your mail">

 <div class="submit_button">
 <form action="php/rec.php" method="post">
 <input type="submit" value="Register" class="button_or">

And actually the script(code) php "rec.php" the code picked up from a site assistant, it seems sorted out and changed all the values to fit your.
 require 'connect.php'; // Connects a file with the username/password and database name
 mysql_set_charset('utf8'); // Sets the encoding of the client
 $client_name = trim($_REQUEST['Name']); // Gets the contents of the field "Author" and eliminates possible gaps in the beginning of the line
 $client_surename = trim($_REQUEST['Surename']); // same for the Title field
 $client_tel = trim($_REQUEST['tel']); // same for the field "Text" + (see below) 
 $client_email = trim($_REQUEST['email']);
 $insert_sql = "INSERT INTO clients (Name, Surename, tel, email)" . // Specifies in which table and in which fields ...
 "VALUES('{$client_name}', '{$client_surename}', '{$client_tel}', '{$client_email}');"; // ...write data
 mysql_query($insert_sql); // send data to database

And actually why not working? Host, timeweb, the DB is created the same on PHPMyAdmin
April 7th 20 at 11:02
3 answers
April 7th 20 at 11:04
code took it off some website assistant

These "helpers" need to dust poison.

To connect with the database should be as written here
Paste as written here.
April 7th 20 at 11:06
1. If a field called client_name
<input type="text" name="client_name">
the server and catch it under the same name:
$name = trim($_REQUEST['client_name']);

2. You have 2 forms < form> - in one field , and the second - only button < submit>.
Pressing the button sent the second form, but no field data. So on the server, nothing is sent. Move the button to "Enroll" in the first form and the second form generally clean.

In General, ibrahim58 rights. You read some wrong websites.
Thank you! As I said, I'm a freshman, and therefore thought that the shape can be divided - reed_Wunsch77 commented on April 7th 20 at 11:09
@chauncey78, be sure to read about sql injection.

Need to escape special characters:
$_client_name = mysql_real_escape_string($client_name);
and then use the variable in the query:
$insert_sql = "INSERT INTO clients (Name) VALUES('{$_client_name}')";

$insert_sql = "INSERT INTO clients Name='{$_client_name}'";

otherwise hack your website using sql injection. - helga_Lebsac commented on April 7th 20 at 11:12
@Osborne.Aufderhar, Yes, I was warned about this, but for now you just have to achieve the communication between the database and the website - reed_Wunsch77 commented on April 7th 20 at 11:15
@chauncey78, I hope the table clients you have previously created?

For your case it is necessary to make a request:
$query = "CREATE TABLE IF NOT EXISTS clients ("
 .", Name VARCHAR(16)"
 .", Surename VARCHAR(32)"
 .", tel VARCHAR(15) UNIQUE" // phone Number - unique
 .", email VARCHAR(32) UNIQUE" // Email - unique
 ." )"
 ." COLLATE='utf8_general_ci'"

which will create table in DB if it does not exist;

And then - include debug information - is inserted into rec.php:
echo '<pre>'.print_r($_REQUEST, true).'</pre>'; will print in browser all submitted fields from the form;

echo mysql_error(); will show the query error, if any. - helga_Lebsac commented on April 7th 20 at 11:18
@Osborne.Aufderhar, of course I previously created, I'm simple but not to such a level. Because I had questions because everything was made to connect the database and website - reed_Wunsch77 commented on April 7th 20 at 11:21
@Osborne.Aufderhar, without a lot of the old features of it. - reed_Wunsch77 commented on April 7th 20 at 11:24
April 7th 20 at 11:08
To all the above I would add that the function that you're using mysql_query is outdated a long time ago, and actually removed from php 7, use mysqli_query or PDO. PDO is more preferable

Find more questions by tags PHPHTML