Monday, October 27, 2014

Earn Cash Online


You can earn in 8 different ways:
  • Earn by Clicking Ads
  • Earn through AutoSurfing
  • Earn by Viewing Videos
  • Earn by Liking the Webpages
  • Earn by Completing Offers
  • Earn through Traffic Exchange
  • Earn by Promoting your PTP Link
  • Earn by Clicking Email Ads

Thursday, June 27, 2013

Create tab base page inside the main page

Create a style sheet named as style.css


* {
margin:0;
padding:0;
}
body {
background:url(../../images/background.png) top left;
font: .8em "Lucida Sans Unicode", "Lucida Grande", sans-serif;
}
h2{
margin-bottom:10px;
}
#wrapper{
width:720px;
margin:40px auto 0;
}

Monday, April 29, 2013

Delete data from list and instant postback from another page

Create a file named aclist.php, which will contain account list and a delete image.

<?php
session_start();
if(!$_session=$myusername){
header("location:index.php");
}
?>
<head>
<title>WELCOME CUSTOMER</title>
</head>
<body>
<h2><center>Account List</center></h2>
<br>
<?php
error_reporting(E_ALL ^ E_NOTICE);

$username = 'DBUSER';
$password = 'DBPASS';
$ora_host='(DESCRIPTION =(ADDRESS =(PROTOCOL = TCP)(HOST = 102.101.2.1)(PORT = 1521))(CONNECT_DATA =(SID = DBNAME)))';
$objConnect = ocilogon($username, $password, $ora_host);

$strSQL = "select *from TABLENAME";
$objParse = oci_parse ($objConnect, $strSQL);
oci_execute ($objParse,OCI_DEFAULT);
$Num_Rows = oci_fetch_all($objParse, $Result);
$strSQLa = "SELECT AC.ACCOUNTNUMBER, AC.NAME ACN, ba.name BCN, cat.name CCN, st.name DCN, pac.MSG ECN FROM TABLE_NAME where pac.ACCOUNTNUMBER = AC.ACCOUNTNUMBER";

$objParsea = oci_parse ($objConnect, $strSQLa);
oci_execute ($objParsea,OCI_DEFAULT);
$Num_Rows2 = oci_fetch_all($objParsea, $Resulta);

$Per_Page = 7;   // Per Page
$Page = $_GET["Page"];
if(!$_GET["Page"])
{
$Page=1;
}
$Prev_Page = $Page-1;
$Next_Page = $Page+1;
$Page_Start = (($Per_Page*$Page)-$Per_Page);
if($Num_Rows<=$Per_Page)
{
$Num_Pages =1;
}
else if(($Num_Rows % $Per_Page)==0)
{
$Num_Pages =($Num_Rows/$Per_Page) ;
}
else
{
$Num_Pages =($Num_Rows/$Per_Page)+1;
$Num_Pages = (int)$Num_Pages;
}
$Page_End = $Per_Page * $Page;
if ($Page_End > $Num_Rows)
{
$Page_End = $Num_Rows;
}

print "<center>";
print "<table border=\"1\" align=\"center\" cellpadding=\"0\" cellspacing=\"1\" >";
print "<tr border=\"1\">";
print "<td valign=\"top\" style=\"border:1px solid black\" width=\"150\"><p align=\"center\"><b>ACCOUNT NUMBER</td>";
print "<td valign=\"top\" style=\"border:1px solid black\" width=\"300\"><p align=\"center\"><b>NAME</td>";
print "<td valign=\"top\" style=\"border:1px solid black\" width=\"150\"><p align=\"center\"><b>AREA</td>";
print "<td valign=\"top\" style=\"border:1px solid black\" width=\"80\"><p align=\"center\"><b>CATEGORY</td>";
print "<td valign=\"top\" style=\"border:1px solid black\" width=\"80\"><p align=\"center\"><b>STATUS</td>";
print "<td valign=\"top\" style=\"border:1px solid black\" width=\"80\"><p align=\"center\"><b>MSG</td>";
print "</tr>";

