corecodeschool.blogspot.com in any corecode like php, html, css, java, JavaScript, Ajax also database related query and some sort and simple code and small code and some shortcut here and start with first step in any language
Thursday, 12 October 2017
Thursday, 31 August 2017
update
update
1.COOKIES
=> SETTING A COOKIE
Syntax :
Set-cookie:NAME=value;EXPIRES=date;PATH=path;DOMAIN=domain;SECURE
The NAME=value is the only required piece of information that must be included in the set-cookie field .
All other entries are optional.
Example :
<html>
<head>
<script>
function newcookie(cookiename, value)
{
document.cookie=cookiename+"="+value;
}
</script>
</head>
<body>
<script>
document.write('<form>');
document.write('<table border="0" width="100%">');
document.write('<tr>');
document.write('<td width="25%">First Name</td>');
document.write('</tr>');
document.write('<tr>');
document.write('<td width="25%">First Name</td>');
document.write('<td width="25%">
<input type="text" name="first_nm" onBlur="newcookie(this.name,this.value);"
Size="20" type="text" value="'+cfirst_nm+'">
</td>');
document.write('</td>');document.write('</tr>');
document.write('</table>');
document.write('</form>');
</script>
</body>
</html>
2.VALIDATION
2.1 Field Name cannot be left empty
------------------------------
/* Cheking if the variable for Client's name is empty,(i.e.a blank Client's name field was submitted .) */
if(empty($_POST['txtName']))
{
/*returning data entry form if the Client's name is empty.*/
$alertmessage="<center>
Filed for Client\'s Name is empty!
</center>";
inclide("page2.php");
exit;
}
2.2 No double spacing in the field name captured
-----------------------------------------
=> To test double spacing validation,insert double spaces in between the Client Name and click submit button .
=> The PHP code checks the contents of Client Name field returned by the Browser. As it has double spacing,an error message is generated and stored in the variable $alertmessage.
ereg("([[:space:]]{2})",$_POST["txtName"]);
------------------------------------------------------------------------------
else
{
if(ereg("([[:space:]]{2})",$_POST["txtName"]))
{
/*
returning data entry form if the Client's name contains double spaces.
*/
$alertmessage="<center>
Double spaces found in Client\'s Name!
</center>";
inclide("page2.php");
exit;
}
}
--------------------------------------------------------------------------------------------------------
2.VALIDATION
2.1 Field Name cannot be left empty
2.1 Field Name cannot be left empty
------------------------------
/* Cheking if the variable for Client's name is empty,(i.e.a blank Client's name field was submitted .) */
if(empty($_POST['txtName']))
{
/*returning data entry form if the Client's name is empty.*/
$alertmessage="<center>
Filed for Client\'s Name is empty!
</center>";
inclide("page2.php");
exit;
}
2.2 No double spacing in the field name captured
-----------------------------------------
=> To test double spacing validation,insert double spaces in between the Client Name and click submit button .
=> The PHP code checks the contents of Client Name field returned by the Browser. As it has double spacing,an error message is generated and stored in the variable $alertmessage.
ereg("([[:space:]]{2})",$_POST["txtName"]);
------------------------------------------------------------------------------
else
{
if(ereg("([[:space:]]{2})",$_POST["txtName"]))
}
--------------------------------------------------------------------------------------------------------
if(empty($_POST['txtName']))
{
/*returning data entry form if the Client's name is empty.*/
$alertmessage="<center>
Filed for Client\'s Name is empty!
</center>";
inclide("page2.php");
exit;
}
2.2 No double spacing in the field name captured
-----------------------------------------
=> To test double spacing validation,insert double spaces in between the Client Name and click submit button .
=> The PHP code checks the contents of Client Name field returned by the Browser. As it has double spacing,an error message is generated and stored in the variable $alertmessage.
ereg("([[:space:]]{2})",$_POST["txtName"]);
------------------------------------------------------------------------------
else
{
if(ereg("([[:space:]]{2})",$_POST["txtName"]))
{
/*
returning data entry form if the Client's name contains double spaces.
*/
$alertmessage="<center>
Double spaces found in Client\'s Name!
</center>";
inclide("page2.php");
exit;
}
--------------------------------------------------------------------------------------------------------
basic code
Basic Code
1. How to create one form<html>
<head>
// you have put hear any meta tag or css depended on you.
</head>
<body>
<form action="process.html" method="post">
Name : <input type="text" name="nm"/><br/>
Add : <input type="text" name="add"/><br/>
Mo No : <input type="text" name="no"/><br/>
Other : <input type="text" name="otr"/><br/>
</form>
</body>
</html>
2. How to use switch case
switch (num)
{
case 1: alert("One");
break;
case 2: alert("Two");
break;
case 3: alert("Three");
break;
case 4: alert("Four");
break;
case 5: alert("Five");
break;
default: alert("Select 1 to 5 Number");
}3. How to create array using script
var demo = new array();
demo[0] = new array();
demo[0][0]='A0';
demo[0][1]='B0';
demo[0][2]='C0';
demo[1] = new array();
demo[1][0]='A1';
demo[1][1]='B1';
demo[1][2]='C1';
demo[2] = new array();
demo[2][0]='A2';
demo[2][1]='B2';
demo[2][2]='C2';
document.write("A : "+demo[0][0]+"<br/>");
document.write("B : "+demo[0][1]+"<br/>");
Tuesday, 11 October 2016
what is ajax?how to create ajax with php code
Ajax Introduction
- એજેક્સ નો ઉપીયોગ કરી ને તમે પેજ લોડ કાર્ય વિના બધી માહિતી મેળવી શકો.એજેક્સ થી તમે કોઈ પણ ડેટા ઝડપ થી મેળવી શકો છો
- अजाक्स का उपियोग करके आप कोई भी डाटा स्पीड में ले सकते हे और इसकी प्रोसेस प्रोसेसबार में नहीं दिखती अजाक्स अपने डाटा सर्वर को सेंड करते समय सेकुएंस मेन्टेन नहीं करता इस लिए हम डाटा फ़ास्ट एक्सेस कर सकते हे
- Ajax stands for Asynchronous JavaScript and XML. Ajax isn’t a technology;
it mixes well-known programming techniques in an uncommon way to enable web
developers to build Internet applications with much more appealing user
interfaces.
- એજેક્સ નો ઉપીયોગ કરી ને તમે પેજ લોડ કાર્ય વિના બધી માહિતી મેળવી શકો.એજેક્સ થી તમે કોઈ પણ ડેટા ઝડપ થી મેળવી શકો છો
- अजाक्स का उपियोग करके आप कोई भी डाटा स्पीड में ले सकते हे और इसकी प्रोसेस प्रोसेसबार में नहीं दिखती अजाक्स अपने डाटा सर्वर को सेंड करते समय सेकुएंस मेन्टेन नहीं करता इस लिए हम डाटा फ़ास्ट एक्सेस कर सकते हे
- The parts of an Ajax application that happen "under the hood" of the browser, such as sending server queries and dealing with the returned data, are written in JavaScript, and XML is a means of coding and transferring formatted information used by Ajax to efficiently transfer data between server and client.
- You cannot make use of the XMLHTTPRequest until you have
created an instance of it.
-Microsoft
first introduced the XMLHTTPRequest object, implementing it in Internet
Explorer 5 as an ActiveX object.
- The following line creates an XMLHTTPRequest object called request
var request = new XMLHTTPRequest();
- Here we have declared a variable request and assigned to it the value returned from the statement
new XMLHTTPRequest(),which is invoking the constructor method for the XMLHTTPRequest object.
- To achieve the equivalent result in Microsoft Internet Explorer, you need to create an ActiveX object.
Here's an example
var request = new ActiveXObject("Microsoft.XMLHTTP");
- This assigns the name request to the new object.
- Some versions of Internet Explorer have a different version of MSXML, the Microsoft XML parser,
installed in those cases you need to use the following instruction
var request = new ActiveXObject("Msxml2.XMLHTTP");
- For cross Browser detection, this is the following code :
function ajaxFunction()
{
var xmlhttp;
if (window.XMLHttpRequest)
{
// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else if (window.ActiveXObject)
{
// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
else
{
alert("Your browser does not support XMLHTTP!");
}
}
In above example create a variable named xmlhttp to hold the XMLHttpRequest object,
Try to create the XMLHttpRequest object with xmlhttp=new XMLHttpRequest(). If that fails,
try xmlhttp=new ActiveXObject("Microsoft.XMLHTTP").
This is for IE6 and IE5. If that fails too, the user has a very outdated browser,
and will get an alert stating that the browser doesn't support XMLHTTP.
Note: The code above
can be used every time you need to create an XMLHttpRequest object.
- XMLHTTPRequest class is predefined in php
- Ajax have a some method and properties
Method : open, send
Properties :onreadystatechange, readyState, responseText and status
Ajax With Html demo.html
ajaxdemo.html
<script
type="text/javascript">
var http =
false;
if(navigator.appName
== "Microsoft Internet Explorer")
{
http
= new ActiveXObject("Microsoft.XMLHTTP");
}
else
{
http = new XMLHttpRequest();
}
function replace()
{
http.open("GET", "test.txt", true);
http.onreadystatechange=function()
{
if(http.readyState == 4)
{
document.getElementById('changed').innerHTML = http.responseText;
document.getElementById('changed').innerHTML = http.responseText;
}
}
}
http.send(null);
}
}
</script>
<p><a
href="javascript:replace()">Replace Text</a></p>
<div
id="changed">
Hello,
world!
</div>
test.txt
This is the
content of test.txt
Sunday, 2 October 2016
how create template using html5 tags
- यह पोस्ट में आप HTML5 के टैग का उपयोग करके बहुत सरलता से अपनी डिजाईन और फॉर्म बना सकते हे.
- In this post you very simply by using HTML5 tags, create your own design and form.
- આ પોસ્ટ માં તમે HTML5 નો ઉપયોગ કરી ખુબજ સરળતા થી તમારી પોતાની Design અને ફોર્મ(Form) બનાવી શકો છો.
Monday, 2 May 2016
How to create Regular expression validation in php
index.php
<?php session_start(); ?>
<html>
<head>
<title>Registration</title>
</head>
<body>
<?php
if(isset($_SESSION['vali']['ok']))
{
echo '<span style="color:green;">'.$_SESSION['vali']['ok'].'</span>';
}
?>
<form action="process.php" method="post" enctype="multipart/form-data">
FullName : <br/>
<input type="text" name="fnm">
<?php
if(isset($_SESSION['vali']['fnm']))
{
echo '<span style="color:red;">'.$_SESSION['vali']['fnm'].'</span>';
}
?>
<br/><br/>
UserName : <br/>
<input type="text" name="unm">
<?php
if(isset($_SESSION['vali']['unm']))
{
echo '<span style="color:red;">'.$_SESSION['vali']['unm'].'</span>';
}
?>
<br/><br/>
Password : <br/>
<input type="password" name="pwd">
<?php
if(isset($_SESSION['vali']['pwd']))
{
echo '<span style="color:red;">'.$_SESSION['vali']['pwd'].'</span>';
}
?>
<br/><br/>
Conform Password : <br/>
<input type="password" name="cpwd">
<?php
if(isset($_SESSION['vali']['cpwd']))
{
echo '<span style="color:red;">'.$_SESSION['vali']['cpwd'].'</span>';
}
if(isset($_SESSION['vali']['pwdm']))
{
echo '<span style="color:red;">'.$_SESSION['vali']['pwdm'].'</span>';
}
?>
<br/><br/>
Mobile No : <br/>
<input type="text" name="mno">
<?php
if(isset($_SESSION['vali']['mno']))
{
echo '<span style="color:red;">'.$_SESSION['vali']['mno'].'</span>';
}
if(isset($_SESSION['vali']['digits']))
{
echo '<span style="color:red;">'.$_SESSION['vali']['digits'].'</span>';
}
if(isset($_SESSION['vali']['max']))
{
echo '<span style="color:red;">'.$_SESSION['vali']['max'].'</span>';
}
?>
<br/><br/>
Email Id : <br/>
<input type="text" name="email">
<?php
if(isset($_SESSION['vali']['email']))
{
echo '<span style="color:red;">'.$_SESSION['vali']['email'].'</span>';
}
if(isset($_SESSION['vali']['regex']))
{
echo '<span style="color:red;">'.$_SESSION['vali']['regex'].'</span>';
}
unset($_SESSION['vali']);
?>
<br/><br/>
<input type="submit" value="Submit">
</form>
</body>
</html>
process.php
<?php session_start();
$_SESSION['vali']=array();
extract($_POST);
if(empty($_POST['fnm']))
{
$_SESSION['vali']['fnm']="Enter Fullname";
}
if(empty($_POST['unm']))
{
$_SESSION['vali']['unm']="Enter Username";
}
if(empty($_POST['pwd']))
{
$_SESSION['vali']['pwd']="Enter Password";
}
if(empty($_POST['cpwd']))
{
$_SESSION['vali']['cpwd']="Enter Re-Password";
}
if($_POST['pwd'] != $_POST['cpwd'])
{
$_SESSION['vali']['pwdm']="Do not match password";
}
if(empty($mno))
{
$_SESSION['vali']['mno']="Enter Mobile No";
}
else if(!is_numeric($mno))
{
$_SESSION['vali']['digits']="Enter Digits";
}
else if(strlen($_POST['mno'])<10)
{
$_SESSION['vali']['max']="Enter 10 Digits";
}
if(empty($_POST['email']))
{
$_SESSION['vali']['email']="Enter Email Id";
}
if(! ereg("^[a-z0-9_]+[a-z0-9_.]*@[a-z0-9_-]+[a-z0-9.-]*\.[a-z]{2,5}$",$_POST['email']))
{
$_SESSION['vali']['regex']="Email not valid";
}
if(!empty($_SESSION['vali']))
{
header('location:index.php');
}
else
{
extract($_POST);
$link=mysql_connect('localhost','root','')or die("connect problem");
mysql_select_db('test',$link);
$q="insert into register(fnm,unm,pwd,mno,email)values('$fnm','$unm','$pwd','$mno','$email')";
mysql_query($q);
$_SESSION['vali']['ok']="Record Insrted";
header('location:index.php');
}
?>
<?php session_start(); ?>
<html>
<head>
<title>Registration</title>
</head>
<body>
<?php
if(isset($_SESSION['vali']['ok']))
{
echo '<span style="color:green;">'.$_SESSION['vali']['ok'].'</span>';
}
?>
<form action="process.php" method="post" enctype="multipart/form-data">
FullName : <br/>
<input type="text" name="fnm">
<?php
if(isset($_SESSION['vali']['fnm']))
{
echo '<span style="color:red;">'.$_SESSION['vali']['fnm'].'</span>';
}
?>
<br/><br/>
UserName : <br/>
<input type="text" name="unm">
<?php
if(isset($_SESSION['vali']['unm']))
{
echo '<span style="color:red;">'.$_SESSION['vali']['unm'].'</span>';
}
?>
<br/><br/>
Password : <br/>
<input type="password" name="pwd">
<?php
if(isset($_SESSION['vali']['pwd']))
{
echo '<span style="color:red;">'.$_SESSION['vali']['pwd'].'</span>';
}
?>
<br/><br/>
Conform Password : <br/>
<input type="password" name="cpwd">
<?php
if(isset($_SESSION['vali']['cpwd']))
{
echo '<span style="color:red;">'.$_SESSION['vali']['cpwd'].'</span>';
}
if(isset($_SESSION['vali']['pwdm']))
{
echo '<span style="color:red;">'.$_SESSION['vali']['pwdm'].'</span>';
}
?>
<br/><br/>
Mobile No : <br/>
<input type="text" name="mno">
<?php
if(isset($_SESSION['vali']['mno']))
{
echo '<span style="color:red;">'.$_SESSION['vali']['mno'].'</span>';
}
if(isset($_SESSION['vali']['digits']))
{
echo '<span style="color:red;">'.$_SESSION['vali']['digits'].'</span>';
}
if(isset($_SESSION['vali']['max']))
{
echo '<span style="color:red;">'.$_SESSION['vali']['max'].'</span>';
}
?>
<br/><br/>
Email Id : <br/>
<input type="text" name="email">
<?php
if(isset($_SESSION['vali']['email']))
{
echo '<span style="color:red;">'.$_SESSION['vali']['email'].'</span>';
}
if(isset($_SESSION['vali']['regex']))
{
echo '<span style="color:red;">'.$_SESSION['vali']['regex'].'</span>';
}
unset($_SESSION['vali']);
?>
<br/><br/>
<input type="submit" value="Submit">
</form>
</body>
</html>
process.php
<?php session_start();
$_SESSION['vali']=array();
extract($_POST);
if(empty($_POST['fnm']))
{
$_SESSION['vali']['fnm']="Enter Fullname";
}
if(empty($_POST['unm']))
{
$_SESSION['vali']['unm']="Enter Username";
}
if(empty($_POST['pwd']))
{
$_SESSION['vali']['pwd']="Enter Password";
}
if(empty($_POST['cpwd']))
{
$_SESSION['vali']['cpwd']="Enter Re-Password";
}
if($_POST['pwd'] != $_POST['cpwd'])
{
$_SESSION['vali']['pwdm']="Do not match password";
}
if(empty($mno))
{
$_SESSION['vali']['mno']="Enter Mobile No";
}
else if(!is_numeric($mno))
{
$_SESSION['vali']['digits']="Enter Digits";
}
else if(strlen($_POST['mno'])<10)
{
$_SESSION['vali']['max']="Enter 10 Digits";
}
if(empty($_POST['email']))
{
$_SESSION['vali']['email']="Enter Email Id";
}
if(! ereg("^[a-z0-9_]+[a-z0-9_.]*@[a-z0-9_-]+[a-z0-9.-]*\.[a-z]{2,5}$",$_POST['email']))
{
$_SESSION['vali']['regex']="Email not valid";
}
if(!empty($_SESSION['vali']))
{
header('location:index.php');
}
else
{
extract($_POST);
$link=mysql_connect('localhost','root','')or die("connect problem");
mysql_select_db('test',$link);
$q="insert into register(fnm,unm,pwd,mno,email)values('$fnm','$unm','$pwd','$mno','$email')";
mysql_query($q);
$_SESSION['vali']['ok']="Record Insrted";
header('location:index.php');
}
?>
Saturday, 23 April 2016
String function in php
echo
<?php
echo " A value is ";
$a=4;
echo $a;
?>
chr
<?php
echo chr(65);
echo "<br/>";
echo chr(122);
?>
strlen
<?php
$pwd="abc@123";
if(strlen($pwd)<6)
{
echo "password to short";
}
?>
ord
<?php
echo ord(' ');
echo "<br/>";
echo ord('z');
?>
print
<?php
print " A value is ";
$a=4;
print $a;
?>
strtoupper
<?php
echo strtoupper('hello');
echo "<br/>";
echo strtoupper('world');
?>
strtolower
<?php
echo strtolower('HEllo');
echo "<br/>";
echo strtolower('WORLD');
?>
substr
<?php
$a="harsukh k k";
$b=strlen($a);
for($i=0;$i<=9;$i++){
$j=substr($a,$i,1);
$d=ord($j);
echo $d;
echo"<br />";
echo $j;
}
?>
chop
<?php
$str = "Hello World!";
echo $str . "<br>";
echo chop($str,"World!");
?>
join
<?php
$arr = array('Hello','World!','Beautiful','Day!');
echo join(" ",$arr);
?>
parse_str
<?php
parse_str("name=Peter&age=43");
echo $name."<br>";
echo $age;
?>
<?php
echo " A value is ";
$a=4;
echo $a;
?>
chr
<?php
echo chr(65);
echo "<br/>";
echo chr(122);
?>
strlen
<?php
$pwd="abc@123";
if(strlen($pwd)<6)
{
echo "password to short";
}
?>
ord
<?php
echo ord(' ');
echo "<br/>";
echo ord('z');
?>
<?php
print " A value is ";
$a=4;
print $a;
?>
strtoupper
<?php
echo strtoupper('hello');
echo "<br/>";
echo strtoupper('world');
?>
strtolower
<?php
echo strtolower('HEllo');
echo "<br/>";
echo strtolower('WORLD');
?>
substr
<?php
$a="harsukh k k";
$b=strlen($a);
for($i=0;$i<=9;$i++){
$j=substr($a,$i,1);
$d=ord($j);
echo $d;
echo"<br />";
echo $j;
}
?>
chop
<?php
$str = "Hello World!";
echo $str . "<br>";
echo chop($str,"World!");
?>
join
<?php
$arr = array('Hello','World!','Beautiful','Day!');
echo join(" ",$arr);
?>
parse_str
<?php
parse_str("name=Peter&age=43");
echo $name."<br>";
echo $age;
?>
How to create pagging system using php
view_pagging.php
<?php
$link=mysql_connect("localhost","root","");
mysql_select_db("product",$link);
$page_q="select * from mobile";
$page_res=mysql_query($page_q,$link);
$item=3;
$total_record=mysql_num_rows($page_res);
$total_page=ceil($total_record/$item);
$cur_page=(isset($_GET['page']))?$_GET['page']:1;
?>
<html>
<body>
<table border="1" width="50%" align="center">
<tr>
<th>No</th>
<th>Name</th>
</tr>
<?php
$k=($cur_page-1)*$item;
$q="select * from mobile LIMIT $k,$item";
$res=mysql_query($q,$link);
while($row=mysql_fetch_array($res))
{
echo '<tr align="center">
<td>'.$row['id'].'
<td>'.$row['nm'].'
</tr>';
}
?>
</table>
<center>
<?php
if($cur_page>1)
{
echo '<a href="view_pagging.php?page='.($cur_page-1).'">Previous </a>';
}
else
{
echo 'Previous';
}
for($i=1;$i<=$total_page;$i++)
{
echo '<a href="view_pagging.php?page='.$i.'">'.$i.'</a> ';
}
if($cur_page<$total_page)
{
echo '<a href="view_pagging.php?page='.($cur_page+1).'">Next</a>';
}
else{
echo 'Next';
}
?>
</center>
</body>
</html>
<?php
$link=mysql_connect("localhost","root","");
mysql_select_db("product",$link);
$page_q="select * from mobile";
$page_res=mysql_query($page_q,$link);
$item=3;
$total_record=mysql_num_rows($page_res);
$total_page=ceil($total_record/$item);
$cur_page=(isset($_GET['page']))?$_GET['page']:1;
?>
<html>
<body>
<table border="1" width="50%" align="center">
<tr>
<th>No</th>
<th>Name</th>
</tr>
<?php
$k=($cur_page-1)*$item;
$q="select * from mobile LIMIT $k,$item";
$res=mysql_query($q,$link);
while($row=mysql_fetch_array($res))
{
echo '<tr align="center">
<td>'.$row['id'].'
<td>'.$row['nm'].'
</tr>';
}
?>
</table>
<center>
<?php
if($cur_page>1)
{
echo '<a href="view_pagging.php?page='.($cur_page-1).'">Previous </a>';
}
else
{
echo 'Previous';
}
for($i=1;$i<=$total_page;$i++)
{
echo '<a href="view_pagging.php?page='.$i.'">'.$i.'</a> ';
}
if($cur_page<$total_page)
{
echo '<a href="view_pagging.php?page='.($cur_page+1).'">Next</a>';
}
else{
echo 'Next';
}
?>
</center>
</body>
</html>
How to create login logout system using php
login.php
<html>
<head>
</head>
<body>
<form action="login_pro.php" method="post">
username<br />
<input type="text" name="unm">
<br />
<br />
password<br />
<input type="password" name="pwd">
<br />
<br />
<input type="submit" value="login">
</form>
</body>
</html>
login_pro.php
<?php session_start();
if (empty($_REQUEST['unm']) || empty($_REQUEST['pwd']))
{
echo "pleace enter username and password";
}
else
{
$link=mysql_connect("localhost","root","");
mysql_select_db("login",$link);
$unm=$_REQUEST['unm'];
$pwd=$_REQUEST['pwd'];
$q="select * from registration where unm='$unm' and pwd='$pwd'";
$res=mysql_query($q,$link)or die($row);
$row=mysql_fetch_array($res);
if(empty($row))
{
echo"wrong username or password";
}
else
{
$_SESSION['unm']=$row['unm'];
$_SESSION['status']=true;
header("location:index1.php");
}
}
?>
index1.php
<?php session_start();
if(isset($_SESSION['status']))
{
echo 'hello:'.$_SESSION['unm'];
echo '<a href="logout.php">Logout</a>';
}
else
{
header("location:logout.php");
}
?>
logout.php
<?php session_start();
session_destroy();
header("location:login.php");
?>
<html>
<head>
</head>
<body>
<form action="login_pro.php" method="post">
username<br />
<input type="text" name="unm">
<br />
<br />
password<br />
<input type="password" name="pwd">
<br />
<br />
<input type="submit" value="login">
</form>
</body>
</html>
login_pro.php
<?php session_start();
if (empty($_REQUEST['unm']) || empty($_REQUEST['pwd']))
{
echo "pleace enter username and password";
}
else
{
$link=mysql_connect("localhost","root","");
mysql_select_db("login",$link);
$unm=$_REQUEST['unm'];
$pwd=$_REQUEST['pwd'];
$q="select * from registration where unm='$unm' and pwd='$pwd'";
$res=mysql_query($q,$link)or die($row);
$row=mysql_fetch_array($res);
if(empty($row))
{
echo"wrong username or password";
}
else
{
$_SESSION['unm']=$row['unm'];
$_SESSION['status']=true;
header("location:index1.php");
}
}
?>
index1.php
<?php session_start();
if(isset($_SESSION['status']))
{
echo 'hello:'.$_SESSION['unm'];
echo '<a href="logout.php">Logout</a>';
}
else
{
header("location:logout.php");
}
?>
logout.php
<?php session_start();
session_destroy();
header("location:login.php");
?>
Subscribe to:
Posts (Atom)
Featured post
what is ajax?how to create ajax with php code
Ajax Introduction - એજેક્સ નો ઉપીયોગ કરી ને તમે પેજ લોડ કાર્ય વિના બધી માહિતી મેળવી શકો.એજેક્સ થી તમે કોઈ પણ ડેટા ઝડપ થી મેળવી શકો છો...
-
Installing ClamAV 1.sudo apt-get install clamav 2.sudo freshclam Note : The error indicates that ClamAV is currently running in the back...
-
Basic Concepts Of Internet INTERNET DOMAIN Each computer that has a permanent IP address, runs Server software and offers infor...
-
dragdrop1.html <html> <head> <title>Show Event Drag And Drop</title> <script type=&qu...