Site directory chart :-
Explanation :- Index.php
Html code : In index.php file we only link the signin page and signup page.
<table width="50%" border="0" align="center" cellpadding="2" cellspacing="10">
<tr>
<td colspan="2" align="center" bgcolor="#0000FF"><h2><a href="http://www.eaglexwebs.blogspot.com" style="text-decoration:none;"><span class="style1">eaglexwebs.blogspot.com</span></a></h2></td>
</tr>
<tr>
<td width="46%" align="center"><a href="login.php"><div class="box" onmouseover="this.className='box1'" onmouseout="this.className='box'">Sign In</div></a></td>
<td width="54%" align="center"><a href="register.php"><div class="box" onmouseover="this.className='box1'" onmouseout="this.className='box'">Sign Up</div></a></td>
</tr></table>
Php code : session code (required to change language )
<?php
session_start();ob_start();
if($_SESSION['lang']=='')
{
$_SESSION['lang'] = "en";
}
include 'languages/lang.'.$_SESSION['lang'].'.php';
?>
register.php
<form action="" id="form1" method="post" name="form1" onsubmit="return validate();">
</form>
onsubmit="return validate(); is user define JavaScript function that validate the field .
Find the validate() function in register.php page .
Php code :
<?php session_start();ob_start();
if($_SESSION['lang']=='')
{
$_SESSION['lang'] = "en";
}
include 'languages/lang.'.$_SESSION['lang'].'.php';
include("include/db.inc.php");
include("include/bit_functions.inc.php");
include("include/function.register.php");
$db1=new db;
$db1->open();
$headermsg= _CREATE_ACCOUNT_;
$str=randamString();
?>
<?
if(isset($_POST['submit_reg']))
{
echo "submit button is post :";
}
?>
<input name="submit_reg" type="submit" class="inputsubmit" value="<?=_REGS_NOW_?>">
extract($_POST) function is add $ in all the post field.(city , $city )(name , $name ).
extract($_POST);
mysql_query("insert into city set stateid='$state',city='$other',status='1'");
$city=mysql_insert_id();
}
$sql="insert INTO user(id,uname,email,password, bday, state, city, time_zone, question, answar, ccode) values('','$name','$email','$pwd','$bday','$state','$city', '$time_zone','$question','$ans','$ccode')";
$res=mysql_query($sql) or die(mysql_error());
$i_id=mysql_insert_id();
$profile_set="insert into profile_setting set uid='$i_id',basic_info='1',contact_info='1',personal='1',
educational='1',course='1',wall='1',photo='1',friends='1',share='1',
notes='1',groups='1'";
mysql_query($profile_set);
Login :-
$query1=mysql_fetch_array(mysql_query("SELECT id FROM user WHERE email='$email' and password='$password' and confirm='1' and blocked='1' and deactive='0'"));
$query2=mysql_fetch_array(mysql_query("SELECT id FROM user WHERE email='$email' and password='$password' and confirm='1' and blocked='0' and deactive='1'"));
$query3=mysql_fetch_array(mysql_query("SELECT id FROM user WHERE email='$email' and password='$password' and confirm='1' and blocked='1' and deactive='1'"));
$query4=mysql_fetch_array(mysql_query("SELECT id FROM user WHERE email='$email' and password='$password' and confirm='1' and blocked='0' and deactive='0'"));
$query5=mysql_fetch_array(mysql_query("SELECT id FROM user WHERE email='$email' and password='$password' and confirm='0' "));
if($query1['id'])
header("location:login.php?msg=blocked");
if($query2['id'])
header("location:login.php?msg=deactive&deactivate=1");
if($query3['id'])
header("location:login.php?msg=deactiveblock");
if($query5['id']){
header("location:login.php?msg=confirm");}
if($query4['id'])
{
$_SESSION[id]=$query4['id'];
$gm=$_SESSION[id];
list($lastlogin)=mysql_fetch_array(mysql_query("select lastlogin from user where id='$gm'"));
$qry="update user set second_lastlogin='$lastlogin',lastlogin=now() where id='$gm'";
$res=mysql_query($qry);
if(!empty($_GET['code']))
{
$id=$_SESSION['id'];
$q="insert into friends(id,user_id,fr_id,fr_type,status) values('','$id','$i_id',1)";
mysql_query($q) or die(mysql_error());
}
//code to insert data in mypoint table or to show Login points
$mypoint_res=mysql_query("select * from mypoint where uid='$gm'");
$mypoint_row=mysql_fetch_object($mypoint_res);
$login_cnt=$mypoint_row->loginpoint;
$cc=mysql_num_rows($mypoint_res);
if($cc)
{
$clv=loginpoint100();
$lc=$login_cnt+$clv;
$qry="update mypoint set loginpoint='$lc' where uid='$gm'";
mysql_query($qry);
}
else
{
$lc=loginpoint100();
mysql_query("insert into mypoint values('','$gm','$lc','','','')");
}
//end of code to insert data in mypoint table or to show Login points
header("location:user_detail.php");
}
Logout :-
<?
session_start();ob_start();
session_destroy();
header("Location: index.php");
?>
User detail :-
<?php
session_start();ob_start();
include("include/db.inc.php");
if($_SESSION['lang']=='')
{
$_SESSION['lang'] = "en";
}
include 'languages/lang.'.$_SESSION['lang'].'.php';
include_once("include/bit_functions.inc.php");
$db1=new db;
$db1->open();
checked_login();
$uid=$_SESSION[id];
$query= "select * fROM user where id = '$uid'";
$sql=mysql_query($query);
$res=mysql_fetch_array($sql);
$query1= "select * fROM profile where uid = '$uid'";
$sql1=mysql_query($query1);
$res1=mysql_fetch_array($sql1);
?>
<table width="100%" cellpadding="3" cellspacing="3" style="font:Verdana, Arial, Helvetica, sans-serif ; font-size:16px; color:#9900CC; background-color:#99FFFF;">
<tr>
<td width="22%">User Name</td>
<td width="25%"><?php echo $res['uname'];?></td>
<td width="19%">Email Id</td>
<td width="34%"><?php echo $res['email'];?></td>
</tr>
<tr>
<td>Gender</td>
<td><?php if($res1['sex'] == m) { Echo "Male";}?><?php if($res1['sex'] == f) { Echo "Female";}?></td>
<td>Last LogIn </td>
<td><?php echo $res['lastlogin'];?></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table>
db.inc.php
var $host = 'localhost';
var $user ='root';
var $password ="";
var $database ='eaglex';
var $persistent = false;
var $adminid='admin';
var $adminipwd='admin';
define('_BASEURL_','http://localhost/signup-signin'); //protocol required (http://)
define('_DOMAINURL_','http://localhost/signup-signin');
define('_BASEPATH_','http://localhost/signup-signin');
Database :- user
CREATE TABLE IF NOT EXISTS `user` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`uname` varchar(50) COLLATE latin1_general_ci NOT NULL,
`fname` varchar(40) COLLATE latin1_general_ci NOT NULL,
`lname` varchar(30) COLLATE latin1_general_ci NOT NULL,
`email` varchar(50) COLLATE latin1_general_ci NOT NULL,
`password` varchar(50) COLLATE latin1_general_ci NOT NULL,
`bday` date NOT NULL,
`state` varchar(50) COLLATE latin1_general_ci NOT NULL,
`city` int(11) NOT NULL,
`college` int(11) NOT NULL,
`collstatus` int(11) NOT NULL,
`collyear` int(11) NOT NULL,
`time_zone` varchar(50) COLLATE latin1_general_ci NOT NULL,
`question` varchar(100) COLLATE latin1_general_ci NOT NULL,
`answar` varchar(50) COLLATE latin1_general_ci NOT NULL,
`blocked` enum('0','1') COLLATE latin1_general_ci NOT NULL,
`deactive` enum('0','1') COLLATE latin1_general_ci NOT NULL DEFAULT '0',
`couse` text COLLATE latin1_general_ci NOT NULL,
`confirm` enum('0','1') COLLATE latin1_general_ci NOT NULL DEFAULT '0',
`ccode` varchar(100) COLLATE latin1_general_ci NOT NULL,
`second_lastlogin` datetime NOT NULL,
`lastlogin` datetime NOT NULL,
`p_view` int(11) NOT NULL,
`online` enum('0','1') COLLATE latin1_general_ci NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=134 ;
State :-
CREATE TABLE IF NOT EXISTS `state` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`state` varchar(30) COLLATE latin1_general_ci NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=11 ;
City :-
-- Table structure for table `city`
--
CREATE TABLE IF NOT EXISTS `city` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`stateid` int(11) NOT NULL,
`city` varchar(200) COLLATE latin1_general_ci NOT NULL,
`status` enum('0','1') COLLATE latin1_general_ci NOT NULL DEFAULT '1',
UNIQUE KEY `id` (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=33 ;