for($i=$Page_Start;$i<$Page_End;$i++)
{
?>

<tr border=\"1\">
<td valign="top" style="border:1px solid black"><font color="black"><?php print $Result["ACCOUNTNUMBER"][$i];?></td>
<td valign="top" style="border:1px solid black"><font color="black"><?php print $Resulta["ACN"][$i];?></td>
<td valign="top" style="border:1px solid black"><font color="black"><?php print $Resulta["BCN"][$i];?></td>
<td valign="top" style="border:1px solid black"><font color="black"><?php print $Resulta["CCN"][$i];?></td>
<td valign="top" style="border:1px solid black"><font color="black"><?php print $Resulta["DCN"][$i];?></td>
<td valign="top" style="border:1px solid black"><font color="black"><?php print $Resulta["ECN"][$i];?></td>
<?php
$ac_num=$Result["ACCOUNTNUMBER"][$i];
print "<td width=\"30\"><form action=\"delcsms.php\" method=\"POST\">";
print "<input type=\"hidden\" name=\"ac_no\" value=\"$ac_num\">";
print "<input type=\"image\" id=\"enter\"  name=\"submit: width=\"30\" height=\"15\" src=\"del.png\">";
?>
</tr>
</form>
<?
}
?>
</table>
</center>
<br>
<center><table align="center" style="width:50%; ">
<font size=2><b>
Total <?= $Num_Rows;?> Record : <?=$Num_Pages;?> Page :
<?
if($Prev_Page)
{
echo " <a href='$_SERVER[SCRIPT_NAME]?Page=$Prev_Page'><< Back</a> ";
}

for($i=1; $i<=$Num_Pages; $i++){
if($i != $Page)
{
echo "[ <a href='$_SERVER[SCRIPT_NAME]?Page=$i'>$i</a> ]";
}
else
{
echo "<b> $i </b>";
}
}
if($Page!=$Num_Pages)
{
echo " <a href ='$_SERVER[SCRIPT_NAME]?Page=$Next_Page'>Next>></a> ";
}
oci_close($objConnect);
//}
?>
</p>
<?php
}
else
{
print "<img src=\"access_denied.gif\" alt=\"ACCESS\" width=\"255\" height=\"77\" />";
}
?>
</table></center>
</b></font>
</center>
</body>
</html>

Another pagination using php and oracle

