<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>login with session in php Archives -</title>
	<atom:link href="https://mitindia.in/tag/login-with-session-in-php/feed/" rel="self" type="application/rss+xml" />
	<link>https://mitindia.in/tag/login-with-session-in-php/</link>
	<description></description>
	<lastBuildDate>Sat, 26 Nov 2016 06:37:00 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://mitindia.in/wp-content/uploads/2023/03/cropped-android-chrome-512x512-1-32x32.png</url>
	<title>login with session in php Archives -</title>
	<link>https://mitindia.in/tag/login-with-session-in-php/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Login with session in php</title>
		<link>https://mitindia.in/login-with-session-in-php/</link>
		
		<dc:creator><![CDATA[SKB]]></dc:creator>
		<pubDate>Thu, 16 Jun 2016 05:47:12 +0000</pubDate>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[login with session in php]]></category>
		<category><![CDATA[php login]]></category>
		<category><![CDATA[php mysql login]]></category>
		<guid isPermaLink="false">http://www.mitindia.in/?p=43</guid>

					<description><![CDATA[<p>The following example shows use of Login authentication with session variables. Before we create programs, let&#8217;s first create a table called &#8220;users&#8221; in your database with following screen image. [both usernm and password field type set to &#8220;varchar&#8221;] 1. Create Login2.php with following code in it. &#60;?php session_start(); ?&#62; &#60;html&#62; &#60;title&#62;Login&#60;/title&#62; &#60;/head&#62; &#60;body&#62; &#60;h1&#62; Login [&#8230;]</p>
<p>The post <a href="https://mitindia.in/login-with-session-in-php/">Login with session in php</a> appeared first on <a href="https://mitindia.in"></a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>The following example shows use of Login authentication with session variables.</p>
<p>Before we create programs, let&#8217;s first create a table called &#8220;users&#8221; in your database with following screen image.<br />
[both usernm and password field type set to &#8220;varchar&#8221;]</p>
<div class="separator"><img decoding="async" class="alignnone" src="https://1.bp.blogspot.com/-elpB2KnEhvI/Vz2zbfz3zLI/AAAAAAAABhM/Q2663KixdJkRa8zPpdnPWlikrHBzhcFmQCLcB/s1600/database.JPG" width="257" height="83" border="0" /></div>
<p>1. Create Login2.php with following code in it.</p>
<pre>&lt;?php  
session_start();
?&gt;  
 
&lt;html&gt;  
 &lt;title&gt;Login&lt;/title&gt;  
&lt;/head&gt;  
&lt;body&gt;  
  &lt;h1&gt; Login here &lt;/h1&gt;
&lt;form name="form" method="post" action="login2.php"&gt;  
&lt;input class="form-control" placeholder="User name" name="email" type="text" autofocus&gt;   &lt;br&gt;
&lt;input class="form-control" placeholder="Password" name="pass" type="password" value=""&gt;  &lt;br&gt;
                 
&lt;input  type="submit" value="login" name="login" &gt;  
&lt;/form&gt;  
&lt;/body&gt;  
&lt;/html&gt;  

&lt;?php  
$con = mysqli_connect('localhost','root','','mars_db');
  
if(isset($_POST['login']))  
{  
    $user_email=$_POST['email'];  
    $user_pass=$_POST['pass'];  
  
$check_user="select * from users WHERE usernm='$user_email' AND password='$user_pass'";  
  
    $run=mysqli_query($con,$check_user);  
      if(mysqli_num_rows($run))  
    {  
  echo "&lt;script&gt;window.open('welcome.php','_self')&lt;/script&gt;";  
  
        $_SESSION['email']=$user_email;
      }  
    else  
    {  
      echo "&lt;script&gt;alert('Email or password is incorrect!')&lt;/script&gt;";  
    }  
}  
?&gt;</pre>
<p>2. The output looks like following image.</p>
<div class="separator"><img decoding="async" class="alignnone" src="https://3.bp.blogspot.com/-8fix5QvVxMg/Vz2xtGQQ25I/AAAAAAAABg4/zLxQZV7BUSI1zuu-wktqJoPlxGZxIJrAgCLcB/s320/login_screen.JPG" width="320" height="130" border="0" /></div>
<p>3. Now create a file called &#8220;welcome.php&#8221; with following code in it.</p>
<pre>&lt;?php  
session_start();  
  if(!$_SESSION['email'])  
{  
header("Location: login2.php");
}  
  
?&gt;  
 
&lt;html&gt;  
&lt;head&gt;  
  
    &lt;title&gt;  
        Registration  
    &lt;/title&gt;  
&lt;/head&gt;  
  
&lt;body bgcolor="green" text="white"&gt;  
&lt;h1&gt;Welcome&lt;/h1&gt;
&lt;?php  
echo $_SESSION['email'];  
?&gt;  
 
&lt;h1&gt;&lt;a href="logout2.php"&gt;Logout here&lt;/a&gt; &lt;/h1&gt;  
&lt;/body&gt;  
&lt;/html&gt;</pre>
<p>4. Output of the above code would produce the following screen shot.<br />
<img decoding="async" class="alignnone" src="https://1.bp.blogspot.com/-Z2zG7qoy_t0/Vz2yW8Czc7I/AAAAAAAABhA/33l1T9AInLstpP74t1bLY5XC0dlKXa98gCLcB/s320/welcome_screen.JPG" width="320" height="152" /></p>
<p>5. Now create a file called &#8220;logout2.php&#8221; with following code in it.</p>
<pre>&lt;?php  
session_start();
session_destroy();  
header("Location: login2.php");
?&gt;</pre>
<p><a class="a2a_button_whatsapp" href="https://www.addtoany.com/add_to/whatsapp?linkurl=https%3A%2F%2Fmitindia.in%2Flogin-with-session-in-php%2F&amp;linkname=Login%20with%20session%20in%20php" title="WhatsApp" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fmitindia.in%2Flogin-with-session-in-php%2F&amp;linkname=Login%20with%20session%20in%20php" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fmitindia.in%2Flogin-with-session-in-php%2F&#038;title=Login%20with%20session%20in%20php" data-a2a-url="https://mitindia.in/login-with-session-in-php/" data-a2a-title="Login with session in php"><img src="https://static.addtoany.com/buttons/favicon.png" alt="Share"></a></p><p>The post <a href="https://mitindia.in/login-with-session-in-php/">Login with session in php</a> appeared first on <a href="https://mitindia.in"></a>.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
