Jump to content
Killersites Forums

Inventory Page Again


Recommended Posts

hello have a page called inventory_list.php

i am not happy as i think the prob is to do with the date added part of my code

 

 

<?php

session_start(); /* this starts a session and is necssary if you want to work with session cookies they help you have pessitent data*/

if(!isset($_SESSION["manager"])){ /* if is not set session manger, in other words if they come to the admin index and they are not logged in they will be ushered to the admin login page*/

header("location: admin_login.php"); /*if you happen not be logged in then uou will be sent to the admin login section*/

exit(); /* if they are already logged in then they will go straight to the index page of the admin area*/

} /* it creates the variables that you log in with as the manager session and compares them to the credentials that you placed into the mysql database */

//BE sure to check that this manager SESSION value is in fact in the database

$managerID = preg_replace('#[^0-9]#i','', $_SESSION["id"]); //filter everyhting but numbers any numbers always auto incremeted this is the session id created when you first login all that can go into this field are numbers 0 through to 9

$manager = preg_replace('#[^A-Za-z0-9]#i','', $_SESSION["manager"]); //filter everything but numbers and letters after it gets cleansed

$password = preg_replace('#[^A-Za-z0-9]#i','', $_SESSION["password"]); //filter everything but numbers and letters

//Run mySQL query to be sure that this person is an admin and that their password session varequals the database information

//Connect to the MySQL database if they do have a session variable set yp you do not exit the script you allow the script to keep running

include "../storescripts/connect_to_mysql.php"; // include the database connection file so you link to your database

$sql= mysql_query("SELECT * FROM admin WHERE id= '$managerID' AND username= '$manager' AND password= '$password' LIMIT 1"); //query the person --make sure person exists in database----by using the three pieces of data *$managerID *$manager*$password

$existCount= mysql_num_rows($sql); //count the row nums after making a varible called existcount run mysql_num_rows($sql); and we can can a count value on the variable

if($existCount == 0){ //evaluate the count and if the person equals zero then they do not exist in the database

header("location: ../index.php");

exit();

}

?>

<?php

$product_list = "";

?>

<?php

//error reporting

error_reporting(E_ALL);

?>

<?php

//parse the form data and add inventory item to the system

if (isset($_POST['product_name'])) {

 

$product_name = mysql_real_escape_string($_POST['product_name']);

$price = mysql_real_escape_string($_POST['price']);

$category = mysql_real_escape_string($_POST['category']);

$subcategory = mysql_real_escape_string($_POST['subcategory']);

$details = mysql_real_escape_string($_POST['details']);

//see if that product name is an identical match to another product in the system

$sql = mysql_query("SELECT id FROM products WHERE product_name='$product_name' LIMIT 1");

$productMatch = mysql_num_rows ($sql); //count the output ammount

if ($productMatch > 0){

echo 'Sorry you tried to place a duplicate "Product Name" into the system, <a href="inventory_list.php">click here</a>';

exit();

//Add this product into the database now

}

 

$sql = mysql_query("INSERT INTO products(product_name, price, details, category, subcategory, date_added) VALUES('$product_name','$price','$details','$category','$subcategory',now())")or die (mysql_error()); //now adds todays date

$pid = mysql_insert_id();

//place image in the folder

$newname = "$pid.jpg";

move_uploaded_file( $_FILES['fileField']['tmp_name'], "../inventory_images/$newname");

header("location: inventory_list.php");

exit();

 

 

}

?>

<?php

//This block grabs the whole list for viewing

$product_list = "";

$sql = mysql_query("SELECT * FROM products");

$productCount = mysql_num_rows($sql);//count the the output ammount

if ($productCount > 0){

while($row = mysql_fetch_array($sql)){

$id = $row["id"];

$price = $row["price"];

$product_name = $row["product_name"];

 

i think this is the problem but mind block!!!

 

$date_added = strftime("%b %d, %Y", strtotime($row["date_Added"])); // Notice here how we changed it from _added to _Added

$product_list .= "$id - $product_name -  £$price -  $date_added    <a href='inventory_edit.phppid=$id'>edit</a>••<a href='inventory_list.php?deleteid=$id'>  delete</a><br/>";

}

 

}else{

$product_list = "You have no products listed in your store Yet";

 

}

?>

 

 

<!DOCTYPE HTML>

<html>

<head>

<meta charset="utf-8">

<title>Inventory List</title>

<link href="../my_carousel/includes/shop.css" rel="stylesheet" type="text/css">

<!--[if lt IE 9]>

<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>

<![endif]-->

 

</head>

 

<body>

<div id="mainWrapper">

<div class="container">

<?php include_once("../admin_head_template.php") ?>

 

<div class="sidebar1">

<nav>

<ul>

<li><a href="#">graphic Design</a></li>

