Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

using php with a database

Status
Not open for further replies.

thumbelina

Programmer
Joined
Jun 4, 2001
Messages
58
Location
CA
ok i'm trying to find the basic syntax for inserting info from my webpage into a table in the database. can u believe that i can't find it. it's a mysql database and the input is coming from a textbox only i don't know what to do next. anyway any help would be greatly appereacted, and if anyone knows of any sources that explain php explictly i would be interested in that too cause most of what i have found is very cryptic.
thanks again.
 
Okay,

inserting data from a textbox into a mysql database using php is pretty simple. On one page you have the form. Now, this form refers to another php page (which is the simplest way):
<form name=&quot;form1&quot; method=&quot;post&quot; action=&quot;otherpage.php&quot;>
<input type=&quot;text&quot; name=&quot;textbox&quot;>
<input type=&quot;submit&quot; value=&quot;submit&quot;>
</form>

The textbox is named &quot;textbox&quot;. When you submit the form, it sends the data from &quot;textbox&quot; to &quot;otherpage.php&quot;.

In otherpage.php you insert the data into the database:

<?php
mysql_connect(&quot;localhost&quot;,&quot;username&quot;,&quot;password&quot;);
mysql_select_db(&quot;databasename&quot;);
mysql_query(&quot;INSERT INTO fieldname VALUES '$textbox'&quot;);
?>

That's all there is to it :)

For more info see , ,
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top