bucket
11-04-2009, 11:42 PM
How do I do it so when this page gets run by itself it doesn't update the table, since if it does it will just make all the fields blank.
<?php
require_once ('inc/config.php');
$firstname = mysql_real_escape_string ($_POST['firstname']);
$lastname = mysql_real_escape_string ($_POST['lastname']);
$middlename= mysql_real_escape_string ($_POST['middlename']);
$id = 2;
$sql = mysql_query ("
UPDATE `testing` SET
`FirstName` = '".$firstname."',
`LastName` = '".$lastname."',
`MiddleName` = '".$middlename."'
WHERE `id` = '".$id."'
")
OR die (mysql_error());
?>
Instead make it update the table only when the form updates it?
<?php
require_once ('inc/config.php');
$firstname = mysql_real_escape_string ($_POST['firstname']);
$lastname = mysql_real_escape_string ($_POST['lastname']);
$middlename= mysql_real_escape_string ($_POST['middlename']);
$id = 2;
$sql = mysql_query ("
UPDATE `testing` SET
`FirstName` = '".$firstname."',
`LastName` = '".$lastname."',
`MiddleName` = '".$middlename."'
WHERE `id` = '".$id."'
")
OR die (mysql_error());
?>
Instead make it update the table only when the form updates it?