Forum Moderators: coopster
Warning: Cannot modify header information - headers already sent by (output started at /home/powerman/public_html/aaa/update.php:2) in /home/powerman/public_html/aaa/update.php on line 22
The two files being used are:
=============================
update.php
=============================
<?
// START PHP CODES. THIS PART MUST ON THE TOP OF THIS PAGE.
// Connect database.
include("config.php");
// ***** This part will process when you Click on "Submit" button *****
// Check, if you clicked "Submit" button
if($_POST['Submit']){
// Get parameters from form.
$id=$_POST['id'];
$Account=$_POST['Account'];
$Client=$_POST['Client'];
$Telephone=$_POST['Telephone'];
// Do update statement.
mysql_query("update client set Account='$Account', Client='$Client', Telephone='$Telephone' where id='$id'");
// Re-direct this page to select.php.
header("location:select.php");
exit;
}
// ************* End update part *************
// *** Select data to show on text fields in form. ***
// Get id parameter (GET method) from select.php
$id=$_GET['id'];
// Get records in all columns from table where column id equal in $id and put it in $result.
$result=mysql_query("select * from clients where id='$id'");
// Split records in $result by table rows and put them in $row.
$row=mysql_fetch_assoc($result);
// Close database connection.
mysql_close();
?>
<!-- END OF PHP CODES AND START HTML TAGS -->
<html>
<body style="font-family: tahoma; font-size: 8pt">
<!-- set this form to POST method and target this form to itself ($PHP_SELF;)-->
<form id="form1" name="form1" method="post" action="<? echo $PHP_SELF; ?>">
<p>Name :
<!-- name of this text field is "name" -->
<input name="Client" type="text" id="name" value="<? echo $row['Client']; ?>"/>
<br />
Email :
<!-- name of this text field is "email" -->
<input name="Account" type="text" id="email" value="<? echo $row['Account']; ?>"/>
<br />
Tel :
<!-- name of this text field is "tel" -->
<input name="Telephone" type="text" id="tel" value="<? echo $row['Telephone']; ?>"/>
</p>
<p>
<input type="submit" name="Submit" value="Submit" />
</p>
</form>
</body>
</html>
============================================
and
config.php
============================================
<?
// Connection codes with database selection.
$dbhost="localhost";
$dbuname="username";
$dbpass="password";
mysql_connect($dbhost,$dbuname,$dbpass);
mysql_select_db("databse_name"); // select database
// You can put or die(); after mysql_connect() and mysql_select_db()
?>
Any help greatly appreciated
[edited by: eelixduppy at 6:59 pm (utc) on Feb. 9, 2009]
[edit reason] disabled smileys [/edit]