Heed some help with the coding

General discussions related to php

Moderators: macek, egami, gesf

abelwang
New php-forum User
New php-forum User
Posts: 1
Joined: Thu Mar 27, 2014 8:22 am

Heed some help with the coding

Postby abelwang » Thu Mar 27, 2014 8:25 am

hi all,

please help me with the error below.

Notice: Undefined index: action in D:\server\website\htdocs\job-search\admin\add_category.php on line 27

Notice: Undefined index: action in D:\server\website\htdocs\job-search\admin\add_category.php on line 44

This the codes..

<?php
include('../inc/config.php');
require_once ('../libs/Smarty.class.php');
require_once ('../inc/smarty_config.php');
require_once ('../inc/database.class.php');
//include('header.php');
include('inc/manage_adv.class.php');
include('inc/secure.class.php');
include('inc/db.class.php');
$secure = new secure();
if (!$secure->adminOk) {
$secure->redirect();
}
$adv = new adv();

if (!$secure->adminOk) {
$secure->redirect();
}
?>

<?php
if (isset($_POST['addcategory'])== 'Add') {
$category = clean($_POST['category']);
$query = "INSERT into category(category)values('{$category}')";
$q = mysql_query($query);
}
if ($_GET['action'] == 'edit') {
$edit_query = "select * from category where id='" . clean($_GET['id']) . "'";
$edit_query_result = mysql_query($edit_query);
$edit_query_result_rows = mysql_fetch_array($edit_query_result);
$namecat = $edit_query_result_rows['category'];
$smarty->assign('name',$namecat);
if (isset($_POST['updatecategory']) == 'Update') {

$id = clean($_GET['id']);
$category = clean($_POST['category']);
$query1 = "UPDATE category set category='{$category}' where id='{$id}'";
$q1 = mysql_query($query1);
if( $q1!=NULL ) {
header("Location: add_category.php");
}
}
}
if (clean($_GET['action']) == 'delete') {
$id = clean($_GET['id']);
$query3 = "Delete from category where id='{$id}'";
$q3 = mysql_query($query3);
}
$sql = "select * from category";
$catres = mysql_query($sql);
$catArray = array();
$i=0;
while($row = mysql_fetch_assoc($catres)){
$catArray[$i] = $row;
$i++;
}
//print_r($catArray);
$smarty->assign('catArray',$catArray);
$smarty->assign('session',$_SESSION);
$smarty->assign('static',$static);

$title = APP_HEAD_TITLE;
$keywords = APP_HEAD_KEYWORDS;
$description = APP_HEAD_DESCRIPTION;
$self = $_SERVER['PHP_SELF'];
$smarty->assign('title',$title);
$smarty->assign('keywords',$keywords);
$smarty->assign('description',$description);
$smarty->assign('lang',$lang);
//echo "<pre>";
//print_r($smarty);
//echo "</pre>";
$smarty->display('category.html');
?>


</p>
<p>
<?php
if (clean($_GET['action']) == 'edit') {
?>

<?php
} else {
?>

<?php
}
?>
</p>



<?php
include('footer.php');
?>

Return to “PHP General”

Who is online

Users browsing this forum: No registered users and 1 guest