.

Thursday, 21 August 2014

Simple Login logout system using php

Simple Login logout system using php

Login and logout system is the most important thing for the user management, session management is one important thing for manage the user for the whole time of login time. for that we have to use session for this. it should have 5 files for this. we have to fetch the same value for the user and check the session and register the session value. and make destroy for logout. let see it detail,
Login logout system

DOWNLOAD             LIVE DEMO
it should need 5 files for this login-logout system, they are
  1. login/index page
  2. datafetch/usercheck page
  3. session/check page
  4. welcome/profile page
  5. logout page

the above files must me needed for this. we can named it as our wish. let see what i done here. and the database file is needed, if you have any doubt about insert coding check here for insert code 

database name --> 2mylogin
table name --> login

DB.PHP

<?php 
$conn=mysql_connect('localhost','root','');
$db=mysql_select_db('2my4edge',$conn);
?>

INDEX.PHP

<?php
session_start();
?>
<
form method="post" name="login" action="login.php">
<
label for="name" class="labelname"> Username </label>
<
input type="text" name="username" id="userid" required="required" /><br />
<
label for="name" class="labelname"> Password </label>
<
input type="password" name="password" id="passid" required="required" /><br />
<
input type="submit" name="submit" id="submit" value="Login" />
</
form>
in the index page we have to start the session, as the above mentioned. action is performed in login.php page.

LOGIN.PHP

