Why not go the data in the database after the form is submitted?

send in a database some data from the form. They kind of do it all. Checked via var_dump kind of rules.
<?php require_once 'mysql.php' ?>
<?php

$uploadname=basename($_FILES['photo']['name']);//write the file name
$uploadpath='img/'.$uploadname; //specify where to load the file
if (isset($_POST['name']) && isset($_POST['dolg']) && isset($_POST['data_okon']) && isset($_POST['diplom']) && 
isset($_POST['sertifikat']) && isset($_POST['data_sertif']) && move_uploaded_file($_FILES['photo']['tmp_name'], $uploadpath)){

 // Variables from the form
 $name= $_POST['name'];
 $dolg = $_POST['dolg'];
 $data_okon = strtotime($_POST['data_okon']);
 $study = $_POST['study'];
 $diplom = $_POST['diplom'];
 $sertifikat = $_POST['sertifikat'];
 $data_sertif = strtotime($_POST['data_sertif']);
 $db_table = "personal";

 $result = $mysqli->query("INSERT INTO ".$db_table." (photo,name,dolg,data_okon,study,diplom,sertifikat,data_sertif) 
VALUES ('$uploadpath', '$name','$dolg','$data_okon','$study','$diplom','$sertifikat','$data_sertif')");


}
var_dump($_POST);
?>

5cf68210be486630248084.png
March 23rd 20 at 19:04
3 answers
March 23rd 20 at 19:06
Solution
Thank you. There were two errors on the associated downloadable file. And what is unclear
Notice: Undefined index: file in D:\OSPanel\domains\polina.loc\admin\libs\addpers.php on line 8

Notice: Undefined index: file in D:\OSPanel\domains\polina.loc\admin\libs\addpers.php on line 10
$uploadname=basename($_FILES['photo']['name'])
$uploadpath='img/'.$uploadname; 
if (isset($_POST['pname']) && isset($_POST['dolg']) && isset($_POST['data_okon']) && isset($_POST['diplom']) && isset($_POST['sertifikat']) && isset($_POST['data_sertif']) && move_uploaded_file($_FILES['photo']['tmp_name'], $uploadpath))
this is the problem when I removed the loading base is added - billy81 commented on March 23rd 20 at 19:09
See the file addpers.php, line 8-th and 10-th.
There is the use of a non-existent array element with the index 'file'.
Something like $a['file'] .= "xyz";, or something else...

And var_dump() inside if() output does trigger the code inside the if() occurs? - Austin commented on March 23rd 20 at 19:12
everything seems to work. the problem was that you need to create a save folder where this script lies - billy81 commented on March 23rd 20 at 19:15
Make var_dump(move_uploaded_file(....), is_writable("img/"));, and probably you'll see bool(false) bool(false).
Then check the access rights to the directory img/ of the user that runs PHP. - Austin commented on March 23rd 20 at 19:18
@Austin, I don't want to deal with this nonsense about all PHP errors will tell you himself. - Gisselle.Jones35 commented on March 23rd 20 at 19:21
@Gisselle.Jones35, yeah, yeah, especially when error_reporting(0);. - Austin commented on March 23rd 20 at 19:24
@Austin, that's just for error_reporting(0); and have the author on hand to beat, not to engage in meaningless villupuram results - Gisselle.Jones35 commented on March 23rd 20 at 19:27
Thank you all. I know - billy81 commented on March 23rd 20 at 19:30
March 23rd 20 at 19:08
Before connecting to database I need to write a line

mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);

after that, PHP will always indicate why a request could not be performed
nothing displays - billy81 commented on March 23rd 20 at 19:11
need to enable error reporting
Oh and by the way. warden should be placed INSIDE conditions.
What is the meaning of withdraw outside? - Gisselle.Jones35 commented on March 23rd 20 at 19:14
March 23rd 20 at 19:10
Code in General is rotten for 5 years) PHP: The Right Way
10 not less - roberto commented on March 23rd 20 at 19:13

Find more questions by tags MySQLPHP