having a slight problem with admin interface

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
AshrakTheWhite
Forum Commoner
Posts: 69
Joined: Thu Feb 02, 2006 6:47 am

having a slight problem with admin interface

Post 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());
}
?>
someberry
Forum Contributor
Posts: 172
Joined: Mon Apr 11, 2005 5:16 am

Re: having a slight problem with admin interface

Post 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()'?
AshrakTheWhite
Forum Commoner
Posts: 69
Joined: Thu Feb 02, 2006 6:47 am

Post by AshrakTheWhite »

got it working
Post Reply