Showing posts with label php. Show all posts
Showing posts with label php. Show all posts

Wednesday, 20 November 2013

PHP MYSQL Login and Registration using Functions

// siddhu vydyabhushana // 140 comments
Today am going to explain you the code for Login and Registration using functions in php,mysql . The best methodology in any language is using Object Oriented Principles.Dealing with classes, objects very easy to manipulate information. Below code for how to develop user registration and login  form in php.

login and registration form using php functions

This tutorial contain only 2 files  functions.php and login_reg.php

Database
simple database with 4 fields id, name, email, password

CREATE TABLE IF NOT EXISTS `javatyro_registration` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` text NOT NULL,
  `email` varchar(100) NOT NULL,
  `password` varchar(100) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=8 ;

Functions.php
class name profile() -> object $profile

<?php
class profile
{
public function db()
{
mysql_connect("localhost","root","")or die(mysql_error());
mysql_select_db("demos") or die(mysql_error());
}
public function registration($name,$email,$password)
{
$query=mysql_query("SELECT * FROM javatyro_registration where email='$email' ");
if(!$query)
{
$query=mysql_query("INSERT INTO javatyro_registration VALUES ('','$name','$email','$password')");
if($query>0)
echo "<h2> hiee..<font color=green>".$name."</font>
</h2><br/><font color=green> You Registered Successfully</font>";
else
echo "<font color=red>failed</font>";
}
else
echo "<h3><font color=red>Sorry,Already Registered</font></h3>";
}
public function login($email,$password)
{
$query=mysql_query("SELECT name FROM javatyro_registration where 
email='$email' AND password='$password' ");
$query=mysql_fetch_array($query);
if($query>0)
echo "<h2> hiee..<font color=blue>".$query['name'].
"</font></h2><br/><font color=green>Login Success</font>";
else
echo "<font color=red>failed</font>";
}
}
?>
login_reg.php
code for login , registration from including php code
<!Doctype>
<html>
<head>
<?php include_once 'functions.php';?>
<style>
body{font-family:segoe ui}
.registration{background:#eeeeee;padding:20px}
.login{background:pink;padding:20px}
input{padding:5px}
</style>
</head>
<body>
<center>
<h2>JAVATYRO-<a href="http://www.facebook.com/siddhucse"
 target="_blank">SIDDHU VYDYABHUSHANA</a></h2>
<table>
<tr>
<td>
<div class="registration">
<form method="POST" action="login_reg.php">
Full Name:<br/>
<input type="text" name="name" required><br/>
Email:<br/>
<input type="email" name="email" required><br/>
Password:<br/>
<input type="password" name="pass" required><br/><br/>
<input type="submit" value="Register">
</form>
</div>
</td>
<td>
<div class="login">
<form method="POST" action="login_reg.php">
Email:<br/>
<input type="email" name="login_email" required><br/>
Password:<br/>
<input type="password" name="login_pass" required><br/><br/>
<input type="submit" value="Login">
</form>
</div>
</td>
</tr>
</table>
<?php
if($_SERVER['REQUEST_METHOD']=="POST")
{
//object for class
$profile=new profile();
//database calling
$profile->db();

//registration function calling
if(isset($_POST['name']) && isset($_POST['email'])
&& isset($_POST['pass']))
$profile->registration($_POST['name'],$_POST['email'],$_POST['pass']);

//login function calling
if(isset($_POST['login_email']) && isset($_POST['login_pass']))
$profile->login($_POST['login_email'],$_POST['login_pass']);

}
?>
</center>
</body>
</html>
How to add new Function:

public function function_name(argument1,argument2)
{
//query to execute
}
I hope you enjoyed my tutorial..
Read More

Monday, 4 February 2013

3 simple Steps to Create PHP code to Excel SpreadSheets

// siddhu vydyabhushana // 4 comments
   As per many request am telling you that this tutorial designed.Spread sheets are simple and easiest sheets which can arrange data in order.Follow below steps for convertion.




                     3 simple Steps to Create PHP code to Excel SpreadSheets 


STEP-1: TYPE OF THE CONTENT 

what type of content its is, it may be pdf or it may be word or excel


        header("Content-Type: application/vnd.ms-excel");

"application/vnd.ms-excel" tells you the content type

STEP-2: ADDING THE DATA

echo "name" ."\t". "ph-no" ."\t". "state"."\n";
echo "siddhu" ."\t". "9533754145" ."\t". "andhra"."\n";

"\t" - gives you tab Space 
"\n"-new line output

name    ph-no       state
siddhu 9533754145 andhra


STEP-3 :DOWNLOAD EXCEL SHEET

header("Content-disposition: attachment; filename=spreadsheet.xls");

data added and header added by writing above lines you can convert php to excel

THANQ
siddhu vydyabhushana.
Read More

Friday, 30 November 2012

Top Free Clone Scripts

// siddhu vydyabhushana // Leave a Comment
its was very interesting and too fuuny to hear ..for web designers, programmers it was sweet new also ,
the social networking sites was developed by some great creative programmers, designers they take help of ajax,php,mySql,jQuery.

Thats why i blogged it with live previews..

You can download it also to do experiments!!!!!!


FACEBOOK CLONE SCRIPT:





   live Preview: Live      Download  :  download


GMAIL CLONE SCRIPT:

Live Preview:   live                  Download:       dwnld


TWITTER CLONE SCRIPT


Lovdbyless : Live Preview Download

elgg : Live Preview Download
Read More

Monday, 1 October 2012

How to use MSAccess as Database

// siddhu vydyabhushana // 4 comments

Microsoft Access is one of the part of  MSOFFICE  .It is a database management system from microsoft that combines the relational microsoft jet database engine with a graphical user interface and software development tools. we can also use this as oracle ,mysql database.... in first i used this one but present i addicted to php......for beginners it is very useful  and interesting no use to write code for creating tables.....................


Login and Regisration Using Jsp:-


NAME YOUR DATABASE:  open MSACCESS in microsoft office 
                              
         START->>>MICROSOFT OFFICE-->>msaccess

after that choose blank database and save it with example.accddb extension


CREATE TABLE :   After RIGHT CLICK ON table1 and take Design View to create table.there is no need to write commands create table.


after clicking design view u can edit like this

and rename table1 with whatever u like 

u create table and save the database in certain folder i am going explain to place it in tomcat   server.for example if u name as example.accdb...u need to place it in
folder of web apps


CONFIGURATION: 
                         Go to Control Panel -->and choose small icons instead of lage->> at next 
click on Administrative Tools   and select Data Sources


Click on Add to add database ---------------------------------------------------------



add *.mdb ,*.accdb Microsoft Access Driver and Finish.

in Data Source Name u choose name Whatever u like it will be used to call database in jsp.

                                                   
Connection con=DriverManager.getConnection("jdbc:odbc:example","","");


on 4 line Database:
                                Select and set path where database was u successfully configured 
if u have any doubts regarding to this topic leave doubts..





Siddhu vydyabhushana please subscribe to get this type posts to ur mail ...





Read More

Saturday, 22 September 2012

jQuery Cook Book for beginners

// siddhu vydyabhushana // 1 comment
hello , i know u shocked because u may waiting for this type of material ,it was really help full to beginners ,already i completed and made tutorials on this in my last posts also...
while reading if u feel bore don't throw away ,leave present chapters and take another chapter..not only this one all 0'Really books are "REALLY SUPERB"..if u are interested download it by below link..

LAST POSTS RELATED TO JQUERY:

JQUERY PART-1

JQUERY PART-2

JQUERY PART-3

                                                         
                                                    

DOWNLOAD BOOK:      HERE(AITAMELEARNING.BLOGSPOT.COM)

Read More

Friday, 21 September 2012

Live check availability using PHP

// siddhu vydyabhushana // Leave a Comment
today am going to learn trick on live check availability   .Before going to learn u need to have some grip on database management,PHP.
so get ready to learn 1
                      2
                      3
                      Lets go.................

whatever you are going to enter text(email id) 
u get the text and check with the database data.php code for checking

<?phpinclude 'database.php';
if(isSet($_POST['username'])

{$sql=mysql_query('SELECT * FROM registration'); 
while($row=mysql_fetch_array($sql)){$get=$row['regusername'];$p=$_POST['username'];if($p==$get)echo "<big><font color='RED'>Not available";elseecho "<big><font color='green'>Available";}}?>
DATABASE CONNECTION :

<?phpmysql_connect("localhost","USERNAME","PASSWORD");mysql_select_db("DATABASE NAME");?>
HTML CODE :

<style>
#main
{
margin-left:275;
width:600px;
padding:10px;
border:solid 1px blue;
background:#eeeeee;
}
</style>
<div id="main">
<b>Already 'vydyas@gmail.com' is existed so if u check with another u can identify<br>
is it working or not
<form id='myform' method='POST' action='index.php' enctype="multipart/form-data">
<input type='text' name='username' size=15>
<button>check</button>
</form>


<?php

include 'result.php';
?>


Read More

Thursday, 30 August 2012

How to run php script on XAMPP

// siddhu vydyabhushana // 3 comments

Hello friends i got many requests from the viewers so i posted this present am using XAMPP !! as a server to run php script , in jsp we use tomcat as a server ,ok if u are familiar to jsp ok good else good!!!!!!!!!!!!

1)first of u please follow below steps to run php script:




DOWNLOAD XAMPP SERVER FIRST       :                      CLICK HERE


2)After download install it as clicking next ,next repeatedly ,it will saved on  d ,or c drive as per ur selection,as like below pic





3)After ur observation, u need to double click on xampp ,it will be opened likeas below

4) its main folder to store our projects or tutorials...............................,please double click on htdocs
5)create a newfolder and change that name as ur wish that will be ur project ........!!!!!!!!!!!!!!!!creaate simple php file and execute it as

1) rename newfolder  as firstproj
2)and create a file name as index.php

code for index.php is

<?php
echo "first project by aitamelearning.blogspot.com";
?>

and execute it  as  localhost/firstproj 

1)open  your browser
2)and type localhost/firstproj and press enter you will get output


thanq
siddhu vydyabhushana


Read More

Sunday, 26 August 2012

PHP script for password encryption

// siddhu vydyabhushana // Leave a Comment
hi friends i explained and teach u about php in many posts but now i want teach u on topic password encryption. on registration page our password going to be stored in one particular location in our database.
last post relate to this is

in facebook,google they protected their password by using this method

   


                                                         DOWNLOAD ALL IN ONE FILE 

1.At first you need to create a table with three coloumns
        id must be tick auto increment,username,passcode

2. Databse connection db.php




<?php
mysql_connect("localhost","root","") or die("Opps some thing went wrong");
mysql_select_db("dream") or die("Opps some thing went wrong");
?>

3.Registration page

<?php
include("db.php");
if($_SERVER["REQUEST_METHOD"] == "POST")
{
// username and password sent from Form
$username=$_POST['username'];
$password=$_POST['password'];
$password=md5($password); // Encrypted Password
$sql="Insert into admin(username,passcode) values('$username','$password');";
$result=mysql_query($sql);
echo "Registration Successfully";
}
?>
<html>
<body>
<form action="registration.php" method="post">
<label>UserName :</label>
<input type="text" name="username"/><br />


<label>Password :</label>
<input type="password" name="password"/><br/>
<input type="submit" value=" Registration "/><br />
</form>
</body>
</html>

4.Login page

<?php
include("db.php");
session_start();
if($_SERVER["REQUEST_METHOD"] == "POST")
{
// aitamelearning.blogspot.com
$username=$_POST['username'];
$password=$_POST['password'];
$password=md5($password); // Encrypted Password
$sql="SELECT id FROM admin WHERE username='$username' and passcode='$password'";
$result=mysql_query($sql);
$count=mysql_num_rows($result);


if($count==1)
{
header("location: welcome.php");//its ur wish
}
else
{
$error="Your Login Name or Password is invalid";
}
}
?>
<form action="login.php" method="post">
<label>UserName :</label>
<input type="text" name="username"/><br />
<label>Password :</label>
<input type="password" name="password"/><br/>
<input type="submit" value=" Login "/><br />
</form>
Read More

Monday, 20 August 2012

HOW TO insert and retrive an image into databse using PHP,MYSQL

// siddhu vydyabhushana // Leave a Comment
hello friends good morning am here with a extordinary coding , i know u all are aware about this, inserting and retriving an image into database mysql using php,

please save this file as index.php
<html>
<head>
</head>
<body>
<form name="myform" method="POST" action="index.php" enctype="multipart/form-data">
<input type='file' name='image'>
<input type='submit' name='upload'>
</form>
</body>

</html>

<?php

mysql_connect("localhost","root","") or die(mysql_error());
mysql_select_db("dream") or die(mysql_error());


$file=$_FILES['image']['tmp_name'];

if(!isset($file))

echo "please select an image";

else
{
$image=addslashes(file_get_contents($_FILES['image']['tmp_name']));
$image_name=addslashes($_FILES['image']['name']);
$image_size=getimagesize($_FILES['image']['tmp_name']);

if($image_size==FALSE)

echo "that is not an image";

else
{
if(!$insert=mysql_query("INSERT INTO store VALUES('','$image_name','$image')"))
echo "problem uploading image";
else
{
$lastid=mysql_insert_id();
echo "image uploaded.<p/>Your image:<p/> <img src='get.php?id=$lastid'></img>";
}

}
}
?>

please save the below file as get.php

<?php
mysql_connect("localhost","root","") or die(mysql_error());
mysql_select_db("dream") or die(mysql_error());

$id=addslashes($_REQUEST['id']);

$image=mysql_query("SELECT * FROM store WHERE id=$id");
$image=mysql_fetch_array($image);
$image=$image['image'];

//header("Content-type:image/jpeg");

echo $image;
?>

please create a mysql table like below with name store


CREATE TABLE IF NOT EXISTS `store` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(50) NOT NULL,
`image` blob NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=10 ;

Read More

Wednesday, 15 August 2012

HOW TO write code for simple captcha in PHP

// siddhu vydyabhushana // Leave a Comment
hi friends today i posted How to upload photos .and another chance i got to show how to write code in php,
it is very easy and funny too,on writing code i got some struggles so i posted in blog in easy steps


save the below code as any name with file extension .PHP
Click here to download

<?php
session_start();

$string = '';

for ($i = 0; $i < 5; $i++) {
$string .= chr(rand(97, 122));
}

$_SESSION['random_number'] = $string;

$dir = 'fonts/';

$image = imagecreatetruecolor(165, 50);

// random number 1 or 2
$num = rand(1,2);
if($num==1)
{
$font = "Capture it 2.ttf"; // font style
}
else
{
$font = "Molot.otf";// font style
}

// random number 1 or 2
$num2 = rand(1,2);
if($num2==1)
{
$color = imagecolorallocate($image, 113, 193, 217);// color
}
else
{
$color = imagecolorallocate($image, 163, 197, 82);// color
}

$white = imagecolorallocate($image, 255, 255, 255); // background color white
imagefilledrectangle($image,0,0,399,99,$white);

imagettftext ($image, 30, 0, 10, 40, $color, $dir.$font, $_SESSION['random_number']);

header("Content-type: image/png");
imagepng($image);

?>
Read More

Saturday, 11 August 2012

PHP ebook for Social Networking

// siddhu vydyabhushana // 2 comments

topics int his book is shown below
  • Existing social networks and softwares
  • planning and developing core framework
  • user registration and authentication
  • friends and relationships
  • profiles and status
  • status stream
  • public and private messsages 
  • events and birthdays
  • groups
  • deployment security and maintenance
  • marketing seo and user retention
  • planning for growth.

DOWNLOAD E-BOOK

Read More