<?php

ini_set("display_errors", 1);
include_once 'function.php';
is_admin();
$id = $_GET['id'];
if (isset($_POST['submit'])) {
    updateproduct();
}
$qwe = $db->prepare("select * from `product` where `id`=?");
$qwe->execute(array($id));
$res = $qwe->fetch();
$x = getcategory();
?>
<html>
    <head>
<link rel="stylesheet" href="css/styles.css">
  <link rel="stylesheet" href="css/style1.css">
  		<!-- TinyMCE -->
<script src="js/jquery-1.10.2.min.js" type="text/javascript"></script>
<script src="js/setup.js" type="text/javascript"></script/>
    <script src="js/tiny-mce/jquery.tinymce.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(document).ready(function () {
	
            setupTinyMCE();

        });
		
    </script>
	
Beispiel #2
0
		  <?php 
include_once 'dbconfig.php';
//get the name
$name;
if ($_SERVER["REQUEST_METHOD"] == "GET") {
    $x = $_GET['id'];
    //this name is used to display filled form in first part and
    // to update the required row in the second part.
    displayform($x);
}
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $productname = $_POST["productname"];
    $productcategory = $_POST["productcategory"];
    $productprice = $_POST["productprice"];
    $hiddenname = $_POST["hiddenname"];
    updateproduct($hiddenname, $productname, $productcategory, $productprice);
}
function updateproduct($hiddenname, $productname, $productcategory, $productprice)
{
    //$name=$GLOBALS['name'];
    $sql = "UPDATE products SET product_name='{$productname}',product_category='{$productcategory}', product_price='{$productprice}' WHERE product_id='{$hiddenname}'";
    if ($GLOBALS['con']->query($sql) === TRUE) {
        echo "Record updated successfully";
        header('Location: index.php');
    } else {
        echo "Error updating record: " . $GLOBALS['con']->error;
    }
}
function displayform($x)
{
    $id = $x;