<?php
//implement hook_menu()
function Users_menu() {
$items['userlogin'] = array(
'title' => t('Login System'),
'page callback' => 'UserLogin_block_view',
'access callback' => TRUE,
);
}
// create block
function UserLogin_block_view($block_name = '')
{
$form = drupal_get_form('user_login_block');
$block = array
(
'content' => $form,
);
return $block;
}
// flush cache
?>
Computer Scientist
Monday, 2 March 2015
Sunday, 1 March 2015
PHP in Action I just read this book is Awesome
To keep programming productive and enjoyable, state-of-the-art practices and principles are essential. Object-oriented programming and design help manage complexity by keeping components cleanly separated. Unit testing helps prevent endless, exhausting debugging sessions. Refactoring keeps code supple and readable. PHP offers all this-and more.
PHP in Action shows you how to apply PHP techniques and principles to all the most common challenges of web programming.
Purchase of the print book comes with an offer of a free PDF, ePub, and Kindle eBook from Manning. Also available is all code from the book.
I am what I read for Dries Buytaert
Almost every night before bed, I spend time reading. I love the feeling of falling asleep a little wiser than when I woke up. And often I read in the morning too. I read about photography, technology, investing, business, and more.
I love reading anything that provides a "mental workout"; articles or blog posts that stretch my mind or that point me in a different direction, that help me articulate my own emotions and my thoughts, or that make my imagination travel in time and space. Changing minds is changing lives. Reading makes me who I am.
While reading begets more reading, I love writing down my own thoughts as well, and that is what I decided to do this night. Sleep well!
Thursday, 26 February 2015
Laravel Best Books
Laravel Best Book By reviews 2014
- Code Bright by (Dale Rees)
- Impleminting Laravel by (Chris Fidao)
- Laravel 4 cookbook by (christopher pitt)
- Laravel Testing Decode by (Jeffrey Way)
- From Apprentice To Artisan by (Taylor otwell)
Create a Website Search in PHP
// first create a HTML form
--create a new file search.php
<form method="post" action="search.php">
<input type="text" class="srch" name="query" placeholder="Enter KeyWord" size="44" maxlength="500" required>
<input type="submit" name="submit" class="btn" value="Search">
</form>
-- add php in search.php
<?php
-- add database connection in search.php
include_once("control.php");
$obj= new Control();
$obj->connect();
-- using $_POST variable form submit and get data
if (isset($_POST['submit'])) {
$query=$_POST['query'];
$obj->search($query);
}
?>
-- and my class file control.php
<?php
class Control{
public $localhost ="localhost";
public $root ="root";
public $sdb ="shoppingcart";
protected $connection;
function connect(){
$connection=mysql_connect($this->localhost,$this->root)or die(mysql_error());
$connection=mysql_select_db($this->sdb)or die(mysql_error());
}
function search($query){
$fields = array('name', 'address', 'city', 'state', 'zip');
$sql=mysql_query("SELECT * FROM `addproduct` WHERE pname like '%$query%' OR bname like '%$query%' OR price like '%$query%' OR cat like '%$query%'")or die(mysql_error());
$count=mysql_num_rows($sql);
if ($count>0) {
while ($row=mysql_fetch_array($sql)) {
$id=$row['id'];
echo "<br><br><br><table style='margin-left:12px;'><tr><td style='color:blue; font-size:20px; text-transform:capitalize;'><a href='product.php?id=$id'>".$row['pname']."</a></td></tr><tr><td style='text-transform:capitalize;'>Brand Name: ".$row['bname']."</td></tr><tr><td style='color:green;'>Price: $".$row['price']."</td></tr></table>";
}
}
if (empty($count)) {
echo"<p style='margin-left:12px;'>Product Are Not Found</p>";
}
}
}
?>
--create a new file search.php
<form method="post" action="search.php">
<input type="text" class="srch" name="query" placeholder="Enter KeyWord" size="44" maxlength="500" required>
<input type="submit" name="submit" class="btn" value="Search">
</form>
-- add php in search.php
<?php
-- add database connection in search.php
include_once("control.php");
$obj= new Control();
$obj->connect();
-- using $_POST variable form submit and get data
if (isset($_POST['submit'])) {
$query=$_POST['query'];
$obj->search($query);
}
?>
-- and my class file control.php
<?php
class Control{
public $localhost ="localhost";
public $root ="root";
public $sdb ="shoppingcart";
protected $connection;
function connect(){
$connection=mysql_connect($this->localhost,$this->root)or die(mysql_error());
$connection=mysql_select_db($this->sdb)or die(mysql_error());
}
function search($query){
$fields = array('name', 'address', 'city', 'state', 'zip');
$sql=mysql_query("SELECT * FROM `addproduct` WHERE pname like '%$query%' OR bname like '%$query%' OR price like '%$query%' OR cat like '%$query%'")or die(mysql_error());
$count=mysql_num_rows($sql);
if ($count>0) {
while ($row=mysql_fetch_array($sql)) {
$id=$row['id'];
echo "<br><br><br><table style='margin-left:12px;'><tr><td style='color:blue; font-size:20px; text-transform:capitalize;'><a href='product.php?id=$id'>".$row['pname']."</a></td></tr><tr><td style='text-transform:capitalize;'>Brand Name: ".$row['bname']."</td></tr><tr><td style='color:green;'>Price: $".$row['price']."</td></tr></table>";
}
}
if (empty($count)) {
echo"<p style='margin-left:12px;'>Product Are Not Found</p>";
}
}
}
?>
How to make Login System in php
Create a html Login Form
--create a new file login.php
<form class="form-1" action="login.php" method="post">
<input type="text" name="email" placeholder="Email" required autocomplete="off">
<input type="password" name="pass" placeholder="Password" required >
<button type="submit" name="submit">
</form>
-- include class file control.php in login.php
-- and create a new object $obj and run connect() function for database connection
// add database connection in login.php
<?php
include_once("control.php");
$obj= new Control();
$obj->connect();
?>
// get data using $_POST variable in login.php
<?php
if (isset($_POST['submit'])) {
$email = $_POST['email'];
$pass = $_POST['pass'];
$pass = md5($pass);
$obj->login($email,$pass);
}
?>
// This is My class file control.php
<?php
class Control{
public $localhost ="localhost";
public $root ="root";
public $sdb ="shoppingcart";
protected $connection;
function connect(){
$connection=mysql_connect($this->localhost,$this->root)or die(mysql_error());
$connection=mysql_select_db($this->sdb)or die(mysql_error());
}
function login($email,$pass){
session_start();
$sql=mysql_query("SELECT * FROM reg WHERE email='$email' AND pass='$pass' LIMIT 1")or die(mysql_error());
$count=mysql_num_rows($sql);
if ($count>0) {
$row=mysql_fetch_array($sql);
$_SESSION['email']=$row['email'];
$_SESSION['pass']=$row['pass'];
header("location:index.php");
exit();
}
}
}
?>
--create a new file login.php
<form class="form-1" action="login.php" method="post">
<input type="text" name="email" placeholder="Email" required autocomplete="off">
<input type="password" name="pass" placeholder="Password" required >
<button type="submit" name="submit">
</form>
-- include class file control.php in login.php
-- and create a new object $obj and run connect() function for database connection
// add database connection in login.php
<?php
include_once("control.php");
$obj= new Control();
$obj->connect();
?>
// get data using $_POST variable in login.php
<?php
if (isset($_POST['submit'])) {
$email = $_POST['email'];
$pass = $_POST['pass'];
$pass = md5($pass);
$obj->login($email,$pass);
}
?>
// This is My class file control.php
<?php
class Control{
public $localhost ="localhost";
public $root ="root";
public $sdb ="shoppingcart";
protected $connection;
function connect(){
$connection=mysql_connect($this->localhost,$this->root)or die(mysql_error());
$connection=mysql_select_db($this->sdb)or die(mysql_error());
}
function login($email,$pass){
session_start();
$sql=mysql_query("SELECT * FROM reg WHERE email='$email' AND pass='$pass' LIMIT 1")or die(mysql_error());
$count=mysql_num_rows($sql);
if ($count>0) {
$row=mysql_fetch_array($sql);
$_SESSION['email']=$row['email'];
$_SESSION['pass']=$row['pass'];
header("location:index.php");
exit();
}
}
}
?>
How to make a module in drupal
Steps
1) Create a folder in drupal directory
C:\wamp\www\drupal\sites\all\modules
--folder name firstmodule
2) Create a two File .info and .module file
-- Your .info and .module file name same as your folder name
firstmodule.info file Look
name = First Module
description = My First Module In Drupal
core = 7.x
firstmodule.module file Look
-- create a hook menu in my module file
function Users_menu() {
$items['testing'] = array(
'title' => t('My First Module In Drupal'),
'page callback' => 'testing_module_block_view',
'access callback' => TRUE,
);
return $items;
}
-- create a block using hook_block_view
function testing_module_block_view($block_name = '')
{
-- create a form using drupal_get_form
$form = drupal_get_form('Testing_form');
$block = array
(
'content' => $form,
);
return $block;
}
-- your custom function
function Testing_form(){
$Hello = "Hello World";
return $Hello;
}
// My Module its Complete
-- go and active your module
Subscribe to:
Posts (Atom)
