<?php require_once("PasswordMstr.php"); ?>

<!DOCTYPE html PUBLIC

"-//W3C//DTD XHTML 1.0 Strict//EN"

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<title>Upadte a Person</title>

<link rel="stylesheet" href="php_styles.css" type="text/css" />

</head>

<body>

<h2>Update of a Person / Record</h2>

<?php

$PersonID = $_GET['UpdPersonID'];

$Name = $_GET['UpdName'];

$Email = $_GET['UpdEmail'];

$Phone = $_GET['UpdPhone'];

$Address = $_GET['UpdAddress'];

 

 

if (empty($Name)) 

                exit("<p>You must enter at least Person Name. Click back.</p>");

 

// $DBConnect = @mysqli_connect("localhost", "root")                                                                                 // (Test)  Connect to MySQL                

$DBConnect = mysqli_connect("db1234.abcdefg.net", "db1234567890", "abcdefgh", "db1234567890")   // Connect to MySQL

                Or die("<p>Unable to connect to data base server 1.</p>"

                . "<p>Error code " . mysqli_connect_errno()

                . "; " . mysqli_connect_error()) . "</p>";

 

// $DBName = "AddressBook";                                                                                                                                                                  // (Test)                               

$DBName = "db240712012";                                                                                                      

mysqli_select_db($DBConnect, $DBName)                                                                                         // Select Data base

                Or die("<p>Unable to select the data base.</p>"

                                . "<p>Error code " . mysqli_errno($DBConnect)

                                . "; " . mysqli_error($DBConnect)) . "</p>";

 

$TableName = "persons";                                                                                                                                                            // Read the Table

$SQLstring = "SELECT * FROM $TableName";

$QueryResult = @mysqli_query($DBConnect, $SQLstring)           

                Or die("<p>Unable to Read the table.</p>"

                                . "<p>Error code " . mysqli_errno($DBConnect)

                                . "; " . mysqli_error($DBConnect)) . "</p>";

 

$SQLstring = "UPDATE persons SET name='$Name', email='$Email', phone='$Phone', address='$Address'

                                                                WHERE personID=$PersonID";                                                                   // Update a Record

$QueryResult = @mysqli_query($DBConnect, $SQLstring)

                Or die("<p>Unable to update the record.</p>"

                                . "<p>Error code " . mysqli_errno($DBConnect)

                                . "; " . mysqli_error($DBConnect)) . "</p>";

echo "<p>Successfully updated the record.</p>";                                                          

                               

mysqli_close($DBConnect);       

?>

<p><a href="indexMstr.php">Return to Menu Page</a></p>

</body>

</html>