Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialDennis Castillo
16,018 PointsBasic Data Entry PHP and MySQL
Greetings,
I'm trying my first data entry form working with PHP and MySQL. On the webpage it doesn't give me an error but when I check my database on phpmyadmin, the data didn't go through... my database table is empty...
SAMPLE.php
<form action="data_entry.php" method="POST">
First Name: <input type="text" name="firstName"><br>
Last Name: <input type="text" name="lastName"><br>
Profession: <input type="text" name="profession"><br>
Employer: <input type="text" name="employer"><br>
<br>
<input type="submit" name="insert" value="submit">
</form>
data_entry.php
<?php
mysql_connect('localhost','root','');
mysql_select_db('julieblog');
?>
<?php
if(isset($_POST['insert'])) {
$firstname = $_POST['firstName'];
$lastName = $_POST['lastName'];
$pro = $_POST['profession'];
$emp = $_POST['employer'];
$insert_data = mysql_query('INSERT INTO personal_data_entry VALUES("$firstname","$lastname","$pro","$emp")');
echo "Data are successfully save...";
?>
It didn't give me any kind of error, but the database table name "personal_data_entry" is empty... Can you give me any guidance... thanks
1 Answer
jason chan
31,009 Pointsdid you create the table?
Dennis Castillo
16,018 PointsDennis Castillo
16,018 Pointsno... so that is mandatory?