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
251 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
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 …

813 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

12 Experts available now in Live!

Get 1:1 Help Now