Wednesday, December 18, 2013

How to Reset the Administrator Password in Joomla

How to ste Administrator password lost in joomla

Password Reset Trick

1. If you are the developer and has the access to database then just fire a update query in jos_users

UPDATE jos_users  SET `username` = 'admin'`password` = 'md5("YOUR PASSWORD")' ;

where you can set the  username and password 

this is the easiest way to reset the password in Joomla

 

Monday, June 3, 2013

WHAT IS AJAX

IT STANDS FOR ASYNCHRONOUS JAVASCRIPT ASYNCHRONOUS XML .AJAX is widely used for real time results from server like data needed for a site showing sharebazzar news or one showing cricket scores.

It is quite easy to learn AJAX

Just simply crate a AJAX Object and call it through JAVASCRIPT

Here is a simple function to create xmlhttp object
function the_Object() {
   
    var xmlhttp;
    // This if condition for Firefox and Opera Browsers
    if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
        try  {
            xmlhttp = new XMLHttpRequest();
        }
        catch (e) {
            alert("Your browser is not supporting XMLHTTPRequest");
            xmlhttp = false;
        }
    }
    // else condition for ie
    else {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    return xmlhttp;
}
var request = the_Object();

THIS OBJECT THEN USED WITH  JAVASCRIPT TO PERFORM TASK

HERE IS EXAMPLE

function searchdata(){

var tosearch = document.getElementById("txtsearch").value;
var searchby = document.getElementById("selfld").value;
if(searchby=='0'){
     alert("Please select Category");
return false;
}
var url = "search.php";// PHP SCRIPT FILE
url1= url+"?tosearch="+tosearch+"&searchby="+searchby; //PASSING VARIABLE
request.open("GET", url1, true);//OPEN URL

request.onreadystatechange = function aa() {//Call a function when the state changes.
       
        if(request.readyState == 4 && request.status == 200) {
            ans=request.responseText;
            document.getElementById("test").style.visibility = 'visible';
            document.getElementById("test").innerHTML=ans;//PLACE OUTPUT
            }
}
request.send(null);
}

THIS IS HOW AJAX WORKS

Thursday, May 16, 2013

How to fetch records from Mysql Databae

The important technique in php is to fetch records from the database to list the data you need to used following php functions

  1. mysql_connect : to connect the mysql server with apache server
  2. mysql_select_db : to connect to a particular database in the mysql server
  3. mysql_query  : to fire a query in the database.
  4. mysql_num_rows to find the number of records in a recordset which is derived from query fired.
  5. mysql_fetch_array to fetch array from record set.
  6. mysql_fetch_assoc  to fetch row from associative array.
  7. mysql_fetch_row  to  fetch row from record set.
  8. mysql_fetch_object  to fetch the data as object generally use to fetch large data
  9. mysql_close close mysql connection   
Step by step we can use this functions to fetch data from Database 

 Using while loop


$recordset = mysql_query("select * from DBTABLE"); 
while ($record= mysql_fetch_array($recordset ) { 
                echo "user_id: ".$record["db_field_name"]."<br />\n"; // as in database
                echo "user_id: ".$record[0]."<br />\n"; // in key value as in array
                  }


This will fetch the database values from dbtable and retrieve list of particular db_field_name


Using for while loop and mysql_fetch_object
$recordset = mysql_query("select * from DBTABLE"); 


while ($record= mysql_fetch_object($recordset )) { 
         echo $record->db_field_name


Using for loop
$record= mysql_fetch_array($recordset );
$count=count($record) ;
for($i = 0;$i< $count ; $i ++)
{ 
                 echo "user_id: ".$record[$i]["db_field_name"]."<br />\n"; // as in database
}
 we will go through other function later...





Tuesday, May 14, 2013

function mysql_connect

The most important function that is used in the php coding is mysql_connect .

This is function used to connect Mysql server with Apache server (PHP).

The syntax for it goes as

mysql_connect ( localhost,username,password)

where the localhost refers to Mysql HOST

username :Mysql username
password ;Mysql password

Example of mysql_connect

<?php
    $link = mysql_connect("localhost", "username", "password")
        or die("Could not connect");
    print ("Connected successfully");
    mysql_close($link);
?>


Similar function which is used for connecting the Mysql server is mysql_pconnect

Mysql_pconnect establishes a persistent connection

In Mysql_connect after the script that calls it has finished it will be closed. but mysql_pconnect will continue to hold the connection until it is closed manually by the user. 

Monday, May 13, 2013

array_key_exists() 

function It is a array function which is used to check if the given key or index exists in the array.

To better understand the function let us see an example

$your_array = array("one" => 1, "two" => 4);
if (array_key_exists("one", $your_array)) {
      echo "The 'one' element is in the array";
 }

if the key exists in the array it will return true other wise it would return false

Use of  array_key_exists()

This function is widely use to save programmers time in search function.

 Most of the array function contain a wide range of argument which can be used to minimize source code.

Wednesday, May 8, 2013

What is PHP

PHP is a very  simple and interactive programming language.It is simple to learn and easy to understand.popularly known as "Personal Home Page" but it  does not mean PHP stands for it.it stands as HYPERTEXT PRE-PROCESSOR.

To learn PHP, our basic requirement is knowledge of HTML ,JAVASCRIPT, and overview of C and C++.

To start php in a code you need to declare  <?php
And to end a php code you need to declare ?>

php is very near to basic C language so it is simple to learn. but PHP supports OOPS i.e Object oriented programming.

Main Benefit of  PHP is it is an open source and available to all freely.

The basic structure of HTML goes like this

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
   "http://www.w3.org/TR/html4/strict.dtd">
<HTML>
   <HEAD>
      <TITLE>Mytitle</TITLE>
   </HEAD>
   <BODY>
      <P>My Content
   </BODY>
</HTML> 
 
when we want to use the php code we can just modify this like
 
<HTML>
   <HEAD>
        <title>Mytitle</title>
  </HEAD>
    <BODY>
<P>
        <?php 
        echo "My Content"; 
        ?>

   
</BODY>
</HTML> 

Now save the file as some "filename.php" and execute the file
in the localhost which would give OUTPUT as below in Browser.
 
My Content