Search Google

Sunday, 21 December 2014

User Registration with Confirmation Email in OOP

https://plus.google.com/113677221098417166384/posts

The database will require a table to store the members, create a table called members:


?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
 CREATE TABLE `members` (
 `memberID` int(11) NOT NULL AUTO_INCREMENT,
 `username` varchar(255) NOT NULL,
 `password` varchar(60) NOT NULL, 
`email` varchar(255) NOT NULL,
 `active` varchar(255) NOT NULL,
 `resetToken` varchar(255) DEFAULT NULL,
 `resetComplete` varchar(3) DEFAULT 'No',
PRIMERY KEY (`memberID`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
In the classes folder their are two files: password.php and user.php. password.php is used to provide the same hashing capability that exists within php 5.5 it uses the same function names so versions 5.3 - 5.5 can use the same functions.
user.php is a class that contains methods to return the users hash (hashed password) as well as logging in, checking if a logged in session already exists and logging the user out.
I'll be going through the user.php methods as they are put to use.

Config.php

Config.php will be included into all pages enable sessions and turn on output buffering this way headers can be used anywhere in the project.
Set the timezone and define the credentials for the database, next attempt to make a new PDO connection if the connection fails display the error and kill the page.
Next include the user class and make an instance of it, pass in the database object to the class to make use of the database.

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?php
    ob_start();
    session_start();
      
          
    //database credentials
    define('DBHOST','localhost');
    define('DBUSER','root');
    define('DBPASS','');
    define('DBNAME','login');
      
    //application address
    define('DIR','http://localhost/loginregister/');
    define('SITEEMAIL','noreply@domain.com');
      
    try {
      
    //create PDO connection
    $db = new PDO("mysql:host=".DBHOST.";port=80;dbname=".DBNAME, DBUSER, DBPASS);
    $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
      
    } catch(PDOException $e) {
    //show error
    echo '<p class="bg-danger">'.$e->getMessage().'</p>';
    exit;
    }
      
    //include the user class, pass in the database connection
    include('classes/user.php');
    $user = new User($db);
    ?>


Next I have a folder called layout in there is a header.php and footer.php these will contain any layout code that will be used on every page, this saves having to include the stylesheet each time. header.php is a typical header file, notice the title expects a $title variable, this will be created in the pages and made available to this file, also making use of Bootstrap this is optional and is not required.

?
1
2
3
4
5
6
7
8
9
<!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="utf-8">
    <title><?php if(isset($title)){ echo $title; }?></title>
    <link href="//netdna.bootstrapcdn.com/bootstrap/3.1.0/css/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" href="style/main.css">
    </head>
    <body> 
Next footer.php this simply closed the body and html, that would be a good place for placing tracking code or any javascript includes.

?
1
2
3
</body>
</html>

index.php

This is the root page the system loads by default, on this page their is a form for users to register to the site, along with links to the login page, if they are already a member. Also if the user is already logged in they will be redirect to the members page.
How these pages start is by including the config file then checking if the user should be redirected or not.
a call is made to the user object $user->is_logged_in() this will return true or false if the user is logged in.

?
1
2
3
4
5
6
7
<?php
    //include config
    require_once('includes/config.php');
      
    //check if already logged in move to home page
    //if logged in redirect to members page
    if( $user->is_logged_in() ){ header('Location: memberpage.php'); }
The title and header.php file is also included on every page
?
1
2
3
4
5
//define page title
$title = 'Demo';
//include header template
require('layout/header.php');

For new registrations display a form consisting of username, email, password and confirm password

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<form role="form" method="post" action="" autocomplete="off">
      
    <div class="form-group">
    <input type="text" name="username" id="username" class="form-control input-lg" placeholder="User Name" value="<?php if(isset($error)){ echo $_POST['username']; } ?>" tabindex="1">
    </div>
    <div class="form-group">
    <input type="email" name="email" id="email" class="form-control input-lg" placeholder="Email Address" value="<?php if(isset($error)){ echo $_POST['email']; } ?>" tabindex="2">
    </div>
    <div class="row">
    <div class="col-xs-6 col-sm-6 col-md-6">
    <div class="form-group">
    <input type="password" name="password" id="password" class="form-control input-lg" placeholder="Password" tabindex="3">
    </div>
    </div>
    <div class="col-xs-6 col-sm-6 col-md-6">
    <div class="form-group">
    <input type="password" name="passwordConfirm" id="passwordConfirm" class="form-control input-lg" placeholder="Confirm Password" tabindex="4">
    </div>
    </div>
    </div>
    <div class="row">
    <div class="col-xs-6 col-md-6"><input type="submit" name="submit" value="Register" class="btn btn-primary btn-block btn-lg" tabindex="5"></div>
    </div>
    </form>  
This is a standard form, one thing to note I make use of sticky forms which means if their has been a validation error the fields that have been filled out will be populated again with the supplied data, except for passwords. Username and email would be restored.
This is done by doing an if statement, if the array $error is set meaning it exists then retrain the $_POST

?
1
value="<?php if(isset($error)){ echo $_POST['email']; } ?>"
If an error has been created it will be stored in an error array to display them loop through the array:

?
1
2
3
4
5
6
//check for any errors
    if(isset($error)){
    foreach($error as $error){
    echo '<p class="bg-danger">'.$error.'</p>';
    }
    
Once the new registration has been saved the form will post back to the same page appending a $_GET key on the end of the URL the key will be called action it will have a value of joined
(this technique is used through the project)

?
1
2
3
if(isset($_GET['action']) && $_GET['action'] == 'joined'){
    echo "<h2 class='bg-success'>Registration successful, please check your email to activate your account.</h2>";
    }
The form should only be processed if it has been submitted this can be checked by an if statement:

?
1
2
//if form has been submitted process it
    if(isset($_POST['submit'])){ 
This way only if the form has been submitted does the validation start and database interactions commence.

Validation

The validation used is fairly basic and can be improved upon
This example checks the length of the username if it's less then 3 characters an error is created, if the first check passes the username is looked up to see if it already exists by passing the username to the database if a record is found an error is created.

?
1
2
3
4
5
6
7
8
9
10
11
if(strlen($_POST['username']) < 3){
    $error[] = 'Username is too short.';
    } else {
    $stmt = $db->prepare('SELECT username FROM members WHERE username = :username');
    $stmt->execute(array(':username' => $_POST['username']));
    $row = $stmt->fetch(PDO::FETCH_ASSOC);
      
    if(!empty($row['username'])){
    $error[] = 'Username provided is already in use.';
    }
    
These check the password to make sure the email has not been used, it's important the email address is only used once, in the event the user wants to reset their password a link will be emailed to that user.

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
 if(strlen($_POST['password']) < 3){
    $error[] = 'Password is too short.';
    }
     
    if(strlen($_POST['passwordConfirm']) < 3){
    $error[] = 'Confirm password is too short.';
    }
     
    if($_POST['password'] != $_POST['passwordConfirm']){
    $error[] = 'Passwords do not match.';
    }
     
    //email validation
    if(!filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)){
    $error[] = 'Please enter a valid email address';
    } else {
    $stmt = $db->prepare('SELECT email FROM members WHERE email = :email');
    $stmt->execute(array(':email' => $_POST['email']));
    $row = $stmt->fetch(PDO::FETCH_ASSOC);
     
    if(!empty($row['email'])){
    $error[] = 'Email provided is already in use.';
    }
    }
After the validation if no errors have been created then carry on
The password provided cannot be stored as it is, that would be a huge security concern instead it's hashed by passing it to the user object inside a password_hash call this returns a hashed password which can then be stored in the database, this way no one can know what the password was apart from the user who entered it.
If your wondering how can the system login a user in without knowing the password; what happens when the user fills in the login form the password they enter is again hashed and then compared with the hash to see if its a match.
We also want to send an activation link to the user when they register to ensure their email address is active, for this we generate an activation code it will be sent in the emails and will form part of a url to validate the email address.

?
1
2
3
4
5
6
7
8
//if no errors have been created carry on
    if(!isset($error)){
      
    //hash the password
    $hashedpassword = $user->password_hash($_POST['password'], PASSWORD_BCRYPT);
      
    //create the activation code
    $activasion = md5(uniqid(rand(),true)); 
Next the user's details are saved to the database using a prepared statement, the first page of the query tells MySQL what action to perform in this case to add a new row and the table,columns to insert into.
where their are columns starting with : like :username these are place holders that will be used to bind the username value to $stmt->execute call. This is done to avoid passing user provided data to the query directly and avoid chances of MySQL Injection.
calling lastInsertId followed by the primary key will return the id of the record just saved, this is needed for the next step.

?
1
2
3
4
5
6
7
8
$stmt = $db->prepare('INSERT INTO members (username,password,email,active) VALUES (:username, :password, :email, :active)');
    $stmt->execute(array(
    ':username' => $_POST['username'],
    ':password' => $hashedpassword,
    ':email' => $_POST['email'],
    ':active' => $activasion
    ));
    $id = $db->lastInsertId('memberID'); 
Next send an email to the newly created user. Two constants defined in config.php will be used here
DIR - contains the full website address
SITEEMAIL - the email address used for emails
in the body of the email is a link activate.php?x=$id&y=$activasion this link is passing the id of the user $id and also the activation code when the user received this email, clicking the link will activate their account.

?
1
2
3
4
5
6
$to = $_POST['email'];
    $subject = "Registration Confirmation";
    $body = "Thank you for registering at demo site.nn To activate your account, please click on this link:nn ".DIR."activate.php?x=$id&y=$activasionnn Regards Site Admin nn";
    $additionalheaders = "From: <".SITEEMAIL.">rn";
    $additionalheaders .= "Reply-To: $".SITEEMAIL."";
    mail($to, $subject, $body, $additionalheaders); 
The last step is to redirect the page back to itself and adding an action with the value of joined so the page know if to show a success message.

?
1
2
header('Location: index.php?action=joined');
    exit;

activate.php

This page checks for the id and activation code being passed from the url (this happens when the user clicks the link from their email)
once the data has been verified the users record is updated, the column active is changed from the token to hold 'Yes' to say they are active, this will only happen if the id and token passed match what's stored against that user.

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<?php
    require('includes/config.php');
      
    //collect values from the url
    $memberID = trim($_GET['x']);
    $active = trim($_GET['y']);
      
    //if id is number and the active token is not empty carry on
    if(is_numeric($memberID) && !empty($active)){
      
    //update users record set the active column to Yes where the memberID and active value match the ones provided in the array
    $stmt = $db->prepare("UPDATE members SET active = 'Yes' WHERE memberID = :memberID AND active = :active");
    $stmt->execute(array(
    ':memberID' => $memberID,
    ':active' => $active
    ));
      
    //if the row was updated redirect the user
    if($stmt->rowCount() == 1){
      
    //redirect to login page
    header('Location: login.php?action=active');
    exit;
      
    } else {
    echo "Your account could not be activated.";
    }
    }
    ?> 

Login.php

Now users can register they need a way to login, start off with a form that expects their username and password

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<form role="form" method="post" action="" autocomplete="off">
      
    <div class="form-group">
    <input type="text" name="username" id="username" class="form-control input-lg" placeholder="User Name" value="<?php if(isset($error)){ echo $_POST['username']; } ?>" tabindex="1">
    </div>
      
    <div class="form-group">
    <input type="password" name="password" id="password" class="form-control input-lg" placeholder="Password" tabindex="3">
    </div>
    <div class="row">
    <div class="col-xs-9 col-sm-9 col-md-9">
    <a href='reset.php'>Forgot your Password?</a>
    </div>
    </div>
    <hr>
    <div class="row">
    <div class="col-xs-6 col-md-6"><input type="submit" name="submit" value="Login" class="btn btn-primary btn-block btn-lg" tabindex="5"></div>
    </div>
    </form> 
The login page will be used to show messages if the users account has been activated or password has been changed, the page will know which message to show based on the value contained inside $_GET['action']

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
if(isset($_GET['action'])){
//check the action
switch ($_GET['action']) {
case 'active':
echo "<h2 class='bg-success'>Your account is now active you may now log in.</h2>";
break;
case 'reset':
echo "<h2 class='bg-success'>Please check your inbox for a reset link.</h2>";
break;
case 'resetAccount':
echo "<h2 class='bg-success'>Password changed, you may now login.</h2>";
break;
}
}  
Next attempt to log the user in. Collect the username and password from the form pass them to the users object in the login method this internally will fetch the users hash by looking for the username in the database once the hash is returned it's then passed to password_verify if the hash and user's hash match it returns true which in turns sets a session $_SESSION['loggedin'] to true otherwise false is returned.

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
public function login($username,$password){
      
    $hashed = $this->get_user_hash($username);
    if($this->password_verify($password,$hashed) == 1){
    $_SESSION['loggedin'] = true;
    return true;
    }
    }
      
    <pre lang="php">
    //process login form if submitted
    if(isset($_POST['submit'])){
      
    $username = $_POST['username'];
    $password = $_POST['password'];
    if($user->login($username,$password)){
      
    header('Location: memberpage.php');
    exit;
    } else {
    $error[] = 'Wrong username or password or your account has not been activated.';
    }
      
    }//end if submit 

Logout.php

To log a user out its very easy:

?
1
2
 //logout
$user->logout();
Once the user is logged out redirect them.

memberpage.php

Once the user is logged in redirect them to the members only page (optional). To ensure a user can only access the page if logged in do a check:

?
1
2
//if not logged in redirect to login page
    if(!$user->is_logged_in()){ header('Location: login.php'); } 

In this example their is not a lot to the members page namely:

?
1
2
<h2>Member only page</h2>
    <p><a href='logout.php'>Logout</a></p> 

reset.php

every system need the ability to reset a password in case it's forgotten, how this will work is a user enters their email address, a check is made to make sure its belongs to a user.
Next a token is created and saved to the users record, an email is sent to them containing a link to when clicked the token from the link is verified, if it passed the user is provided with a form to enter their new password, its then saved to the database.
This may seem like a long winded approach but it does prevent the password being sent by email which is not recommended.
To start with the form

?
1
2
3
4
5
6
7
8
9
<form role="form" method="post" action="" autocomplete="off">
    <div class="form-group">
    <input type="email" name="email" id="email" class="form-control input-lg" placeholder="Email" value="" tabindex="1">
    </div>
    <hr>
    <div class="row">
    <div class="col-xs-6 col-md-6"><input type="submit" name="submit" value="Sent Reset Link" class="btn btn-primary btn-block btn-lg" tabindex="2"></div>
    </div>
    </form> 
If their is an $_GET['action'] show the correct message

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
<?php
    if(isset($_GET['action'])){
      
    //check the action
    switch ($_GET['action']) {
    case 'active':
    echo "<h2 class='bg-success'>Your account is now active you may now log in.</h2>";
    break;
    case 'reset':
    echo "<h2 class='bg-success'>Please check your inbox for a reset link.</h2>";
    break;
    }
    }
    ?> 
Next process the form ensure the email matches a user:

?
1
2
3
4
5
6
7
8
9
10
11
12
//email validation
    if(!filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)){
    $error[] = 'Please enter a valid email address';
    } else {
    $stmt = $db->prepare('SELECT email FROM members WHERE email = :email');
    $stmt->execute(array(':email' => $_POST['email']));
    $row = $stmt->fetch(PDO::FETCH_ASSOC);
      
    if(empty($row['email'])){
    $error[] = 'Email provided is not on recognised.';
    }
    
Create the token

?
1
2
 //create the activation code
    $token = md5(uniqid(rand(),true));
Next update the users record and set resetToken to the value of the token and resetComplete to No that will be needed if the link is clicked and password has been changed. Send an email to the user containing a link that points to resetPassword.php?key=$token passing the token.

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
$stmt = $db->prepare("UPDATE members SET resetToken = :token, resetComplete='No' WHERE email = :email");
    $stmt->execute(array(
    ':email' => $row['email'],
    ':token' => $token
    ));
      
    //send email
    $to = $row['email'];
    $subject = "Password Reset";
    $body = "Someone requested that the password be reset. nnIf this was a mistake, just ignore this email and nothing will happen.nnTo reset your password, visit the following address: ".DIR."resetPassword.php?key=$token";
    $additionalheaders = "From: <".SITEEMAIL.">rn";
    $additionalheaders .= "Reply-To: $".SITEEMAIL."";
    mail($to, $subject, $body, $additionalheaders);
      
    //redirect to index page
    header('Location: login.php?action=reset');
    exit; 
?
1
  

resetPassword.php

First check the token been passed to the page matches a user

?
1
2
3
4
5
6
7
8
9
10
$stmt = $db->prepare('SELECT resetToken, resetComplete FROM members WHERE resetToken = :token');
    $stmt->execute(array(':token' => $_GET['key']));
    $row = $stmt->fetch(PDO::FETCH_ASSOC);
      
    //if no token from db then kill the page
    if(empty($row['resetToken'])){
    $stop = 'Invalid token provided, please use the link provided in the reset email.';
    } elseif($row['resetComplete'] == 'Yes') {
    $stop = 'Your password has already been changed!';
    
If $stop has been set then display that

?
1
2
3
if(isset($stop)){
    echo "<p class='bg-danger'>$stop</p>";
    
If no errors have been created show a form to change the password

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
 <form role="form" method="post" action="" autocomplete="off">
    <div class="row">
    <div class="col-xs-6 col-sm-6 col-md-6">
    <div class="form-group">
    <input type="password" name="password" id="password" class="form-control input-lg" placeholder="Password" tabindex="1">
    </div>
    </div>
    <div class="col-xs-6 col-sm-6 col-md-6">
    <div class="form-group">
    <input type="password" name="passwordConfirm" id="passwordConfirm" class="form-control input-lg" placeholder="Confirm Password" tabindex="1">
    </div>
    </div>
    </div>
    <hr>
    <div class="row">
    <div class="col-xs-6 col-md-6"><input type="submit" name="submit" value="Change Password" class="btn btn-primary btn-block btn-lg" tabindex="3"></div>
    </div>
    </form>
Once the form has been submitted validate the data then hash the password update the users row and set resetComplete to Yes to indicate the process is finished if the reset link is clicked again from email the process will be halted.

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
 //if form has been submitted process it
if(isset($_POST['submit'])){
//basic validation
if(strlen($_POST['password']) < 3){
$error[] = 'Password is too short.';
}
if(strlen($_POST['passwordConfirm']) < 3){
$error[] = 'Confirm password is too short.';
}
if($_POST['password'] != $_POST['passwordConfirm']){
$error[] = 'Passwords do not match.';
}
//if no errors have been created carry on
if(!isset($error)){
//hash the password
$hashedpassword = $user->password_hash($_POST['password'], PASSWORD_BCRYPT);
try {
$stmt = $db->prepare("UPDATE members SET password = :hashedpassword, resetComplete = 'Yes' WHERE resetToken = :token");
$stmt->execute(array(
':hashedpassword' => $hashedpassword,
':token' => $row['resetToken']
));
//redirect to index page
header('Location: login.php?action=resetAccount');
exit;
//else catch the exception and show the error.
} catch(PDOException $e) {
$error[] = $e->getMessage();
}
}
}








------------------------------------------------------
PHP (recursive acronym for "PHP: Hypertext Preprocessor") is a widely-used Open Source general purpose
scripting language that is especially suited for Web development and can be embedded
into HTML.
This is the simple Code Example through which you can Add, Delete, View , Edit from MySql
Database.
Paste this code and save the file as written above.

Create a database named test and create a table student as below structure.


?
1
2
3
4
5
6
7
8
9
CREATE TABLE `student` ( `roll` int(11) default NULL, `class` varchar(20) default NULL, `name`
 
varchar(40) default NULL, `f_name` varchar(40) default NULL, `sex` varchar(6) default NULL,
 
`addr1` varchar(20) default NULL, `addr2` varchar(20) default NULL, `addr3` varchar(20) default
 
NULL, `city` varchar(20) default NULL, `phone` varchar(12) default NULL, `email` varchar(100)
 
default NULL, `remarks` varchar(40) default NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8;


Index.php [Main or Home Page]
?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<html>
 
<head>
 
<meta name="description" content="Core php code for add, edit, view,delete" />
 
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
 
<title>Search Student Record</title>
 
</head>
 
<body>
 
<center><h1><u>Student Database</u></h1></center>
 
<form name="search" method="post" action="search.php">
 
<table style=" border:1px solid silver" cellpadding="10px" cellspacing="0px"
 
align="center">
 
<tr>
 
<td colspan="3" style="background:#0066FF; color:#FFFFFF; fontsize:
 
20px">Search</td></tr>
 
<tr>
 
<td>Enter Search Keyword</td>
 
<td><input type="text" name="search" size="40" /></td>
 
<td><input type="submit" value="Search" /></td>
 
</tr>
 
<tr>
 
<td colspan="3">&nbsp;</td></tr>
 
<tr bgcolor="#CCCCCC">
 
<th><a href="add.php">Add Record</a></th>
 
<th><a href="del.php">Delete Record</a></th>
 
<th><a href="del.php">Update Record</a></th>
 
</tr>
 
</table>
 
</form>
 
</body>
 
</html>


Search.php
?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
<?
 
mysql_connect("localhost");
 
mysql_select_db("test") or die("database could not connect ");
 
?>
 
<html>
 
<head>
 
<meta name="description" content="Core php code for add, edit, view,delete" />
 
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
 
<title>Search Student Record</title>
 
</head>
 
<body>
 
<center><h1><u>Student Database</u></h1></center>
 
<form name="search" method="post" action="search.php">
 
<table style=" border:1px solid silver" cellpadding="5px" cellspacing="0px"
 
align="center" border="0">
 
<tr>
 
<td colspan="3" style="background:#0066FF; color:#FFFFFF; fontsize:
 
20px">Search</td></tr>
 
<tr>
 
<td>Enter Search Keyword</td>
 
<td><input type="text" name="search" size="40" /></td>
 
<td><input type="submit" value="Search" /></td>
 
</tr>
 
<tr bgcolor="#666666" style="color:#FFFFFF">
 
<td>Roll & class</td>
 
<td>Name & Father's Name</td>
 
<td>&nbsp;</td>
 
<?
 
$search=$_POST["search"];
 
$flag=0;
 
$query="select * from student where name like '%$search%' ";
 
$result=mysql_query($query);
 
while ($row = mysql_fetch_array($result)) {
 
$flag=1;
 
echo "<tr ><td>",$row[0],", ",$row[1],"</td><td><a
 
href='view.php?roll=",$row[0],"'>",$row[2],", ",$row[3],"</a></td><td><a
 
href='edit.php?roll=",$row[0],"'>Edit</a> | <a
 
href='del.php?roll=",$row[0],"'>Delete</a></td></tr>";
 
}
 
if($flag==0)
 
echo "<tr><td colspan='3' align='center' style='color:red'>Record not
 
found</td></tr>";
 
?>
 
<tr>
 
<td colspan="3">&nbsp;</td></tr>
 
<tr bgcolor="#CCCCCC">
 
<th colspan="3" align="right"><a href="add.php">Add Record</a></th>
 
</tr>
 
</table>
 
</form>
 
</body>
 
</html>


View.php
?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
<?
 
mysql_connect("localhost");
 
mysql_select_db("test") or die("database could not connect ");
 
?>
 
<html>
 
<head>
 
<meta name="description" content="Core php code for add, edit, view,delete" />
 
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
 
<title>View Student Record</title>
 
</head>
 
<body>
 
<center><h1><u>Student Database</u></h1></center>
 
<?
 
$roll=$_GET["roll"];
 
$query="select * from student where roll='$roll'";
 
$result=mysql_query($query);
 
while ($row = mysql_fetch_array($result)) {
 
?>
 
<table style=" border:1px solid silver" cellpadding="5px" cellspacing="0px"
 
align="center" border="1">
 
<tr>
 
<td colspan="4" style="background:#0066FF; color:#FFFFFF; font-size:20px">VIEW
 
STUDENT DATABASE</td></tr>
 
<tr>
 
<td> Roll Number</td><td><? echo $row[0];?></td>
 
<td> Class</td><td><? echo $row[1];?></td>
 
</tr>
 
<tr>
 
<td> Name of Student</td><td><? echo $row[2];?></td>
 
<td> Father's Name</td><td><? echo $row[3];?></td>
 
</tr>
 
<tr>
 
<td>Sex</td><td><? echo $row[4];?></td>
 
<td>Address1</td><td><? echo $row[5];?></td></tr>
 
<tr>
 
<td>Address2</td><td><? echo $row[6];?></td>
 
<td>Address3</td><td><? echo $row[7];?></td></tr>
 
<tr>
 
<td>City</td><td><? echo $row[8];?></td>
 
<td>Phone</td><td><? echo $row[9];?></td></tr>
 
<tr>
 
<td>Email</td><td><? echo $row[10];?></td>
 
<td>Remarks</td><td><? echo $row[11];?></td></tr>
 
<tr>
 
</table>
 
<?
 
}
 
?>
 
<p align="center"><a href="index.php">Go Back to Home</a></p>
 
</body>
 
</html>


Add.php
?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
<?
 
mysql_connect("localhost");
 
mysql_select_db("test") or die("database could not connect ");
 
?>
 
<html>
 
<head>
 
<meta name="description" content="Core php code for add, edit, view,delete" />
 
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
 
<title>Add Student Record</title>
 
</head>
 
<body>
 
<center>
 
<h1><u>Student Database</u></h1>
 
</center>
 
<?
 
if($_POST["do"]=="store")
 
{
 
$roll=$_POST["roll"];
 
$class=$_POST["class"];
 
$name=$_POST["name"];
 
$fname=$_POST["fname"];
 
$sex=$_POST["sex"];
 
$addr1=$_POST["addr1"];
 
$addr2=$_POST["addr2"];
 
$addr3=$_POST["addr3"];
 
$city=$_POST["city"];
 
$phone=$_POST["phone"];
 
$email=$_POST["email"];
 
$remarks=$_POST["remarks"];
 
$query="insert into student
 
value($roll,'$class','$name','$fname','$sex','$addr1','$addr2','$addr3','$city','$phone','$
 
email','$remarks')";
 
mysql_query($query);
 
echo "<center>Successfully store in DATABASE</center>";
 
}
 
?>
 
<form name="add" method="post" action="add.php">
 
<table style=" border:1px solid silver" cellpadding="5px" cellspacing="0px"
 
align="center" border="0">
 
<tr>
 
<td colspan="4" style="background:#0066FF; color:#FFFFFF; fontsize:
 
20px">ADD STUDENT RECORD</td>
 
</tr>
 
<tr>
 
<tr>
 
<td>Enter Roll Number</td>
 
<td><input type="text" name="roll" size="20"></td>
 
<td>Enter Class</td>
 
<td><input type="text" name="class" size="20"></td>
 
</tr>
 
<tr>
 
<td>Enter Name of Student</td>
 
<td><input type="text" name="name" size="20"></td>
 
<td>Enter Father's Name</td>
 
<td><input type="text" name="fname" size="20"></td>
 
</tr>
 
<tr>
 
<td>Sex</td>
 
<td><input type="radio" name="sex" value="Male">
 
Male
 
<input type="radio" name="sex" value="Female">
 
Female </td>
 
<td>Address1</td>
 
<td><input type="text" name="addr1" size="20"></td>
 
</tr>
 
<tr>
 
<td>Address2</td>
 
<td><input type="text" name="addr2" size="20"></td>
 
<td>Address3</td>
 
<td><input type="text" name="addr3" size="20"></td>
 
</tr>
 
<tr>
 
<td>City</td>
 
<td><input type="text" name="city" size="20"></td>
 
<td>Phone</td>
 
<td><input type="text" name="phone" size="20"></td>
 
</tr>
 
<tr>
 
<td>Email</td>
 
<td><input type="text" name="email" size="20"></td>
 
<td>Remarks</td>
 
<td><input type="text" name="remarks" size="20"></td>
 
</tr>
 
<tr>
 
<td colspan="4" align="center"><input type="hidden" name="do" value="store">
 
<input type="submit" value="ADD RECORD"></td>
 
</tr>
 
</table>
 
</form>
 
<p align="center"><a href="index.php">Go Back to Home</a></p>
 
<?
 
include("search.php");?>
 
</body>
 
</html>


Edit.php
?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
<?
 
mysql_connect("localhost");
 
mysql_select_db("test") or die("database could not connect ");
 
?>
 
<html>
 
<head>
 
<meta name="description" content="Core php code for add, edit, view,delete" />
 
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
 
<title>Update Student Record</title>
 
</head>
 
<body>
 
<?
 
if($_POST["do"]=="update")
 
{
 
$roll=$_POST["roll"];
 
$class=$_POST["class"];
 
$name=$_POST["name"];
 
$fname=$_POST["fname"];
 
$sex=$_POST["sex"];
 
$addr1=$_POST["addr1"];
 
$addr2=$_POST["addr2"];
 
$addr3=$_POST["addr3"];
 
$city=$_POST["city"];
 
$phone=$_POST["phone"];
 
$email=$_POST["email"];
 
$remarks=$_POST["remarks"];
 
$query="update student set
 
name='$name',f_name='$fname',sex='$sex',addr1='$addr1',addr2='$addr2',addr3='$ad
 
dr3',city='$city',phone='$phone',email='$email',remarks='$remarks' where roll=$roll";
 
mysql_query($query);
 
echo "<center>Successfully Updated in DATABASE</center>";
 
include("search.php");
 
}
 
?>
 
<center>
 
<h1><u>Student Database</u></h1>
 
</center>
 
<?
 
$roll=$_GET["roll"];
 
$query="select * from student where roll='$roll'";
 
$result=mysql_query($query);
 
while ($row = mysql_fetch_array($result)) {
 
?>
 
<form name="update" method="post" action="edit.php">
 
<table style=" border:1px solid silver" cellpadding="5px" cellspacing="0px"
 
align="center" border="0">
 
<tr>
 
<td colspan="4" style="background:#0066FF; color:#FFFFFF; fontsize:
 
20px">ADD STUDENT RECORD</td>
 
</tr>
 
<tr>
 
<tr>
 
<td>Enter Roll Number</td>
 
<td><? echo $row[0];?>
 
<input type="hidden" name="roll" size="20" value="<? echo $row[0];?>"></td>
 
<td>Enter Class</td>
 
<td><input type="text" name="class" size="20" value="<? echo $row[1];?>"
 
disabled="disabled"></td>
 
</tr>
 
<tr>
 
<td>Enter Name of Student</td>
 
<td><input type="text" name="name" size="20" value="<? echo $row[2];?>"></td>
 
<td>Enter Father's Name</td>
 
<td><input type="text" name="fname" size="20" value="<? echo
 
$row[3];?>"></td>
 
</tr>
 
<tr>
 
<td>Sex</td>
 
<td><input type="radio" name="sex" value="Male" checked="checked">
 
Male
 
<input type="radio" name="sex" value="Female">
 
Female </td>
 
<td>Address1</td>
 
<td><input type="text" name="addr1" size="20" value="<? echo $row[5];?>"></td>
 
</tr>
 
<tr>
 
<td>Address2</td>
 
<td><input type="text" name="addr2" size="20" value="<? echo $row[6];?>"></td>
 
<td>Address3</td>
 
<td><input type="text" name="addr3" size="20" value="<? echo $row[7];?>"></td>
 
</tr>
 
<tr>
 
<td>City</td>
 
<td><input type="text" name="city" size="20" value="<? echo $row[8];?>"></td>
 
<td>Phone</td>
 
<td><input type="text" name="phone" size="20" value="<? echo
 
$row[9];?>"></td>
 
</tr>
 
<tr>
 
<td>Email</td>
 
<td><input type="text" name="email" size="20" value="<? echo
 
$row[10];?>"></td>
 
<td>Remarks</td>
 
<td><input type="text" name="remarks" size="20" value="<? echo
 
$row[11];?>"></td>
 
</tr>
 
<tr>
 
<td colspan="4" align="center"><input type="hidden" name="do"
 
value="update">
 
<input type="submit" value="UPDATE RECORD"></td>
 
</tr>
 
</table>
 
</form>
 
<? } ?>
 
<p align="center"><a href="index.php">Go Back to Home</a></p>
 
</body>
 
</html>


Del.php
?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?
 
mysql_connect("localhost");
 
mysql_select_db("test") or die("database could not connect ");
 
?>
 
<html>
 
<head>
 
<meta name="description" content="Php Code for View, Search, Edit and Delete
 
Record" />
 
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
 
<title>Add Student Record</title>
 
</head>
 
<body>
 
<?
 
$roll=$_GET["roll"];
 
$query="delete from student where roll=$roll";
 
mysql_query($query);
 
echo "<center>Successfully Deleted</center>";
 
include("search.php");
 
?>
 
</body>
 
</html>

How to send emails from localhost (Windows XP Apache/PHP Server)How to send emails from localhost (Windows XP Apache/PHP Server)

 https://plus.google.com/113677221098417166384/posts




Sometimes we may need to send emails in our local PHP projects. In order to do that, we may install a E-Mail server, but that could be a little bit tedious. The easiest alternative is using sendmail and the smtp server of any of your mail accounts (gmail, yahoo, hotmail, ETC).
In this example I’m showing how to configure sendmail to make it working with a Gmail account. But as I said you can make it working with any smtp server you have already.

1st step: Download sendmail

Download sendmail and extract all the files in the folder “C:\sendmail\”

2nd step: configure sendmail.ini

Open the file “C:\sendmail\sendmail.ini” and add the following params in the corresponding lines:
smtp_server=smtp.gmail.com
smtp_port=587
auth_username=your_address@gmail.com
auth_password=your_password
force_sender=your_address@gmail.com
?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
; configuration for fake sendmail
  
; if this file doesn't exist, sendmail.exe will look for the settings in
; the registry, under HKLM\Software\Sendmail
  
[sendmail]
  
; you must change mail.mydomain.com to your smtp server,
; or to IIS's "pickup" directory.  (generally C:\Inetpub\mailroot\Pickup)
; emails delivered via IIS's pickup directory cause sendmail to
; run quicker, but you won't get error messages back to the calling
; application.
  
smtp_server=smtp.gmail.com
  
; smtp port (normally 25)
  
smtp_port=587
  
; the default domain for this server will be read from the registry
; this will be appended to email addresses when one isn't provided
; if you want to override the value in the registry, uncomment and modify
  
default_domain=
  
; log smtp errors to error.log (defaults to same directory as sendmail.exe)
; uncomment to enable logging
  
error_logfile=error.log
  
; create debug log as debug.log (defaults to same directory as sendmail.exe)
; uncomment to enable debugging
  
;debug_logfile=debug.log
  
; if your smtp server requires authentication, modify the following two lines
  
auth_username=your_address@gmail.com
auth_password=your_password
  
; if your smtp server uses pop3 before smtp authentication, modify the
; following three lines
  
pop3_server=
pop3_username=
pop3_password=
  
; to force the sender to always be the following email address, uncomment and
; populate with a valid email address.  this will only affect the "MAIL FROM"
; command, it won't modify the "From: " header of the message content
  
force_sender=your_address@gmail.com
  
; sendmail will use your hostname and your default_domain in the ehlo/helo
; smtp greeting.  you can manually set the ehlo/helo name if required
  
;hostname=
 

3rd step: Configure php.ini

Open the php.ini, find the following lines and add the path to the sendmail executable file. Don’t forget to restart the Apache server after doing that.
 
?
1
2
3
; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").
; http://php.net/sendmail-path
sendmail_path = "C:\sendmail\sendmail.exe -t"

4th step: test it!

Just a little test to check if it’s actually working. Create a PHP script with the following code:


?
1
2
3
4
mail(
     'your_email@gmail.com',
     'Works!',
     'An email has been generated from your localhost, congratulati

all about software engineering how to be a developer

https://www.quora.com/Jimmy-Wales


  • correct use of the standard libraries and
  • some times you need individual solutions.
You should be able to analyze your own or others code. The Big-O-Notation is the standard method to describe the expected consumption of time or memory depending from the number of data. [3]

--------------------------------------------------

Top 10 Living Software Engineers in the World Today


  1. Steve McConnell – He wrote the bible, Code Complete.  Enough said. (Age:50)
  2. Linus Torvalds – He wrote and is the architect for one of the most used operating systems ever, Linux.  Oh, he did Git also. (Age: 43)
  3. Kent BeckTDD, Agile Manifesto Signatory, jUnit, XP. (Age: 52)
  4. Barry Boehm – Software Economics, COCOMO, Spiral Development (Age: 78)
  5. David Parnas – Invented Information hiding and de-coupling. (Age: 72)
  6. Grady Booch – Helped invent UML and RUP.  Seminal person in Software Architecture. (Age: 58)
  7. Martin FowlerAgile Manifesto Signatory, Refactoring, and wrote the classic Patterns of Enterprise ApplicationArchitecture. (Age: 50)
  8. Tim Berners-Lee – Invented the WWW for heaven’s sake. (Age: 57)
  9. Fred Brooks – Wrote THE classic, Mythical Man-Month and also a Turing award (Nobel Prize of Computing) winner. (Age: 81)
So, you’ll probably notice the list only has nine people (if you read this far).  I’ve included the best for last because he is also the most controversial.
Bill Gates (Age: 57)

http://itflow.biz/most-profitable-programming-languages/

job-count1-804x1024


profitable-languages-new


http://itflow.biz/web-developer-salary-ranking/
--------------------------------------------------------------------

http://itflow.biz/top-20-hottest-tech-skills/

8. Drupal Developer

drupal developer
[8] http://bit.up.krakow.pl/~sslomczynski/wordpress/?page_id=36

Salary: $100,000 to $130,000

Desirable skills: 3+ years experience with Drupal
____________________________

9. User Experience/User Interface Developers

user experience engineer
[9] http://edmondscommerce.github.io/web%20design/what-is-user-experience-why-bother.html

Salary: $110,000 to $130,000

Desirable skills: UX or UI experience,  HTML5/CSS3/JS + Ability to use tools such as Photoshop, Fireworks, Illustrator, LucidChart or Visio to produce high-level user interaction flows
____________________________

10. Augmented Reality Developeraugumented reality developer




[10] http://www.theguardian.com/technology/2010/mar/21/augmented-reality-iphone-advertising

Salary: $115,000 to $130,000

Desirable skills:  ARToolKit, Unity3D, Vuforia and Metaio
____________________________

11. Big Data Engineer

big data engineer
[11] http://www.ichimnetz.de/2014/05/news/big-data-auf-dem-vormarsch-22177/

Salary: $125,000 to $145,000

Desirable skills: Hadoop, Netezza and Cloudera.
____________________________

12. IT Project Manager


IT project manager
[12] http://blog.m-files.com/leveraging-m-files-enterprise-content-management-platform-effective-project-management/

Salary: $110,000 to $150,000

Desirable skills3+ years experience in managing team (work experience as Teamlead, SCRUM Master or similar)
____________________________

  1. Big Data

Big data’s is a definitely a buzzword, with no doubt. However now it’s also quickly becoming big business – from “nice to have” technology in last years, nowadays it evolved to “must have”  As many companies tries to turn consumer data into usable and actionable intelligence that will help them reduce costs and increase profits. Jobs requiring expertise in R, NoSQL, and MapReduce held high positions in salary rankings at around $115,000 annually, and other big data-related platforms and skills aren’t far behind.
  • Hot Big Data Skills: MapReduce | Hadoop | R | HBase | NoSQL

  1. Cloud Computing

Cloud computing was most probably buzzword of 2014. Whenever you look you can see cloud implementations. Perhaps you might be even a little tired of the term “cloud”, unless you’re in the job market, of course. Employers seem to understand and appreciate role of IT professionals with serious cloud computing skills, and they’re paying accordingly. For example, OpenStack experts currently draw an average salary of $107,000 per year.
  • Hot Cloud Skills: OpenStack | Cloudera | Azure | Amazon Web Services

  1. Information Security

Unlike Big Data and Cloud Computing, Security is mature subject. However still as much important as it was always and it doesn’t seem to change anyhow soon. In fact, many experts expect information security needs to increase as more and more devices — wearable technologies, appliances, cars, you name it — go online. Security remains a one of the most important challenge for businesses, governments, and individuals. If you know how to help protect those devices and/or the networks they operate on, you can be confident that most probably you will get new offering every week or so.
  • Hot Security Skills: Intrusion Detection | Intrusion Protection | Familiarity with operating consoles like Cisco ASA, Checkpoint, and Palo Alto

  1. Project Management

There will be always need for smart people who can manage complex, evolving technology, team of people and deliver within given time.  As number of carried IT project still growths demand for good managers increases simultaneously. As such, these people get paid well, very well. These days six-figure salaries are more of standard.  Especially if you know similar areas like Scrum, Kanban, and Waterfall.
  • Hot Project Management Skills: CMMI | Lean | Change Management

  1. Mobility

Mobile went wild. Today everything has its mobile versions – starting with websites, blogs, through games, application to end with dedicated apps only for devices with small screen. Therefore mobility experts and application developers are in high demand.  Candidates who have expertise on multiple mobile platforms are hired much faster however “multiple” has concrete value in theses case which is 2 – Apple iOS and Google’s Android as these two giants combine to power more than 90% of mobile devices.
  • Hot Mobility Skills: iOS and Android App Development | Mobile Security | Device Management

  1. Operating Systems

The old IT joke says that there are only 10 types of people. (If you don’t know answer let me explain that 10 is binary presentation of number 2, which means that there are actually only 2 kinds of people – these which understand binary presentation and which don’t). If would have ask first group (no-binary) which is the most common operating system probably their answer was Windows, or sometimes OS X. The other group knows that most of the servers run under Unix-based operating systems. If you know how to administrate Oracle, Solaris or HP blades you can easily earn around $105 000.
  • Hot OS Skills: Solaris 10/11 | Oracle SPARC | HP-UX 11i v3 & 11i v2 | TOGAF/ITIL/SOA frameworks | Virtualization

  1. Programming& Software Development

Although the most desirable languages sometimes change – programming remains a fundamental skill for IT, no doubt on that. To give you some insight on what is demand, according to HirringSolved.com IT recruiters conducted more than 1 300 000 social media queries for candidates with knowledge of MS/SQL in February ’14 only! In the same time Software engineer were searched more than 1 600 000 times…
  • Hot Programming & Development Skills: UML | Puppet | JDBC | Objective C

  1. Bonus“Soft” Skill: Fluency in Business-Speak

There was always a gap between IT and business department, therefore ability to speak “business” – the natural language for management, marketing, sales and other functional areas – will distinguish the IT stars from the rest of clerks. Combined with deep technical knowledge of one or more of mentioned above skills will ensure you long term assignment.
On the other hand, translation is usually needed in both directions. If you can clearly explain functional requirements to your strictly technical team you can also expect boost in your career. As information security executive J. Wolfgang Goerlich recently said: “The ability to effectively communicate never goes out of style. […] soft skills make or break your IT career.”
  • Hot Soft Skills: Presenting IT Topics to Non-IT Staffers | Writing | Public Speaking | Leadership | Team-Building
8 Desired Skills (2)


Thursday, 18 December 2014

How To Create Blogger Template From Scratch


 https://www.google.co.in/search?q=how+to+create+blogspot+template+from+scratch
Understanding the <b:section> and <b:widget> tags
Must read: Intro, Section and Widget attributes. This page gives a brief explanation of the Section and Widget parts of the template. Also the attributes of the <b:section> and <b:widget> tags are listed here which we will use later on.
Blogger Template Sections and Widgets
Fig.2 - Just a quick summary minus the attributes.
So I made some tests and this is the leanest code I can upload to Blogger. This, by the way, is based on the Simple template - well at least the first 15 or so lines.

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html>
<html b:version='2' class='v2' expr:dir='data:blog.languageDirection' xmlns='http://www.w3.org/1999/xhtml' xmlns:b='http://www.google.com/2005/gml/b' xmlns:data='http://www.google.com/2005/gml/data' xmlns:expr='http://www.google.com/2005/gml/expr'>
<head>
  <meta content='IE=EmulateIE7' http-equiv='X-UA-Compatible'/>
  <b:if cond='data:blog.isMobile'>
    <meta content='width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0' name='viewport'/>
  <b:else/>
    <meta content='width=1100' name='viewport'/>
  </b:if>
  <b:include data='blog' name='all-head-content'/>
  <title><data:blog.pageTitle/></title>
  <b:skin>
  </b:skin>
</head>

<body>
  
  <b:section id='header' class='header' maxwidgets='' showaddelement='yes'>
  </b:section>

</body>
</html>
Fig. 3 - Simplest template code.

 http://postoneeighth.blogspot.in/2012/09/creating-your-own-blogger-template-from.html







<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html>
<html xmlns='http://www.w3.org/1999/xhtml' xmlns:b='http://www.google.com/2005/gml/b' xmlns:data='http://www.google.com/2005/gml/data' xmlns:expr='http://www.google.com/2005/gml/expr'>
  <head>

    <b:include data='blog' name='all-head-content'/>

<title>
      <b:if cond='data:blog.pageType == &quot;index&quot;'>
        <data:blog.pageTitle/>
        <b:else/>
        <b:if cond='data:blog.pageType != &quot;error_page&quot;'>
          <data:blog.pageName/> | <data:blog.title/>
          <b:else/>
          Page Not Found | <data:blog.title/>
        </b:if>
      </b:if>
    </title>

    <b:skin><![CDATA[

body {
background:white;
color:black;
}
#Navbar1 {dispaly:none!important;}
]]></b:skin>

</head>
<body>

  <b:section class='navbar' id='navbar' maxwidgets='1' showaddelement='no'>
<b:widget id='Navbar1' locked='true' title='Navbar' type='Navbar'/>
</b:section>

</body>
</html>
In the above basic coding, you'll see that there are XML and HTML tags in the starting which means that this is built with XML and HTML. The main extension for this coding will be .XML. If you copy the above coding and paste it with the whole coding of a template then it will be saved and will show nothing on blog because this is simple blank HTML page. Let's understand the basic structure.

1. XML and HTML tags : As I already told you that XML and HTML tags are the main tags in which whole template will be stored. If we want to save this template in computer then we'll choose .XML extension while saving because blogger supports only .XML file templates.

2. Long <title> Coding : If you look in the title code below <head> you'll see long coding between <title> tag. Basically, That is customized title coding which has many benefits. We've used conditional tags to customize this title coding. The first condition tells that if someone opens the homepage or index main page then it will write the blog title as title of the webpage. Second condition is to show the post or page title first and show blog title after post or page title. In the last, there is 404 error page title coding.

3. <b:skin> Tag For Storing Stylesheet : There is additional built in tag for blogger templates to use <b:skin> tag with CDATA for storing the whole CSS or stylesheet of the blog. In these tags, you'll only see CSS which is being used in the whole blog. So, every CSS which you'll write should be placed in these tags.

4. <b:section> Tags For Widgets : In blogger, we use these tags to create widgets. Most important things like Blog Title and Content are done by implementing widgets in templates. In short, There are default widgets which are for Header and Blog Content which we use while creating template. For creating widgets, we should cover them with <b:section> tags which will help us to prepare layout page.

Step 3. Creating Header 

After learning the basic structure, let's get started by creating header of blog. Basically, There are only two important things to create a blogger template. First one is Header and second one is Blog Content. Other things are also important but these are most ones. We'll use custom Header widget and will customize it according to our needs. Basically, Header is a widget and you know for creating widget, we should create section for a single or multiple widgets. Copy the code below and paste it anywhere in the <body> of template where you want to display Header widget.
 <b:section class='header' id='header' maxwidgets='1' showaddelement='no'>
        <b:widget id='Header1' locked='true' title='' type='Header'></b:widget>
</b:section>
The above coding is not complete coding of Header but when you'll integrate the above coding in template then it will automatically become longer. Save this template, reload the Edit HTML page and you'll see expand arrow in the left side of <b:widget> tag. Blogger will automatically write the default coding on it. So, let's understand this header coding.

1. <b:section> having class='header' and id='header' : First of all, in the section tag, you'll see class='header' and id='header' which are common CSS class and id tags. So, by the help of these tags, you can do customization of header like giving specific width, height, margin, padding, font size, color etc to the header section only.

2. <b:section> having maxwidgets='1' : I don't need to explain these simple things, but for totally newbies I'll explain it. There is another XML tag of blogger which is maxwidgets='1' by this, we can simply set the number of maximum widgets in that section just replacing the number 1.

3. <b:section> having showaddelement='no' : This is just another simple tag by which we can disable or enable the Add a Gadget option.

4. <b:widget> having id='Header1' : In the header widget, there is CSS id tag by which we customize the header widget with CSS.

5. <b:widget> having locked='true' : This tag allows you to lock and unlock widgets easily by choosing true or false. When the widget is locked, one can't easily edit that through layout page.

The current settings for this header widget and section are fine so we'll not edit them. Below, I'm going to give you class and ID CSS tags which will help you to customize header widget. Simply, add this below CSS between <b:skin> tag and fill them with your own properties.
#header {  }

#header h1 {  }

#header h1 a {  }

#header .description {  }

Step 4. Creating Pages Menu Widget

I forgot to mention the pages menu widget which is also important for creating menu. That kind of menu only displays the those links which are actually pages made in blogger blog. In default blogger templates, it's mostly used so here I'm going to teach you how can we implement them in our blogs. I'll just give you default XML and HTML coding and will show you way to design that with CSS. If you're well known with HTML and CSS then you can easily make custom menu there anywhere in the template. But for this pages menu, you might face problem. Let's get started.
This pages menu widget is also done by creating widget section and widget. So, below I'm going to give you another code which will be having section tags and there will be page list widget which is the main thing. Just put the below coding anywhere where you want to show up that pages menu widget. 
 <b:section class='tabs' id='crosscol' maxwidgets='1' showaddelement='yes'>
        <b:widget id='PageList1' locked='false' title='Pages' type='PageList'>
       </b:widget>
</b:section>
As we did in Header widget, this is also just a little piece of tags which will automatically complete itself with the default coding. For the customization, it's simple you can just take ID and Class tags from the above code and start writing your own CSS for them. But, This time I'm also going to give you CSS empty tags in which you've to fill properties according to your needs and design that better.
.tabs {  }
#corsscol {  }
#PageList1 {  }
#PageList1 ul {  }
#PageList1 ul li {  }
#PageList1 ul li a {  }

Step 5. Creating Blog or Content Widget

This is the main thing should is important most of all. In blogger, we create a default widget which is actual posts widget. In the layout pages, you might have seen the big widget named Blog Posts. We can easily create default blog posts widget with a bit of coding but customizing that according to our needs can be little difficult. First of all, open the html editor in blogger and paste the following blog posts widget code there.
<b:section class='main' id='main' preferred='yes' showaddelement='no'>
 <b:widget id='Blog1' locked='true' title='Blog Posts' type='Blog'>
 </b:widget>
</b:section>
Just like other widgets, we've also created section for that blog posts widget. After saving this widget in template, reload the html editor it will gain default coding of blog posts widget automatically. Here, get started in customizing the posts section according to your needs. Look at the class and id tags and write CSS for those tags to beautify posts area. When you'll expand blog posts widget, you'll get many <b:includable> tags that are actually in posts area. There will be specific includable tag having id='post' and var='post'. If you expand that includable tag then it will show up the coding of posts area only where you can do customizing easily.

Step 6. Creating Custom Gadget Area Like Sidebar and Footer

The above five steps will get you a simple template but creating custom gadgets area can be useful like making sidebar, footer and other gadget necessary gadget areas. So, in this step we're going to learn that how can we easily create custom gadgets section in blogger layout. We'll just write <b:section> tag in which we can add widgets as more as we want. Go to html editor and paste the following code anywhere you want to create the gadgets area or section.
<b:section class='' id='' maxwidgets='' showaddelement='yes'>

</b:section>
There is nothing special then <b:section> tags in the above coding. Class and ID tags are empty where you can add your own custom names to call the CSS for that section. You can use class and ID to call CSS and beauty that gadgets section by adding any width, height, padding, margin etc. Another tag, maxwidgets='' is also in which you write any maximum number like 10 so that section wouldn't contain more than 10 widgets. If you want to show Add a Gadget option in layout then remain the yes in the showaddelement tag otherwise overwrite it with no.

Step 7. Setting up Layout Page

While creating template, also take care of layout page in blogger blog because that page depends on the template of a blog. If you do the things correctly then it won't get messed up but if you're facing problem then we've solution for this. We can rearrange the widgets and gadget sections there through using simple CSS. And for what, I've already written great post on fixing blogger layout page messed up. For rearranging the widgets in layout page, we'll use CSS and it will be like this. 
body#layout #widgetID { The Properties For Widget In Layout Page Goes Here }
body#layout #widgetID2 { The Properties For Widget In Layout Page Goes Here }
body#layout #widgetID3 { The Properties For Widget In Layout Page Goes Here }
body#layout #widgetID3 { The Properties For Widget In Layout Page Goes Here } 

 Advanced Guide

Anyone who has basic knowledge of web designing can develop blogger template just by using simple HTML and CSS. Newbies might face problem in understanding the structure of blogger template but if you keep doing practice then you in a few days, you can be expert in that. Those web designers who can create HTML Templates or any other blogging platform themes then I don't think they're going to face any problem. Even designing blogger templates is one of the most easiest platforms than others. 
Above we've only created the simple blogger template which contains header, pages menu and blog posts. There is no sidebar and footer in the above template. You can make sidebar by giving specific width to posts widget, float blog posts widget to left and create another section which will be sidebar. You'll need to float sidebar in right and also give such width to those blog posts and sidebar sections that these both should suite on the area. You can do many more experiments with blogger template designs and also you can cover each widgets section with specific HTML div tags. 
While creating blogger templates, sometimes I make use of Inspect Element in Google Chrome which is common coding tool and it helps to edit any webpage. It will also help you to find the specific Class and ID tags of anything and you can customize them through CSS.

best blogger templates best of best

best fo best http://www.cssauthor.com/free-responsive-blogger-templates/
 http://www.freshdesignweb.com/free-blogger-templates-2014.html
http://www.lovelytemplates.com/wordpress-themes/free-themes

http://helplogger.blogspot.in/2014/09/where-to-find-free-blogger-backgrounds-textures.html

Pixel Blog Responsive Blogger Template

Pixel Blog Responsive Blogger Template Free Download
Pixel Blog Responsive Blogger Template Free Download

Pixel Blog is a new Responsive blogger template which is specially built for Magazine type blog/website. It has a new fresh UI and fully 100% responsive design. Some new colors, plugins and layout is combined to make this awesome blogger template. Pixel Blog template is compatible with smartphones, tablets, PCs etc. 




Squared Portfolio Blogger Template

Squared Portfolio Blogger Template

Squared Portfolio is a unique and professional blogger template pack with alot of features specially made for the Portfolio/Personal sites which want to describe about their company or about. It is fast, unique and fully responsive in design built with CSS3, HTML5 and jQuery.




Red Hood Free Portfolio Blogger Template

templateism.com/blogger-templates/RedHood-Portfolio-Framework.zip

Luna Folio Responsive Portfolio Blogger Template

Luna Folio is a responsive blogger theme specially made for corporate and portfolio based blogs. It is light weight theme which is easy to use and fast to load. It is made with latest code’s to make it more stunning. It also have a smooth parallax effect which attract your viewers. 



http://designscrazed.org/best-free-blogger-templates/

http://www.bestbloggertemplates.net/

http://www.soratemplates.com/

Wednesday, 10 December 2014

how to make money with facebook

Build Your Mailing List

Since most businesses make money from their mailing list, let’s look at some specific ways you can grow your mailing list on Facebook to increase your online income.
  1. Post new signup incentives (free e-books, reports, whitepapers, discounts, etc.) on your Facebook wall. For extra exposure, promote your post using the traditional Facebook Ads interface so you can target your post to the Facebook audience most likely to sign up and later become customers. Continue the ad as long as you continue getting signups.
  2. Look for opportunities in relevant Facebook groups to share your signup incentives. Start by joining groups where your target customers are active. Look at the question they post most frequently. Create signup incentives that answer those questions and leave a short, informative answer with a link to your squeeze page so people can learn more. .
  3. Install apps from your email service provider to put an opt-in form on your Facebook page as a custom tab. ESPs that offer Facebook apps include Aweber, MailChimp, GetResponse, Constant Contact, and iContact.
  4. Use the Woobox HTML tab app build an iframe on your Facebook page. You can easily add your mailing list squeeze page and have it show as one of your four custom tabs beneath your cover photo.

facebookappsFacebook Apps & Integrations

If you want to make money directly off of Facebook, you will want to turn your Facebook page into a sales machine. Here are some apps that allow you to sell from your Facebook page or easily lead your Facebook fans to your online store.
  1. Beetailer. Helps you import your existing online store into Facebook.
  2. Show & Sell. Sell your products or services on Facebook with an easy-to-configure social mini-store.
  3. Storefront Social. Enables businesses to showcase their products or services on their Facebook page.
  4. ShopTab. One of the leading Facebook store applications.
  5. Ecwid. Formerly Payvment, an embeddable centrally managed storefront that works on Facebook, WordPress, Joomla, Drupal, Squarespace, and additional platforms.
  6. Integrations with Facebook. Facebook store applications and integrations for Shopify users.
  7. StoreYa. Facebook store application and integration for Magento users.
Another way to encourage sales is by offering deals, coupons, and discounts. Here are some apps that make it easy to give your fans exclusives that will drive them to buy.
  1. Deal Share. Create and launch a viral deal on your Facebook Page where you can set the number of registrations required to unlock a group discount.
  2. Exclusive. Visitors unlock a “fan exclusive” download by sharing a wall post .
  3. Fan Coupon. Convert visitors into fans of your Facebook page by rewarding them with an exclusive coupon or invitation to a special event.
  4. Coupons & Vouchers. Create fan-only coupons with unique one per user custom coupon codes.
  5. Deals. Require payment via Paypal to access an offer.
  6. Group Deals. Create coupons that are available only after a certain number of people request the coupon.
  7. Facebook Coupon App. Reward your fans and generate sales revenue with Facebook exclusive offers.
For businesses who just want leads, there are some apps that let Facebook visitors contact you for more information, without having to trust them to find your message button.
  1. InlineVision Contact Form. Give fans an easy way to contact you with our Contact Form for Facebook and get the submissions delivered directly to your email Inbox.
  2. Pagemodo Contact Form. A contact form is a quick and easy way for visitors and fans to contact you. They fill in information on your tab and you’ll get alerted with an email.
  3. North Contact. North Contact is a free social CRM extension for North Social’s apps. Perfect for creating user forms, list management, as well as outbound emails and autoresponders
 -------------------------------------------
http://monetizepros.com/blog/2013/101-ways-to-make-money-on-facebook/ 

Access denied for user ‘root’@’localhost’ (using password: NO)

For wamp and xampp server Access denied for user ‘root’@’localhost’ (using password: NO)

or Access denied for user ‘root’@’localhost’ (using password: yes)



  1. Go to file C:\wamp\apps\phpmyadmin3.2.0.1\config.inc.php (I guess you would replace "wamp" with the name of your server if you're not using Wamp Server)
  2. Find the line $cfg['Servers'][$i]['password']='' and change this to
    $cfg['Servers'][$i]['password']='NO'
  3. Try opening phpMyAdmin again, and hopefully the message will now read "Access denied for user 'root'@'localhost' (using password: YES)
  4. Now change the password in the above line to 'yourpassword' (whatever you had set it to before)
Hope this helps somebody.

Now find $cfg['Servers'][$i]['AllowNoPassword'] = true; and replace it by $cfg['Servers'][$i]['AllowNoPassword'] = false;

i got the same error when i install xampp on my windwos7 system. solution i found is: in config.inc.php file i replaced the $cfg['Servers'][$i]['auth_type'] = 'config'; to $cfg['Servers'][$i]['auth_type'] = 'cookie'; then everything working fine... test your luck if have same issue..


or

1. xampp/htdocs/xampp/cds.php

change line 4 to: mysql_connect("localhost","root","enter password here");
change line 64 to: if(!mysql_connect("localhost","root","enter password here"))
-----------------------------------------------

I solved with following steps..

Step1: Go to Control Panel
Step2: Click Administrator Tools
Step3: Click Services
Step4: Find MySQL Service
Step5: Right click and click stop
Step6: Now Restart Wampserver