Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
PHP/Html form to MySQL database
Old 07-15-2008, 01:34 AM PHP/Html form to MySQL database
Lashtal's Avatar
wherenomanhasgonebefore

Posts: 680
Name: Lashtal
Trades: 0
I am trying to create a table called "form_data" for the PHP side of this form...

PHP Code:
<?php
$con 
mysql_connect("LOCALHOST","USERNAME","PASSWORD"); //Replace with your actual MySQL DB Username and Password
if (!$con

die(
'Could not connect: ' mysql_error()); 

mysql_select_db("DATABASE"$con); //Replace with your MySQL DB Name
$name=mysql_real_escape_string($_POST['name']); //This value has to be the same as in the HTML form file
$email=mysql_real_escape_string($_POST['email']); //This value has to be the same as in the HTML form file
$sql="INSERT INTO form_data (name,email) VALUES ('$name','$email')"/*form_data is the name of the MySQL table where the form data will be saved.
name and email are the respective table fields*/
if (!mysql_query($sql,$con)) {
 die(
'Error: ' mysql_error()); 

echo 
"The form data was successfully added to your database."
mysql_close($con);
?>
As a total newbie, I do not know what information is required to create the table in MySQL to be called "form_data" (with consideration to the code you see above) that is supposed to store both "name" and "email" fields, and would appreciate some assistance as to what's required in order to construct the aforesaid table.

As a beginner, I have been dropping data into MySQL versus creating the tables by hand, so I would see your answer clearer if you communicated in

CREATE TABLE form_data
) blah blah blah

terms


If my question is not entirely clear, please ask me to define it for you.

Thanks.
__________________
Currently Reading:
Please login or register to view this content. Registration is FREE
Lashtal is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 07-15-2008, 01:57 AM Re: PHP/Html form to MySQL database
Lashtal's Avatar
wherenomanhasgonebefore

Posts: 680
Name: Lashtal
Trades: 0
Alright, I just figured it out...

Code:
CREATE TABLE `form_data` ( 
`name` VARCHAR( 50 ) NOT NULL , 
`email` VARCHAR( 50 ) NOT NULL 
);
__________________
Currently Reading:
Please login or register to view this content. Registration is FREE
Lashtal is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to PHP/Html form to MySQL database
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

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





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.39035 seconds with 12 queries