Solved insert form is not inserting data in database

Hewlett-packard / Cq61 notebook
May 9, 2013 at 02:47:15
Specs: Windows 7, AMD sempron 2 gb
Hi I am doing the Developer Works tutorial. When I get to the part of inserting data into the database, after creating the form datain.html and datain.php what happens is that no data is entered though I get a successful message. At first I was getting an error undefined variables
for all the fields so I corrected that as you can see from the code below.Now everything seems fine as I said I get a message that the data insertion has been successful but if a do a select
statement nothing has been entered.Can somebody help me? Thank you

this is the code:

<form method="post" action="datain.php">
First name:<input type="Text" name="first">

Last name:<input type="Text" name="last">

Nick Name:<input type="Text" name="nickname">

E-mail:<input type="Text" name="email">

Salary:<input type="Text" name="salary">

<input type="Submit" name="submit" value="Enter info">



$firstname= "";
$lastname= "";
$nickname= "";
$email= "";
$salary= "";

$db = mysql_connect("localhost", "root","LaTorre1937##");
$sql = "INSERT INTO personnel (firstname, lastname, nickname, email, salary)
VALUES ('$firstname','$lastname','$nickname','$email','$salary')";
$result = mysql_query($sql);
echo "Thank you! Information entered.\n";

See More: insert form is not inserting data in database

Report •

May 9, 2013 at 05:48:56
Hi, this is the second message I get but it just shows my post, no answer to my question, something's wrong?

Report •

May 9, 2013 at 09:54:35
✔ Best Answer
You assigned an empty string to each of the vars. You need to assign them the values passed in from the form.

$firstname= $_POST["first"];
$lastname= $_POST["last"];

Report •

Related Solutions

Ask Question