Monday, October 12, 2009

How do I get a web form to write to a MySQL database using PHP myAdmin?

I am trying to use a webform to post data to my MySQL database. I have all of this set up on my website that is hosted on yahoo. I have php MyAdmin installed on the server to manage the database. For some reason, I can%26#039;t get my webform to post the info to my database. Can anyone help?



How do I get a web form to write to a MySQL database using PHP myAdmin?





%26lt;?php



// assuming you are posting a field called %26#039;first_name%26#039;



$first_name =$_POST[%26#039;first_name%26#039;];



//use proper values for mysql_user and mysql_password



//use proper value for localhost, if you are not using local host.



$link = mysql_connect(%26#039;localhost%26#039;, %26#039;mysql_user%26#039;, %26#039;mysql_password%26#039;);



if (!$link) {



die(%26#039;Could not connect: %26#039; . mysql_error());



}



//assuming you are entering this field in a table called %26#039;myfriends%26#039;



$query = %26quot;INSERT INTO myfriends(first_name) VALUES(%26#039;$first_name%26#039;)%26quot;;



mysql_query($query);



mysql_close($link);



?%26gt;



How do I get a web form to write to a MySQL database using PHP myAdmin?



try this



http://php.resourceindex.com/Documentati...

No comments:

Post a Comment