Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more

Go Back   Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more > Web Programming > PHP Development
User Name
Password

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 03-30-2006, 02:06 PM   #1 (permalink)
drew22299
Junior Member
 
Join Date: Mar 2006
Location: Wilts / Bristol
Posts: 55
Default How do I create a textbox that stores values in a database?

Hey,

I have created a mysql database using phpmyadmin on the hosts server, and have entered the fields and defined the primary key.

These fields are for members details, or for people that have subscribed to the mailing list. I have some questions,

1) Is this the same as creating a php file that tells the database what fields to make and store them?
2) How do I make a text box that takes an email address and stores it in the database? Can anyone suggest some code?

Drew,
__________________
www.hotlista.co.uk
drew22299 is offline   Reply With Quote
Sponsored Links
Old 04-02-2006, 10:19 AM   #2 (permalink)
welstein
Junior Member
 
Join Date: Apr 2006
Posts: 2
Default Re: How do I create a textbox that stores values in a database?

your HTML :
<FORM action="test.php" method="post">
<INPUT type="text" value="this is a text" name"txtInput" id="txtInput" />
</FORM>

then in your test.php
<?php
// if the method="get" then you have to change to $_GET
extract($_POST);
print($txtInput); // print your text value

$db = mysql_connect("localhost", "root", "123");
mysql_select_db("mydb", $db) or die(mysql_errno() . ": " . mysql_error() . "<br>");


$sql = " INSERT INTO test VALUES('$txtInput') ";
$result = mysql_query($sql, $db);
if(!$result){
echo mysql_error();
exit;
}
// close the connection
mysql_free_result($result);
mysql_close();
?>

Last edited by welstein : 04-02-2006 at 10:23 AM.
welstein is offline   Reply With Quote
Old 04-04-2006, 08:54 PM   #3 (permalink)
drew22299
Junior Member
 
Join Date: Mar 2006
Location: Wilts / Bristol
Posts: 55
Default Re: How do I create a textbox that stores values in a database?

Thanx,

For this to work do you need to have setup a database with the required fields? For example, if you are taking someones email address you need to have a field in your database called emailaddress?

Is there a way of using PHP so that it creates the fields when it is executed?

Drew,
__________________
www.hotlista.co.uk
drew22299 is offline   Reply With Quote
Old 04-11-2006, 06:39 AM   #4 (permalink)
Formula
Junior Member
 
Join Date: Apr 2006
Posts: 1
Default Re: How do I create a textbox that stores values in a database?

The best thing for you is to create a table with these fields:
user_id
user_name
user_email

and insert the emails to this table.

Assaf
Formula is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Points Per Thread View: 1.00
Points Per Thread: 11.00
Points Per Reply: 5.00



» Sponsors

» Links

» Affiliates
Web Hosting
Online Backup Reviews
Marketing Find
Merchant Select
SiteMap Builder
Host Compare
Dedicated Servers

» Links

» Sports Network
Paintball Forum
Football Forum
Hockey Forum
Golf Forum
Boxing Forum
Lacrosse Forum
Baseball Forum
SnowBoarding Forum
Soccer Forum
MMA Forum


All times are GMT -4. The time now is 08:55 AM.



LinkBacks Enabled by vBSEO 3.0.0 RC8
Webmaster Forums