Page 1 of 1

having a slight problem with admin interface

Posted: Mon May 08, 2006 6:47 am
by AshrakTheWhite
heres the code:

for some reason none of it is reaching the mysql qury string and there by not being entered into DB, any suggestions?

also if i swap the isset for !empty then it prints out absolutely nothing?!

Code: Select all

<?php
session_start();
require_once 'functions.php';
connectDB();

error_reporting(E_ALL);

echo '
    <table>
        <tr>
            <td>
                <a href="adminInterface.php?op=editShop">Edit Shop Items</a>
            </td>
            <td>
                <a href="adminInterface.php?op=viewOrders">View Orders</a>
            </td>
            <td>
                <a href="adminInterface.php?op=logOut">Log out</a>
            </td>
    </table>
';

switch($_GET['op'])
{
    case('editShop'):
        echo' 
            <table>
                <form method="post" action="adminInterface.php">
                    Enter Product Name:&nbsp
                    <input type="text" name="productName"><br>
                    Enter Product Price:&nbsp
                    <input type="text" name="productPrice"><br>
                    Enter Product Unit:&nbsp
                    <input type="text" name="productUnit"><br>
                    <input type="button" name="Submit" value="update">
                </form>
            </table>';
}

if(isset($_POST['productName'], $_POST['productPrice'], $_POST['productUnit']))
{
    $pName = $_POST['productName'];
    $pPrice = $_POST['productPrice'];
    $pUnit = $_POST['productUnit'];
    $pName = mysql_real_escape_string($pName);
    $pPrice = mysql_real_escape_string($pPrice);
    $pUnit = mysql_real_escape_string($pUnit);
    updateItems($pName, $pPrice, $pUnit);
}

function updateItems($pName, $pPrice, $pUnit)
{
    $query='
    INSERT INTO
        MarkoPood
    (name, hind, yhik)
        values ("' . $pName . '","' . $pPrice . '","' . $pUnit . '")    
    ';
    mysql_query($query) or die(mysql_error());
}
?>

Re: having a slight problem with admin interface

Posted: Mon May 08, 2006 7:17 am
by someberry
AshrakTheWhite wrote:also if i swap the isset for !empty then it prints out absolutely nothing?!
Thats because they check for different things.
isset - whether or not the variable has been set/instantiated.
empty - whether or not there is a value or not. '', '0', 0, NULL, FALSE, unstantiated (off the top of my head, probably one or two others) are empty.

Are you sure you have connected to your database, and are you actually calling the function 'updateItems()'?

Posted: Mon May 08, 2006 7:57 am
by AshrakTheWhite
got it working