
Untitled
By: a guest on
May 11th, 2012 | syntax:
None | size: 1.72 KB | hits: 19 | expires: Never
<?php
include("header.php");
?>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
</head>
<body>
<html>
<body>
<?php
$b = $_POST['b'];
$c = $_POST['c'];
$d = $_POST['d'];
$e = $_POST['e'];
$f = $_POST['f'];
$id = "".$_GET['id']."";
if($_POST['v'] == "1"){
if($b == ""){
$b = "NULL";
}
if($c == ""){
$c = "NULL";
}
if($d == ""){
$d = "NULL";
}
if($e == ""){
$e = "NULL";
}
if($f == ""){
$f = "NULL";
}
$dbconn = pg_connect("host=localhost dbname=project6 user=postgres password=p@ssw0rd")
or die('Could not connect: ' . pg_last_error());
$query = "update nutrition set shrt_desc=$b,water=$c,energ_kcal=$d,protein=$e,lipid_tot=$f where ndb_no = '$id'";
$update = pg_query($dbconn, $query);
if($update)
{
?>
<meta http-equiv="refresh" content="0; url=inspect.php?id=<?php echo $id; ?>">
<?php
} else {
echo "I can't update database.";
}
}
?>
<form action="#" method="post">
<input type="hidden" name="b" value="<?php echo $b; ?>">
<input type="hidden" name="c" value="<?php echo $c; ?>">
<input type="hidden" name="d" value="<?php echo $d; ?>">
<input type="hidden" name="e" value="<?php echo $e; ?>">
<input type="hidden" name="f" value="<?php echo $f; ?>">
<input type="hidden" name="v" value="1">
Ndb_No: <?php echo $a; ?><br>
Shrt_desc: <?php echo $b; ?><br>
Water: <?php echo $c; ?><br>
Energy_kcal: <?php echo $d; ?><br>
Protein: <?php echo $e; ?><br>
Lipid_tot: <?php echo $f; ?><br><br>
Are you sure you want to change this?<br>
<input type="submit" value="Yes">
<input type="button" value="No" onclick="location.href='edit.php?id=<?php echo $id; ?>'">
</form>
</body>
</html>