Answer the question
In order to leave comments, you need to log in
How to transfer data from a form to a file?
Tell me what is wrong or what I forgot? I have a local server with no password. The table was created in phpadmin database php1 table tabl1. Always writes an error when adding data / I understand that I'm probably dumb and probably didn't establish a connection to the database. I'm waiting for help.
include ('php1.tabl');
$text = $_POST['text'];
$age = $_POST['age'];
$mail = $_POST['mail'];
$gender = $_POST['gender'];
$smoking = $_POST['smoking'];
$sql = 'INSERT INTO members(text, age, mail, gender,smoking)
VALUES("'.$text.'", "'.$age.'", "'.$mail.'", "'.$gender.'", "'.$smoking.'")';
if(!mysql_query($sql))
{echo '<center><p><b>Ошибка при добавлении данных!</b></p></center>';}
else
{echo '<center><p><b>Данные добавлены!</b></p></center>';}
Answer the question
In order to leave comments, you need to log in
and probably did not establish a connection to the database - did you install it or not? And once you start, then make it a rule not to write queries to the database in this way - with the insertion of user data directly into the query string. Use PDO or something.
"How to transfer data from a form to a file?"
<?
file_put_contents($filepath, $_POST['data']);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question