<?php 
include('db.php');
session_start();
{
$user=mysql_real_escape_string($_POST['username']);
$pass=mysql_real_escape_string($_POST['password']);
$fetch=mysql_query("SELECT id FROM `login` WHERE 
                         username='$user' and password='$pass'");
$count=mysql_num_rows($fetch);
if($count!="")
{
session_register("sessionusername");
$_SESSION['login_username']=$user;
header("Location:profile.php");
}
else
{
header('Location:index.php');
}

}
?>
if the session is registered then go to check the profile.php page there session.php file is included so the session is checked.

SESSION.PHP

<?php
include('db.php');
session_start();
$check=$_SESSION['login_username'];
$session=mysql_query("SELECT username FROM `login` WHERE username='$check' ");
$row=mysql_fetch_array($session);
$login_session=$row['username'];
if(!isset($login_session))
{
header("Location:index.php");
}
?>
check the session value is correct or not. if the session is value is not set, then again redirect to index.php page.

PROFILE.PHP

<?php
include("session.php");
?>

<h3 align="center"> Hellow <?php echo $login_session; ?></h3>
<h2 align="center" >Welcome to login system</h2>

<h4 align="center"> click here to <a href="logout.php">LogOut</a> </h4>

assign the logout.php page in the profile.php page.

LOGOUT.PHP

<?php
session_start();
if(session_destroy())
{
header("Location: index.php");
}
?>
in the logout.php page, we should unset or destroy the session value as the above you seen. then locate to index.php page.
and we should have to start the session in all the page.

Thursday, 14 August 2014

Image Slideshow Using PHP and simple Jquery

Step 1:Creating our style to beautify our slideshow

to create, open your php editor and paste the code bellow and save it as "slideshow.php."


  1. <html lang="en">



  2. <head>



  3. <title>Simplest jQuery Slideshow</title>



  4.  



  5. <style>



  6. body {font-family:Arial, Helvetica, sans-serif; font-size:12px;}



  7.  



  8. .fadein {



  9. position:relative; height:332px; width:500px; margin:0 auto;



  10. background: url("slideshow-bg.png") repeat-x scroll left top transparent;



  11. padding: 10px;



  12. }



  13. .fadein img { position:absolute; left:10px; top:10px; }



  14. </style>



Step 2: Creating and linking our jquery

To create, copy and paste the code below after the style tag in the file "slideshow.php".


  1. <script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>



  2. <script>



  3. $(function(){



  4. $('.fadein img:gt(0)').hide();



  5. setInterval(function(){$('.fadein :first-child').fadeOut().next('img').fadeIn().end().appendTo('.fadein');}, 3000);



  6. });



  7. </script>



Step 3: Creating the div tag where the images display

Copy and paste the code below after the script tag of "slideshow.php".


  1. </head>



  2. <body>



  3. <div class="fadein">



  4. <img src="http://chictraveler.wpengine.netdna-cdn.com/wp-content/uploads/2010/09/Picture-91-500x332.png">



  5. <img src="http://sevillespain.info/wp-content/uploads/2012/02/Casa-De-Carmona-Hotel-Seville-casa_de_carmona_galeria_mr_1200-500x332.jpg">



  6. <img src="http://hereelsewhere.com/wp-content/uploads/2012/06/Chambre22-500x332.jpeg">



  7. <img src="http://www.worlddesignhotels.com/wp-content/uploads/407/X%20Ordinary%20Room-500x332.jpg">



  8. <img src="http://armywife101.com/wp-content/uploads/2012/09/DoubleTree-Suites-by-Hilton-exterior-photo-Downtown-Disney-Resort-Area-Hotels-500x332.jpg">



  9. </div>



  10. </body>



  11. </html>



the summarize code will look like the code below


  1. <html lang="en">



  2. <head>



  3. <title>Simplest jQuery Slideshow</title>



  4.  



  5. <style>



  6. body {font-family:Arial, Helvetica, sans-serif; font-size:12px;}



  7.  



  8. .fadein {



  9. position:relative; height:332px; width:500px; margin:0 auto;



  10. background: url("slideshow-bg.png") repeat-x scroll left top transparent;



  11. padding: 10px;



  12. }



  13. .fadein img { position:absolute; left:10px; top:10px; }



  14. </style>



  15.  



  16. <script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>



  17. <script>



  18. $(function(){



  19. $('.fadein img:gt(0)').hide();



  20. setInterval(function(){$('.fadein :first-child').fadeOut().next('img').fadeIn().end().appendTo('.fadein');}, 3000);



  21. });



  22. </script>



  23.  



  24. </head>



  25. <body>



  26. <div class="fadein">



  27. <img src="http://chictraveler.wpengine.netdna-cdn.com/wp-content/uploads/2010/09/Picture-91-500x332.png">



  28. <img src="http://sevillespain.info/wp-content/uploads/2012/02/Casa-De-Carmona-Hotel-Seville-casa_de_carmona_galeria_mr_1200-500x332.jpg">



  29. <img src="http://hereelsewhere.com/wp-content/uploads/2012/06/Chambre22-500x332.jpeg">



  30. <img src="http://www.worlddesignhotels.com/wp-content/uploads/407/X%20Ordinary%20Room-500x332.jpg">



  31. <img src="http://armywife101.com/wp-content/uploads/2012/09/DoubleTree-Suites-by-Hilton-exterior-photo-Downtown-Disney-Resort-Area-Hotels-500x332.jpg">



  32. </div>



  33. </body>



  34. </html>



Congratulation, you've been successfully created your image slideshow with a very few lines of code.
I also included the file in this tutorial. you can download the file and run it on your computer.
Hope this code helps you.

Difference : Margin & Padding

Set the margin in an element

An element has four sides: right, left, top and bottom. The margin is the distance from each side to the neighboring element (or the borders of the document).
As the first example, we will look at how you define margins for the document itself i.e. for the element <body>. The illustration below shows how we want the margins in our pages to be.
Examples of margins
The CSS code for this would look as follow:
 
body {
margin-top: 100px;
margin-right: 40px;
margin-bottom: 10px;
margin-left: 70px;
}

Or you could choose a more elegant compilation:
 
body {
margin: 100px 40px 10px 70px;
}

You can set the margins in the same way on almost every element. For example, we can choose to define margins for all of our text paragraphs marked with <p>:
 
body {
margin: 100px 40px 10px 70px;
}

p {
margin: 5px 50px 5px 50px;
}


Set padding in an element

Padding can also be understood as "filling". This makes sense as padding does not affect the distance of the element to other elements but only defines the inner distance between the border and the content of the element.
The usage of padding can be illustrated by looking at a simple example where all headlines have background colors:
 
h1 {
background: yellow;
}

h2 {
background: orange;
}

By defining padding for the headlines, you change how much filling there will be around the text in each headline:
 
h1 {
background: yellow;
padding: 20px 20px 20px 80px;
}

h2 {
background: orange;
padding-left:120px;
}

PHP Connect to the MySQL Server

PHP Connect to the MySQL Server


Use the PHP mysqli_connect() function to open a new connection to the MySQL server.

Open a Connection to the MySQL Server

Before we can access data in a database, we must open a connection to the MySQL server.
In PHP, this is done with the mysqli_connect() function.

Syntax

mysqli_connect(host,username,password,dbname);

Parameter Description
host Optional. Either a host name or an IP address
username Optional. The MySQL user name
password Optional. The password to log in with
dbname Optional. The default database to be used when performing queries
Note: There are more available parameters, but the ones listed above are the most important.
In the following example we store the connection in a variable ($con) for later use in the script:
<?php
// Create connection
$con=mysqli_connect("example.com","peter","abc123","my_db");

// Check connection
if (mysqli_connect_errno()) {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
?>


Close a Connection

The connection will be closed automatically when the script ends. To close the connection before, use the mysqli_close() function:
<?php
$con=mysqli_connect("example.com","peter","abc123","my_db");

// Check connection
if (mysqli_connect_errno()) {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
}

mysqli_close($con);
?>

Tuesday, 12 August 2014

Modifying a Joomla! Template

To preserve your changes you need to Copy the template with all its files and styles. This procedure makes references to creating a full copy (an exact duplicate) of the template including all the files. In order to make a copy, you must be on the Customise Template view. There are two methods available for accessing the Template Manager: Customise Template. The Customise Template interface allows for editing the actual code found in the template files, creating template overrides and template file manipulation.

One-Click or Switch to Template View

30-Template-manager-template-styles-view-1.png
Tip-icon.png
A Tip!
Styles column refers to changing the available parameters of a template, such as color, font-color, logo, etc. These are dependent on the parameters a template maker made available and are a convenience for quick changes. Template - column refers to editing the actual template files.
To access the Template Customise feature:
  • Directly - Click the template name in the column Template
600
  • Indirectly - Styles will be highlighted, click on Templates below it which will turn the view to Template Manager:Templates, see image below.
30-Template-manager-template-style-view.png
  • Select the template you wish to modify which will change the view to Template Manager: Customise Template view

Customisation View

You should now be looking at the image below, Template Manager: Customise Template.
3x-template-manager-customise-template.png

Copy an Existing Template

The Easy Way

Create a new template by copying an existing template:
3x-template-manager-customise-template-toolbar.png
  • Provide a new name and click on Copy Template
3x-template-manager-customise-template-popup-copy.png
  • The template is completely copied. This includes styles and all the template files.

Manually

  • Create a new /templates/my_template directory.
  • Copy the contents of the original template directory to the my_template directory.
  • Go to the root /language/en-GB directory.
    • Copy /language/en-GB/en-GB.tpl_original_template.ini to en-GB.tpl_my_template.ini
    • Copy /language/en-GB/en-GB.tpl_original_template.sys.ini to en-GB.tpl_my_template.sys.ini
  • Go to the /language/en-GB directory in the template's directory, if it exists.
    • Copy /language/en-GB/en-GB.tpl_original_template.ini to en-GB.tpl_my_template.ini
    • Copy /language/en-GB/en-GB.tpl_original_template.sys.ini to en-GB.tpl_my_template.sys.ini
  • Open the templateDetails.xml file in the my_template directory and change all references, if they exist, for the original template directory to the new directory my_template.
<name>My_Template</name>
<language tag="en-GB">en-GB.tpl_my_template.ini</language>
<language tag="en-GB">en-GB.tpl_my_template.sys.ini</language>
<param name="theme_header" type="folderlist" directory="templates/my_template/styles/header" default="" label="Header Themes" description="HEADER THEMES DESCRIPTION" />
<param name="theme_background" type="folderlist" directory="templates/my_theme/styles/background" default="" label="Background Themes" description="BACKGROUND THEMES DESCRIPTION" />
<param name="theme_elements" type="folderlist" directory="templates/my_theme/styles/elements" default="" label="Primary Elements" description="PRIMARY ELEMENTS DESCRIPTION" />

Discover the New Template

When manually copying a template, the new template must be introduced to your Joomla site through the discovery process.
  • Go to Administrator  Extensions  Extension Manager  Discover
  • Click the Discover icon.
  • Select your new template.
  • Click Install.
If successful, the new template will now be available in Administrator  Extensions  Template Manager
  • Make the new template the default template.
  • View the site to verify it.

Finding Errors

You might have problems as a result of copying an existing template to a new template. Because of the way that Joomla handles file names, you might be tripped up by a capitalization error, for example.
Joomla contains some useful debugging tools. To see what is happening while working on a site, there are three settings that you should change.
  1. Administration > Site > Global Configuration > System > Debug Settings > Debug System > Yes (Default = No)
  2. Administration > Site > Global Configuration > System > Debug Settings > Debug Language > Yes (Default = No)
  3. Administration > Site > Global Configuration > Server > Server Settings > Error Reporting > Maximum (Default = System Default)
With the Debug Language set to Yes, for instance, you will see the success or failure of language file loading on each page of the Administrator. Open the Joomla Debug Console > Language Files Loaded panel to view the report.

How to override the output from the Joomla! core

There may be occasions where you would like to change the way a Joomla! Extension (such as a Component or Module, whether from the Joomla! core or produced by a third party) is displayed on your site. Of course, you could recode the Extension from scratch, but that may be a bit ambitious for you! Thankfully, there is another way.
The standard output from any Joomla! Module or Component can be overridden by adding code to the html directory of your template. It is also possible to override two aspects of core functionality: Module chrome, and pagination.
As of Joomla 3.2 overrides can be created using the Template manager Creating Overrides

Getting a head-start with overrides

If you are new to Joomla! development, then it is probably easiest to start with an existing view, and try modifying it to get what you want. To do this, you should make a copy of the existing view in the html directory of your template, and then modify the copy.
The directory structure you need is:
TEMPLATE_NAME/html/EXTENSION_NAME/VIEW_NAME/FILE_NAME.php
For example, if you want to change the way that the 'Article' view displays a com_content article, then you should copy the file at
PATH_TO_JOOMLA/components/com_content/views/article/tmpl/default.php
to
TEMPLATE_NAME/html/com_content/article/default.php
(note the slight difference in directory structure)
Similarly, if you want to change how the mod_login Module is displayed, then you should copy
PATH_TO_JOOMLA/modules/mod_login/tmpl/default.php
to
TEMPLATE_NAME/html/mod_login/default.php

Joomla! comes pre-packaged with a frontend template called Beez. Beez utilizes template overrides to produce a table-less layout for faster, smoother, and semantically correct markup. To see how it's done, locate your Joomla! installation's template directory, and you'll notice the Beez template. Inside the Beez template directory, you'll find a directory named html
the entire directory structure is as follows:
/your_joomla/templates/Beez/html/
If you want to try modifying the overrides used in Beez, you could simply copy and paste the Beez html directory into your own template's main directory. However you choose to make your override files, you will need to ensure that they are correctly installed with your template. To do this, you should add the following code to your template's templateDetails.xml file (in between the <files> and </files> tags):
<folder>html</folder>
The above code in essence lets the Joomla! package installer know that there are files to extract, and that they are part of the template as a whole.

Further tips

Template overrides are almost limitless. They allow you to add, edit, and remove the components of the Joomla! core output. The Template Manager can be used to create override files ready for editing.
Note: For the FireFox web browser, an extension called Firebug is available, which is useful for browsing a page's HTML source and matching it up with the PHP code used in template overrides. For more information, please watch the free video tutorial on using Firebug with Joomla. Now firebug is also available for IE called Firebug Lite.
More information is available from the following resources:

Parent/child tree generator

<?php

$nav_query = mysql_query("SELECT * FROM `cm2year` ORDER BY `catid`");
$tree = ""; // Clear the directory tree
$depth = 1; // Child level depth.
$top_level_on = 1; // What top-level category are we on?
$exclude = array(); // Define the exclusion array
array_push($exclude, 0); // Put a starting value in it

while ( $nav_row = mysql_fetch_array($nav_query) )
{
$goOn = 1; // Resets variable to allow us to continue building out the tree.
for($x = 0; $x < count($exclude); $x++ ) // Check to see if the new item has been used
{
if ( $exclude[$x] == $nav_row['catid'] )
{
$goOn = 0;
break; // Stop looking b/c we already found that it's in the exclusion list and we can't continue to process this node
}
}
if ( $goOn == 1 )
{
$tree .= "Year". $nav_row['catname'] . "<br>"; // Process the main tree node
array_push($exclude, $nav_row['catid']); // Add to the exclusion list
if ( $nav_row['category_id'] < 6 )
{ $top_level_on = $nav_row['catid']; }

$tree .= build_child($nav_row['catid']); // Start the recursive function of building the child tree
}
}

function build_child($oldID) // Recursive function to get all of the children...unlimited depth
{
global $exclude, $depth; // Refer to the global array defined at the top of this script
$child_query = mysql_query("SELECT * FROM `cm3model` WHERE parentid=" . $oldID);
while ( $child = mysql_fetch_array($child_query) )
{
if ( $child['catid'] != $child['parentid'] )
{
for ( $c=0;$c<$depth;$c++ ) // Indent over so that there is distinction between levels
{ $tempTree .= "&nbsp;"; }
$tempTree .= "options[" . $child['parentid'] ."]". "=new Option" . "(\"" . $child['catname'] ."\"" . "," . "\"http://www.intimegraphics.com/category_s/" . $child['catid']. ".htm\")<br>";
$depth++; // Incriment depth b/c we're building this child's child tree  (complicated yet???)
$tempTree .= build_child($child['catid']); // Add to the temporary local tree
$depth--; // Decrement depth b/c we're done building the child's child tree.
array_push($exclude, $child['catid']); // Add the item to the exclusion list
}
}

return $tempTree; // Return the entire child tree
}

echo $tree;

?>

.

Popular Posts

Powered by Blogger.