Answer the question
In order to leave comments, you need to log in
Why are records not being added to the database on Denwer?
Hello. I am working on localhost. I'm trying to transfer data to a database.
Here is my form
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
<title>Untitled Document</title>
</head>
<body>
<form action="config.php" method="post" name="forma">
<fieldset>
<label for="first_name">Имя:</label><br/>
<input type="text" name="first_name" size="30"><br/>
<label for="last_name">Фамилия:</label><br/>
<input type="text" name="last_name" size="30"><br/>
<label for="email">Email:</label><br/>
<input type="text" name="email" size="30"><br/>
</fieldset>
<br/>
<fieldset>
<input id="submit" type="submit" value="Отправить данные"><br/>
</fieldset>
</form>
</body>
</html>
<?php
mysql_pconnect("localhost","root","") or die ("Невозможно подключение к MySQL");
mysql_select_db("new_db") or die ("Невозможно открыть таблицу с данными");
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$email = $_POST['email'];
$result = mysql_query ("INSERT INTO users VALUES ('".$first_name."', '".$last_name."', '".$email."')");
if ($result)
echo "Добавлено в базу данных.";
?>
Answer the question
In order to leave comments, you need to log in
After calling mysql_query add a call to mysql_error and see what row it returns.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question