PHP Form Submit to MySQL

Hello All,

I am new to developing PHP and have a question about submitting some data in a form. I have created a form and a submit page and everything seems to be working properly but the data record does not show up in MySQL. It shows that a record had been created by there is no data in the record except for the record ID.

Any help would be great.

Thanks,

you will have to post some data for us to look at so that we can help … but just off the top of my head it sounds like your form isn’t transmitting the vars through your sql statement.

Here is my Submit

<?php $con = mysql_connect("localhost", "root", "Mapguide123"); // Check connection if (!$con) { die('Cound not connect:' . mysql_error()); } $db_selected = mysql_select_db("jobjournal" , $con); if (!$db_selected){ die('Can\'t use' . DB_NAME . ': ' . mysql_error()); } echo 'Connected Successfully'; $value1 = $_post['input1']; $sql = "INSERT INTO user1(firstname) VALUES ('$value1')"; if (!mysql_query($sql)) { die('Error: ' . mysql_error()); } echo "1 record added"; mysql_close($con); ?>

I did make one correction $result= mysql_query($sql); and it still does not seem to be working correctly. Thanks again for the help

<?php $con = mysql_connect("localhost", "root", "Mapguide123"); // Check connection if (!$con) { die('Cound not connect:' . mysql_error()); } $db_selected = mysql_select_db("jobjournal" , $con); if (!$db_selected){ die('Can\'t use' . DB_NAME . ': ' . mysql_error()); } echo 'Connected Successfully'; $value1 = $_post['input1']; $sql = "INSERT INTO user1(firstname) VALUES ('$value1')"; $result= mysql_query($sql); if (!mysql_query($sql)) { die('Error: ' . mysql_error()); } echo "1 record added"; mysql_close($con); ?>

OK,

I fixed it.

Thanks

Sponsor our Newsletter | Privacy Policy | Terms of Service