Update MySQL database through PHP form?

selfrob

New member
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','password','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','$state','$country','$postal_code','$return_reason','$solution')";

//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***
 
Back
Top