PHP

//Image upload start
if(isset($_FILES[‘v_picture’][‘name’])){
$dest = “uploads/banner/”;

if(isset($_FILES[‘v_picture’][‘name’]) && $_FILES[‘v_picture’][‘name’]!=””)
{
if (($_FILES[“v_picture”][“type”] == “image/gif”)
|| ($_FILES[“v_picture”][“type”] == “image/jpeg”)
|| ($_FILES[“v_picture”][“type”] == “image/png”)
|| ($_FILES[“v_picture”][“type”] == “image/pjpeg”))
{
// remove old one
$file_name = time().$_FILES[‘v_picture’][‘name’];
$file_name = $gnrl->removeChars($file_name);
move_uploaded_file($_FILES[‘v_picture’][‘tmp_name’],$dest.$file_name);
}
else
{
$gnrl->redirectTo($label.”.php?msg=imageonly”);
}
}
}
//image upload end

 

//Login In PHP

<?php
require(‘includes/configuration.php’);

$table = ‘tbl_admin’;
if( $_GET[‘msg’] == “logout” ) {
$ins = array(‘d_last_log’ => date(‘Y/m/d H:i:s’));
$dclass->update($table,$ins,” id='”.$_SESSION[‘adminid’].”‘”);

session_unregister(‘adminid’);
session_unregister(‘adminlevel’);
session_unregister(‘adminname’);
}

if(isset($_REQUEST[‘submit’]) && $_REQUEST[‘submit’]==’Sign In’){
extract($_POST);
$check = $dclass->select(“*”,$table,” AND ( v_admin_username='”.$v_admin_username.”‘ OR v_admin_email='”.$v_admin_username.”‘ ) AND v_admin_password='”.$v_admin_password.”‘ AND e_admin_status=’active'”);
if(!empty($check)){
$getData = $dclass->select(“*”,$table,” AND v_admin_username='”.$v_admin_username.”‘ AND v_admin_password='”.$v_admin_password.”‘”);
$_SESSION[‘adminid’] = $check[0][‘id’];
$_SESSION[‘adminlevel’] = $check[0][‘i_admin_level’];
$_SESSION[‘adminname’] = $check[0][‘v_admin_username’];
$_SESSION[‘lastlog’] = $check[0][‘d_last_log’];

//Update Last Login date and time in admin table
$dclass->update($table,”array(‘d_last_log’=>now())”,” id = ‘”.$_SESSION[‘adminid’].”‘”);
header(‘location:site_setting.php’);
}else{
$_REQUEST[‘msg’] = “invalid”;

}
}
?>

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”&gt;
<html xmlns=”http://www.w3.org/1999/xhtml”&gt;
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″ />
<title>Admin Panel | Sign In</title>
<link rel=”stylesheet” href=”css/reset.css” type=”text/css” media=”screen” />
<link rel=”stylesheet” href=”css/style.css” type=”text/css” media=”screen” />
<link rel=”stylesheet” href=”css/invalid.css” type=”text/css” media=”screen” />
<script src=”js/jquery-1.3.2.min.js” type=”text/javascript” ></script>
<script type=”text/javascript” language=”javascript”>

function blank_field_email(str1,str2)
{
if ( ($.trim(document.getElementById(str1).value) != ‘Username/Email’) && ($.trim(document.getElementById(str2).value) != ‘password’) )
{
return true;
}else{
return false;
}
}
function blank_field_email(str,value)
{
if($.trim(document.getElementById(str).value) == value)
{
document.getElementById(str).value = “”;
}
}
function fill_field_email(str,value)
{
if($.trim(document.getElementById(str).value) == “”)
{
document.getElementById(str).value = value;
}
}
</script>
</head>

<body id=”login”>
<div id=”login-wrapper” class=”png_bg”>
<div id=”login-top”>
<!– Logo –>
<h1>Admin Panel</h1>
</div>
<!– End #logn-top –>
<?php
$v_admin_username =’Username/Email’ ;
$v_admin_password = ‘password’;
?>
<form name=”frm_login” action=”” method=”post”>
<div id=”login-content”>
<?php
if($_REQUEST[‘msg’]!=”) {
?>
<div class=”notification information png_bg”>
<div><?php echo $mess[$_REQUEST[‘msg’]];?></div>
</div>
<?php
}
?>

<p>
<label>Username</label>
<input class=”text-input” name=”v_admin_username” id=”v_admin_username” value=”” type=”text” onblur=”fill_field_email(‘v_admin_username’,’Username/Email’);” onfocus=”blank_field_email(‘v_admin_username’,’Username/Email’);” onmouseover=”blank_field_email(‘v_admin_username’,’Username/Email’);” onmouseout=”fill_field_email(‘v_admin_username’,’Username/Email’);” />
</p>
<div class=”clear”></div>
<p>
<label>Password</label>
<input class=”text-input” name=”v_admin_password” id=”v_admin_password” type=”password” blank_field_email(‘v_admin_password’,’password’); onfocus=”blank_field_email(‘v_admin_password’,’password’);” onmouseover=”blank_field_email(‘v_admin_password’,’password’);” onmouseout=”fill_field_email(‘v_admin_password’,’password’);” />
</p>
<div class=”clear”></div>
<a href=”forgot_password.php”>Forgot password?</a> <span>
<input type=”submit” name=”submit” id=”submit” onclick=”return check(‘v_admin_username’,’v_admin_password’);”value=”Sign In” class=”button” style=”background-color:#0085C4;”/>
</span>

</div>
</form>
<br /><br />
<br /><br />

<!– End #login-content –>

</div>
<!– End #login-wrapper –>
<!– software copyright http://software4.mobi –>
<!– Remember you my use it but you dont own it // http://software4.mobi –>
</body>
</html>

// Image Upload

# upload image starts
$dest = “uploads/”.$label.”/”;
if(isset($_FILES[‘photo’][‘name’]) && $_FILES[‘photo’][‘name’] !=””) {
$file_name = time().$_FILES[‘photo’][‘name’];
$file_name = $gnrl->removeChars($file_name);
if(move_uploaded_file($_FILES[‘photo’][‘tmp_name’],$dest.$file_name)) {
$insimg = array(‘photo’ => $file_name);
$dclass->update($table,$insimg,” id=’$id2′”);
}
}
# upload image ends

//AJAx Jquery With DB

<script type=”text/javascript” src=”js/jquery.min.js”></script>
<script type=”text/javascript”>
$(document).ready(function(){
$(‘#category_id’).change(function(){
$.post(“get_cat.php”, {
contact_get: $(‘#category_id’).val(),
}, function(response){
//alert(response);
$(‘#show_category’).html(response);
});
return false;
});
});
</script>

<body>
<h3>Category</h3>
<select name=”category_id” id=”category_id”>
<?php
//echo ‘<pre>’; print_r(mysql_fetch_array($Recordset1));
while($row = mysql_fetch_array($Recordset1))
{
//echo $row[‘id’] . ” ” . $row[‘name’] . ” ” .$row[‘parent’] . ” ” . $row[‘link’];
echo “<option value=”.$row[‘id’].”>”.$row[‘name’].”</option>”;
}
?>
</select>

<h3>Sub Category</h3>
<div id=”show_category”>
<select name=”sub_category_id” id=”sub_category_id”>
<?php
//echo ‘<pre>’; print_r(mysql_fetch_array($Recordset1));
$query_Recordset11 = “SELECT * FROM categories where parent = ‘1’”;
$Recordset11 = mysql_query($query_Recordset11);
while($row = mysql_fetch_array($Recordset11))
{
//echo $row[‘id’] . ” ” . $row[‘name’] . ” ” .$row[‘parent’] . ” ” . $row[‘link’];
echo “<option value=”.$row[‘id’].”>”.$row[‘name’].”</option>”;
}
?>
</select>
</div>

<h3>Link</h3>
<label id=”link”>
<?php
$sql = “SELECT * from categories WHERE id=’1′”;
$result = mysql_query($sql,$con);
$val = mysql_fetch_row($result);
echo $val[‘3’]; ?>
</label>
</body>

get_category.php

<?php
// include configuration file
require(‘config_db.php’);
mysql_select_db(“dynamicmenu”, $con);

$id = $_REQUEST[‘contact_get’];
$result = mysql_query(“SELECT * FROM categories where parent = ‘$id'”);
?>
<select name=”category_id” id=”category_id”>
<?php
while($row = mysql_fetch_array($result))
{
echo “<option value=”.$row[‘id’].”>”.$row[‘name’].”</option>”;
}
?>
<select>

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: