Hi,
Initialy i use the below code to load the inputed data into the Databse with a auto-incrament primary key resulting with a ID number for the registration.
--------------
$sql = "insert into `$tbl_name` (`cna`, `phone`, `mobile`, `f_name`, `s_name`, .........................
------------
I have worked out a way of loading, and now updating the data useing the below code
-----------------
$sql = "replace into `$tbl_name` (`cna`, `phone`, `mobile`, `f_name`, `s_name`, .........................
----------------
but the problem is that the querie will delete the original key, load a new key with the updated information on it.
which now causes conflictions where the original ID when recorded no longer exisits.
Is there anouther way to go about this ? below is the full list of code from the php script.
Thanks
Tiranto
----------------------
<?php
$host="#Removed#"; // Host name
$username="#Removed#"; // Mysql username
$password="#Removed#"; // Mysql password
$db_name="foc"; // Database name
$tbl_name="foc_data"; // Table name
// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
// username and password sent from form
$cna = mysql_real_escape_string(strip_tags($_POST['cna']));
$phone = mysql_real_escape_string(strip_tags($_POST['phone']));
$mobile = mysql_real_escape_string(strip_tags($_POST['mobile']));
$f_name = mysql_real_escape_string(strip_tags($_POST['f_name']));
$s_name = mysql_real_escape_string(strip_tags($_POST['s_name']));
$sql = "replace into `$tbl_name` (`cna`, `phone`, `mobile`, `f_name`, `s_name`)
values ('$cna', '$phone', '$mobile', '$f_name', '$s_name')";
//$result=mysql_query($sql)or die("test");
$result=mysql_query($sql)or header("location:../error messages/fail.php");
// If result matched $myusername and $mypassword, table row must be 1 row
if($count==1){
//Register $cna and redirect to file "success.php"
session_register("cna");
}
else {
$focid = mysql_real_escape_string(strip_tags($_GET["focid"]));
$sql = 'SELECT * FROM ' . $tbl_name . ' WHERE cna="' . $cna . '"';
$result = mysql_query($sql);
$output_focid = mysql_result($result,0,"focid");
include("form_body.php");
include("form_fotter.php");
}
?>
----------------------
Note im learing as I go, so you probably will see code that might be a older way or a longer way of doing things, but its how i manage to get it to work from researching the internet help guides to build this my self.