<li><a href="#">Pay monthly</a></li>

<li><a href="#">pricing</a></li>

<li><a href="#">templates</a></li>

<li><a href="#">**Contact Us**</a></li>

</ul>

</nav>

<div>

<aside>

<div><section>

<p><img src="../style/portia_price (2).gif" width="150" height="291" alt="portia_price"></p>

</section></div>

<p> </p>

<p> </p>

<section>

<p>starting point and modify the properties to produce your own unique look. If you require flyout menus, create your own using a Spry menu, a menu widget from Adobe's Exchange or a variety of other javascript or CSS solutions.</p>

<p>If you would like the navigation along the top, simply move the ul to the top of the page and recreate the styling.</p>

</section>

</aside>

</div>

<!-- end .sidebar1 --></div>

<article class="content">

<h1>Portia Solutions</h1>

<section>

<h1>Admin</h1>

<div align="right"style="margin-right:22px"><a href="inventory_list.php#inventoryForm">+Add New Inventory Item</a></div>

<div align="left" style="margin-left:24px">

<h3>Inventory list</h3>

<?php echo $product_list; ?>

<p> </p>

<p> </p>

</div>

<p> </p>

</section>

<section>

<hr />

 

<div>

<a name="inventoryForm" id="inventoryForm"></a>

<h3 align="center">

↓ Add New Inventory Item Form ↓

</h3>

</div>

<form action="inventory_list.php" enctype="multipart/form-data" name="myForm" id="myForm" method="post">

<table width="90%" border="0" cellspacing="0" cellpadding="6">

<tr>

<td width="20%" align="right">Product Name</td>

<td width="80%"><label>

<input name="product_name" style="margin-left:6px" "type="text" id="product_name" size="64" />

</label></td>

</tr>

<tr>

<td align="right">Product Price</td>

<td><label>

£

<input name="price" style="margin-left:4px" type="text" id="price" size="12" />

</label></td>

</tr>

<tr>

<td align="right">Category</td>

<td><label>

<select name="category" id="category" style="margin-left:18px" >

<option value=1PageSite" > 1PageSite</option>

<option value=ECommerce" > E-Commerce</option>

<option value=adPackageBasic" > adPackageBasic</option>

<option value=adPackageFull" > adPackageFull</option>

<option value=Branding" > Branding</option>

<option value=UpdatePackage" > Updatepackage</option>

</select>

</label></td>

</tr>

<tr>

<td align="right">Subcategory</td>

<td><select name="subcategory" id="subcategory" style="margin-left:18px" >

<option value=""></option>

<option value="Logo">Logo</option>

<option value="Flash">Flash</option>

<option value="Scripts">Scripts</option>

<option value="Leaflets">Leaflets</option>

<option value="BusinessCards">Businesscards</option>

 

</select></td>

</tr>

<tr>

<td align="right">Product Details</td>

<td><label>

<textarea style="margin-left:4px" name="details" id="details" cols="48" rows="5"></textarea>

</label></td>

</tr>

<tr>

<td align="right">Product Image</td>

<td><label>

<input type="file" name="fileField" id="fileField" />

</label></td>

</tr>

<tr>

<td> </td>

<td><label>

<input type="submit" name="button" id="button" value="Add This Item Now" />

</label></td>

</tr>

</table>

</form>

</p>

<div align="center"><img align="center" src="../style/webdevelopment.finished.png" width="250" height="90" alt="html5"></div>

<p> </p>

</section>

<!-- end .content --></article>

<aside class="aside-right">

<h4>Backgrounds</h4>

<section>

 

 

</section>

</aside>

<table width="32%" cellpadding="1">

<tr>

<td> </td>

</tr>

<tr>

<td> </td>

</tr>

</table>

<footer>

<section>

<div align="center"><a href="How_long.php">:How long will it Take?:</a> </div>

</section>

<section>

<p align="center"><a href="#">:Do we Outsource?:</a></p>

</section>

<div align="center"><a href="#">:How long will it take to get recognized?:

 

</a></div>

<a href="#">

<section>

</section>

</a>

<section>

<p align="center"> </p></section>

<section>

<div align="right">

<table align="left" width="55%%" cellpadding="1">

<tr>

<td> </td>

</tr>

<tr>

<td> </td>

</tr>

<tr>

<td> <address class="copyright">

©Copyrighted by Portia Solutions

</address></td>

</tr>

</table>

 

<img style="margin-right:5px" src="../style/portia.png" alt="portia" width="160" height="85"></div>

</section>

</footer>

<!-- end .container --></div>

</body>

</html>

 

 

when i add a produst to the databse it says

 

 

Notice: Undefined index: date_Added in C:\xampp\htdocs\myNewweb\storeadmin\inventory_list.php on line 68

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...