TechSpott - Computer and technology forums

Go Back   TechSpott - Computer and technology forums > Webmasters > Database Management > MySQL
MySQL Forum dedicated to the world's most popular open source database engine.

Reply
 
Thread Tools Display Modes
Old April 8th, 2010, 01:07 PM   #1 (permalink)
selfrob
Guest
 
Posts: n/a
Default Update MySQL database through PHP form?

I have a PHP form that inserts the data into a MySQL database, but what I would like to do with it is to be able to update the database information through the form itself as needed. I would just like to be able to update the form fields as needed through the form.

Here is what I have for the PHP code. Thanks for your assistance.

***Start Code***

<?php

//Define variables
$controller_serial=$_POST['controller'];
$sample_holder_serial=$_POST['sampleholder'];
$first_name=$_POST['firstname'];
$last_name=$_POST['lastname'];
$company_name=$_POST['companyname'];
$phone=$_POST['phone'];
$email=$_POST['email'];
$return_address=$_POST['address'];
$city=$_POST['city'];
$state=$_POST['state'];
$country=$_POST['country'];
$postal_code=$_POST['postalcode'];
$return_reason=$_POST['return'];
$solution=$_POST['solution'];

//Connect to MySQL or display error
$dbc=mysqli_connect('localhost','username','passwo rd','database')
or die('Error connecting to MySQL server.');

//Insert form data into MySQL database.
$query="INSERT INTO rma(controller_serial, sample_holder_serial, first_name, last_name, company_name, phone, email, return_address, city, state, country, postal_code, return_reason, solution)" .
"VALUES('$controller_serial', '$sample_holder_serial', '$first_name','$last_name', '$company_name', '$phone','$email','$return_address','$city','$stat e','$country','$postal_code','$return_reason','$so lution')";
原帖地å€: TechSpott - Computer and technology forums http://www.techspott.com//showthread.php?p=5470

//Query database or display error.
$result=mysqli_query($dbc,$query)
or die('Error querying database');

//Display MySQL database unique row id.
$row_id=mysqli_insert_id($dbc);

//Close MySQL database connection.
mysqli_close($dbc);

//Display form confirmation page.
echo'Thanks for submitting the form.<br />';
echo'RMA NUMBER: ' . date("ymd");
echo '-' . $row_id . '<br />';
echo'Temperature Controller Serial Number: ' . $controller_serial . '<br />';
echo'Sample Holder Serial Number: ' . $sample_holder_serial . '<br />';
echo'First Name: ' . $first_name . '<br />';
echo'Last Name: ' . $last_name . '<br />';
echo'Company Name: ' . $company_name . '<br />';
echo'Phone Number: ' . $phone . '<br />';
echo'Email: ' . $email . '<br />';
echo'Return Address: ' . $return_address . '<br />';
echo'City: ' . $city . '<br />';
echo'State: ' . $state . '<br />';
echo'Country: ' . $country . '<br />';
echo'Postal Code: ' . $postal_code . '<br />';
echo'Reason For Return: ' . $return_reason . '<br />';
echo'Solution: ' . $solution . '<br />';

?>

***End PHP Code***
  Reply With Quote Share with Facebook
Reply

Bookmarks

Tags
database, form, mysql, php, update


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Is there a Windows version of MySQL or other database program? Cully W MySQL 0 April 7th, 2010 08:33 PM
PHP - how to post text to textarea on the same form after "sbumit"? stella1229 PHP 0 April 7th, 2010 12:25 PM
How do I create a login form and a sign up form using php my admin or mysql? Hollywood MySQL 0 April 4th, 2010 11:05 PM
i don't have access to mysql database, any other alternatives? siekkwang_cin MySQL 1 April 4th, 2010 03:10 AM
Multiple PHP Scripts in 1 MySQL Database? Robert M PHP 0 April 4th, 2010 02:56 AM

 
Forum Stats
Members: 14,361
Threads: 20,372
Posts: 27,828
Total Online: 40

Newest Member: Webchatugk

Latest Threads

Advertisements

Support our advertisers!

Amazon
Sears
Macys
1800flowers.com
Drugstore.com


Carbonite Online-Backups
Tiger Direct
Tech Depot
Buy.com
Office Depot
Fatcow
HostGator


TripsNow.us
Marriott
Expedia
CheapTickets.com
OneTravel
Hotwire

Are you a Fan?

Share this on Facebook

Tag Cloud

Partner Links


Contact Us - Home - Archive - Privacy Statement - Top - Copyright © 2009-2010, TechSpott - All times are GMT -4. Time is 05:06 PM

Powered by vBulletin® Copyright © Jelsoft Enterprises Ltd. :: SEO by vBSEO