<?php
session_start();
if(!$_session=$myusername){
header("location:index.php");
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Welcome User</title>
<link href="css/layout.css" rel="stylesheet" type="text/css" />
<link href="css/forms.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="wrap">
<?php
date_default_timezone_set ("Asia/Dhaka");
$date=date("d-M-y");
?>
<div id="content" align="center">
<div id="home_main"><div id="search">
<div class="tab">
<h2>CURRENT ACCOUNTS LIST</h2>
</div>
<div class="container">
<br>
<table width="450" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
<tr>
<form name="form1" method="post" action="<?php print $_SERVER['PHP_SELF'] ?>">
<td>
<table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
<tr><td width="350"><b>Select Area</td>
<td width="6">:</td>
<td width="150"><select name="pcatagory">
<option selected value="">Select  Area</option>
<option value="R0069">AREA01
<option value="R0124">AREA02
<option value="R0164">AREA03
<option value="R0364">AREA04</option>
</select></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td><input type="submit" name="submit" value="Check Account Detail"></td><td></td>
</tr>
</table>
</td>
</form>
</tr>
</table>

<?php
$pccat=$_POST['pcatagory'];
if($_POST['pcatagory']!="")
{
         $_SESSION['pcatagory']=$pccat;
         $barea=$_SESSION['pcatagory'];
        }
else
  {
    $barea=$_SESSION['pcatagory'];
  }

error_reporting(E_ALL ^ E_NOTICE);
print "<br>";

if($barea=="R0069")
{
$billarea="AREA01";
}
if($barea=="R0124")
{
$billarea="AREA02";
}
if($barea=="R0164")
{
$billarea="AREA03";
}
if($barea=="R0364")
{
$billarea="AREA04";
}

if($barea)
{

Print "<b>Customer Area : <font color=\"red\">". $billarea."</font></b>";
print "<br>";
$username = 'dbuser';
$password = 'dbpassword';
$ora_host='(DESCRIPTION =(ADDRESS =(PROTOCOL = TCP)(HOST = 102.102.1.1)(PORT = 1521))(CONNECT_DATA =(SID = dbname)))';
$objConnect = ocilogon($username, $password, $ora_host);

$strSQL = "select FL.ACCOUNTNUMBER, FL.CUSTNAME, FL.ENTRY_DATE DATE,
 from table_name where  FL.AREAID = '$barea' ";
$objParse = oci_parse ($objConnect, $strSQL);
oci_execute ($objParse,OCI_DEFAULT);
$Num_Rows = oci_fetch_all($objParse, $Result);
$Per_Page = 7;   // Per Page
$Page = $_GET["Page"];
if(!$_GET["Page"])
{
$Page=1;
}
$Prev_Page = $Page-1;
$Next_Page = $Page+1;
$Page_Start = (($Per_Page*$Page)-$Per_Page);
if($Num_Rows<=$Per_Page)
{
$Num_Pages =1;
}
else if(($Num_Rows % $Per_Page)==0)
{
$Num_Pages =($Num_Rows/$Per_Page) ;
}
else
{
$Num_Pages =($Num_Rows/$Per_Page)+1;
$Num_Pages = (int)$Num_Pages;
}
$Page_End = $Per_Page * $Page;
if ($Page_End > $Num_Rows)
{
$Page_End = $Num_Rows;
}
print "<br>";
print "<table border=\"1\" align=\"center\" cellpadding=\"0\" cellspacing=\"1\" >";
print "<tr border=\"1\">";
print "<td valign=\"top\" style=\"border:1px solid black\" width=\"150\"><p align=\"center\"><b>ACCOUNT NUMBER</td>";
print "<td valign=\"top\" style=\"border:1px solid black\" width=\"150\"><p align=\"center\"><b>CUSTOMER NAME</td>";
print "<td valign=\"top\" style=\"border:1px solid black\" width=\"150\"><p align=\"center\"><b>DATE</td>";
print "</tr>";

for($i=$Page_Start;$i<$Page_End;$i++)
{
?>
<tr border=\"1\">
<td valign="top" style="border:1px solid black"><font color="black"><?php print $Result["ACCOUNTNUMBER"][$i];?></td>
<td valign="top" style="border:1px solid black"><font color="black"><?php print $Result["PACKAGENAME"][$i];?></td>
<td valign="top" style="border:1px solid black"><font color="black"><?php print $Result["DATE"][$i];?></td>

<?php
$ac_num=$Result["ACCOUNTNUMBER"][$i];
print "<td width=\"30\"><form action=\"prevfup.php\" method=\"POST\">";
print "<input type=\"hidden\" name=\"ac_no\" value=\"$ac_num\">";
print "<input type=\"image\" id=\"enter\" name=\"submit: width=\"30\" height=\"15\" src=\"prev.jpg\">";
?>
</tr>
</form>

<?
}
?>
</table>
<center><table align="center" style="width:50%; ">
<font size=2><b>
Total <?= $Num_Rows;?> Record : <?=$Num_Pages;?> Page :
<?
if($Prev_Page)
{
echo " <a href='$_SERVER[SCRIPT_NAME]?Page=$Prev_Page'><< Back</a> ";
}

for($i=1; $i<=$Num_Pages; $i++){
if($i != $Page)
{
echo "[ <a href='$_SERVER[SCRIPT_NAME]?Page=$i'>$i</a> ]";
}
else
{
echo "<b> $i </b>";
}
}
if($Page!=$Num_Pages)
{
echo " <a href ='$_SERVER[SCRIPT_NAME]?Page=$Next_Page'>Next>></a> ";
}
oci_close($objConnect);
}
?>
</p>
</table></center>
</b></font>
</center>
</div>
</div></div>
<div class="clear">&nbsp;</div>
</div>
</div>
</body>
</html>

Select value from database and viewed using pagination in php

Create a external pagination file pagination.php

<?php

class PS_Pagination {
var $php_self;
var $rows_per_page = 10; //Number of records to display per page
var $total_rows = 0; //Total number of rows returned by the query
var $links_per_page = 5; //Number of links to display per page
var $append = ""; //Paremeters to append to pagination links
var $sql = "";
var $debug = false;
var $conn = false;
var $page = 1;
var $max_pages = 0;
var $offset = 0;

/**
* Constructor
*
* @param resource $connection Mysql connection link
* @param string $sql SQL query to paginate. Example : SELECT * FROM users
* @param integer $rows_per_page Number of records to display per page. Defaults to 10
* @param integer $links_per_page Number of links to display per page. Defaults to 5
* @param string $append Parameters to be appended to pagination links
*/

function PS_Pagination($connection, $sql, $rows_per_page = 10, $links_per_page = 5, $append = "") {
$this->conn = $connection;
$this->sql = $sql;
$this->rows_per_page = (int)$rows_per_page;
if (intval($links_per_page ) > 0) {
$this->links_per_page = (int)$links_per_page;
} else {
$this->links_per_page = 5;
}
$this->append = $append;
$this->php_self = htmlspecialchars($_SERVER['PHP_SELF'] );
if (isset($_GET['page'] )) {
$this->page = intval($_GET['page'] );
}
}

/**
* Executes the SQL query and initializes internal variables
*
* @access public
* @return resource
*/
function paginate() {
//Check for valid mysql connection
if (! $this->conn || ! is_resource($this->conn )) {
if ($this->debug)
echo "MySQL connection missing<br />";
return false;
}

//Find total number of rows
$all_rs = @mysql_query($this->sql );
if (! $all_rs) {
if ($this->debug)
echo "SQL query failed. Check your query.<br /><br />Error Returned: " . mysql_error();
return false;
}
$this->total_rows = mysql_num_rows($all_rs );
@mysql_close($all_rs );

//Return FALSE if no rows found
if ($this->total_rows == 0) {
if ($this->debug)
echo "Query returned zero rows.";
return FALSE;
}

//Max number of pages
$this->max_pages = ceil($this->total_rows / $this->rows_per_page );
if ($this->links_per_page > $this->max_pages) {
$this->links_per_page = $this->max_pages;
}

//Check the page value just in case someone is trying to input an aribitrary value
if ($this->page > $this->max_pages || $this->page <= 0) {
$this->page = 1;
}

//Calculate Offset
$this->offset = $this->rows_per_page * ($this->page - 1);

//Fetch the required result set
$rs = @mysql_query($this->sql . " LIMIT {$this->offset}, {$this->rows_per_page}" );
if (! $rs) {
if ($this->debug)
echo "Pagination query failed. Check your query.<br /><br />Error Returned: " . mysql_error();
return false;
}
return $rs;
}

/**
* Display the link to the first page
*
* @access public
* @param string $tag Text string to be displayed as the link. Defaults to 'First'
* @return string
*/
function renderFirst($tag = 'First') {
if ($this->total_rows == 0)
return FALSE;

if ($this->page == 1) {
return "$tag ";
} else {
return '<a href="' . $this->php_self . '?page=1&' . $this->append . '">' . $tag . '</a> ';
}
}

/**
* Display the link to the last page
*
* @access public
* @param string $tag Text string to be displayed as the link. Defaults to 'Last'
* @return string
*/
function renderLast($tag = 'Last') {
if ($this->total_rows == 0)
return FALSE;

if ($this->page == $this->max_pages) {
return $tag;
} else {
return ' <a href="' . $this->php_self . '?page=' . $this->max_pages . '&' . $this->append . '">' . $tag . '</a>';
}
}

/**
* Display the next link
*
* @access public
* @param string $tag Text string to be displayed as the link. Defaults to '>>'
* @return string
*/
function renderNext($tag = '&gt;&gt;') {
if ($this->total_rows == 0)
return FALSE;

if ($this->page < $this->max_pages) {
return '<a href="' . $this->php_self . '?page=' . ($this->page + 1) . '&' . $this->append . '">' . $tag . '</a>';
} else {
return $tag;
}
}

/**
* Display the previous link
*
* @access public
* @param string $tag Text string to be displayed as the link. Defaults to '<<'
* @return string
*/
function renderPrev($tag = '&lt;&lt;') {
if ($this->total_rows == 0)
return FALSE;

if ($this->page > 1) {
return ' <a href="' . $this->php_self . '?page=' . ($this->page - 1) . '&' . $this->append . '">' . $tag . '</a>';
} else {
return " $tag";
}
}

/**
* Display the page links
*
* @access public
* @return string
*/
function renderNav($prefix = '<span class="page_link">', $suffix = '</span>') {
if ($this->total_rows == 0)
return FALSE;

$batch = ceil($this->page / $this->links_per_page );
$end = $batch * $this->links_per_page;
if ($end == $this->page) {
//$end = $end + $this->links_per_page - 1;
//$end = $end + ceil($this->links_per_page/2);
}
if ($end > $this->max_pages) {
$end = $this->max_pages;
}
$start = $end - $this->links_per_page + 1;
$links = '';

for($i = $start; $i <= $end; $i ++) {
if ($i == $this->page) {
$links .= $prefix . " $i " . $suffix;
} else {
$links .= ' ' . $prefix . '<a href="' . $this->php_self . '?page=' . $i . '&' . $this->append . '">' . $i . '</a>' . $suffix . ' ';
}
}

return $links;
}

/**
* Display full pagination navigation
*
* @access public
* @return string
*/
function renderFullNav() {
return $this->renderFirst() . '&nbsp;' . $this->renderPrev() . '&nbsp;' . $this->renderNav() . '&nbsp;' . $this->renderNext() . '&nbsp;' . $this->renderLast();
}

/**
* Set debug mode
*
* @access public
* @param bool $debug Set to TRUE to enable debug messages
* @return void
*/
function setDebug($debug) {
$this->debug = $debug;
}
}
?>

Popup window in javascript

Add those lines between head tag.


<script type="text/javascript">
function newPopup(url) {
popupWindow = window.open(
url,'popUpWindow','height=350,width=800,left=10,top=10,resizable=no,scrollbars=yes,toolbar=no,menubar=no,location=no,directories=no,status=no')
}
</script>

Create a form inside body tag.


<?php
print "<form action=\"JavaScript:newPopup('comment.php');\" method=\"POST\">";
print "<input type=\"hidden\" name=\"rnum\" value=\" $ac_no\">";
print "<td><input type=\"image\" id=\"enter\" name=\"submit\" src=\"images/comment.gif\">";
print "</td>";
print "</form>";
?>

Create a simple html or php page which you want to be popped out.

Enjoy your pop out window having all editable properties[height=350,width=800,left=10,top=10,resizable=no,scrollbars=yes,toolbar=no,menubar=no,location=no,directories=no,status=no].

How to check if login credentials are null or not register in php


Add those lines before html tag. if login credentials are null or not register it will redirect the page in index page. In this case credential is username.

<?php
error_reporting(E_ALL ^ E_NOTICE ^ E_WARNING);
session_start();
if(!$_session=$myusername){
header("location:index.php");
}
?>