Solved

What steps I need to make to insert the content of a form in a mysql data base with php?

Posted on 2008-06-24
3
233 Views
Last Modified: 2010-04-21
I recently have made a form in php that sends via email the content of it (to the asigned email). Now, I want to change this to insert the content in a mysql database with php, and I´m not sure the way that I must to do. I think, first I must create a table in my mysql database? Second,  this code must change? how?
e.g. $body .= "Deaprture: " . $_POST["port"] . "\r\n"
0
Comment
Question by:juanico
3 Comments
 
LVL 36

Accepted Solution

by:
Loganathan Natarajan earned 30 total points
ID: 21854774
yes, you will have to create tables and store it

ref. http://www.w3schools.com/PHP/php_mysql_insert.asp
0
 
LVL 29

Assisted Solution

by:fosiul01
fosiul01 earned 20 total points
ID: 21855320
Hi juanico,
The previous link will show you how to connect database and how to insert data into record

Now what you will have to do is :

if you follow the previous link , bellow line :

mysql_query("INSERT INTO person (FirstName, LastName, Age)
VALUES ('Peter', 'Griffin', '35')");

where the value is inputted statically
but in your case value would inputed dynamically

Like in the mail proramm, you have variables such as ( as you said in your pose)
$body .= "Deaprture: " . $_POST["port"] . "\r\n"

Now here  ,instead of peter use $body
which would be like this

mysql_query("INSERT INTO emailtable (emailaddress,subject, body)
VALUES ($emailaddress,$subject,$body)");

thats it, job done. and  you will have to write this insert statement, in Submit button just after sending the email


0
 

Author Closing Comment

by:juanico
ID: 31470104
I only want to say thank you!!!
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

Foreword In the years since this article was written, numerous hacking attacks have targeted password-protected web sites.  The storage of client passwords has become a subject of much discussion, some of it useful and some of it misguided.  Of cou…
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now