<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Marwa El mekkaoui</title>
    <description>The latest articles on DEV Community by Marwa El mekkaoui (@marwa_elmekkaoui_6b5facf).</description>
    <link>https://dev.to/marwa_elmekkaoui_6b5facf</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1498694%2F612a6019-f669-45d9-b70e-e69797822a6b.png</url>
      <title>DEV Community: Marwa El mekkaoui</title>
      <link>https://dev.to/marwa_elmekkaoui_6b5facf</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/marwa_elmekkaoui_6b5facf"/>
    <language>en</language>
    <item>
      <title>LOGIN SYSTEM IN PHP AND MYSQL: User Authentication system.</title>
      <dc:creator>Marwa El mekkaoui</dc:creator>
      <pubDate>Wed, 15 May 2024 14:41:18 +0000</pubDate>
      <link>https://dev.to/marwa_elmekkaoui_6b5facf/login-system-in-php-and-mysql-user-authentication-system-178b</link>
      <guid>https://dev.to/marwa_elmekkaoui_6b5facf/login-system-in-php-and-mysql-user-authentication-system-178b</guid>
      <description>&lt;p&gt;&lt;strong&gt;hackathon - OFPPT&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;User &lt;strong&gt;authentication&lt;/strong&gt; in web developemen is used to authorized and restrict users to certain pages in a web appplication.&lt;/p&gt;

&lt;p&gt;here are the github repository&lt;br&gt;
&lt;a href="https://github.com/salahghr4/hackathon"&gt;github&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  REGISTERATION SYSTEM
&lt;/h3&gt;
&lt;h4&gt;
  
  
  DATABASE TABLE IN MYSQL
&lt;/h4&gt;

&lt;p&gt;The database used is MySQL, so you'll need a MySQL database to run create the users table.&lt;br&gt;
Run the &lt;code&gt;hackathon.sql&lt;/code&gt; file in MySQL database to create users table.&lt;/p&gt;
&lt;h3&gt;
  
  
  CONFIGURATION FILE
&lt;/h3&gt;

&lt;p&gt;The PHP script to connect to the database is in &lt;code&gt;config.php&lt;/code&gt; directory.&lt;br&gt;
Replace credentials to in &lt;code&gt;config.php&lt;/code&gt; to match your server credentials.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?php

$host = 'localhost';
$db   = 'Hackathon';
$user = 'root';
$pass = '';
$charset = 'UTF8';

$dsn = "mysql:host=$host;dbname=$db;charset=$charset";

// set the PDO error mode to exception and the default fetch mode to associative arrays
$options = [
    PDO::ATTR_ERRMODE =&amp;gt; PDO::ERRMODE_EXCEPTION,
    PDO::ATTR_DEFAULT_FETCH_MODE =&amp;gt; PDO::FETCH_ASSOC,
];

try {
    $conn = new PDO($dsn, $user, $pass, $options);

} catch (PDOException $e) {
    echo 'Connextion failed' . $e-&amp;gt;getMessage();
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  REGISTERATION FORM AND SCRIPT
&lt;/h3&gt;

&lt;p&gt;The &lt;code&gt;register.php&lt;/code&gt; creates a web form that allows users to register themselves.&lt;br&gt;
The script generates error if form input is empty and username is has been taking already by another user.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7ba1ef6lh985zihemg4o.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7ba1ef6lh985zihemg4o.jpg" alt="Image description" width="800" height="419"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  LOGIN SYSTEM
&lt;/h2&gt;

&lt;h4&gt;
  
  
  LOGIN FORM AND SCRIPT
&lt;/h4&gt;

&lt;p&gt;&lt;code&gt;login.php&lt;/code&gt; is the login script.&lt;br&gt;
When a user submit a form with the input of username and password, these inputs will be verified against the credentials data stored in the database, if there is a match then the user will be authorized and granted access to site or page.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkhsdtuqv6bkb4t7c4s1d.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkhsdtuqv6bkb4t7c4s1d.jpg" alt="Image description" width="800" height="433"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5mlvbhvtg99e0u1gdsd2.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5mlvbhvtg99e0u1gdsd2.jpg" alt="Image description" width="800" height="462"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  DASHBOARD PAGE
&lt;/h3&gt;

&lt;p&gt;User is redirected to &lt;code&gt;dashboard.php&lt;/code&gt; if login is successful.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg7uvvcvotfw69s9scqj0.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg7uvvcvotfw69s9scqj0.jpg" alt="Image description" width="800" height="414"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  LOGIN OUT
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;logout.php&lt;/code&gt; log out the user and destroy all his sessions.&lt;/p&gt;

&lt;h3&gt;
  
  
  SECURITY
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;always hash the password before stoke it in the database.&lt;br&gt;
we use functions &lt;strong&gt;password_hash()&lt;/strong&gt; for hashing&lt;br&gt;
and &lt;strong&gt;password_verify()&lt;/strong&gt; for check for the hashed password.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;we use the function &lt;strong&gt;filter_input()&lt;/strong&gt; its similar to &lt;strong&gt;htmlspecialchar()&lt;/strong&gt;, to validate variables from insecure sources, such as user input.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;use &lt;strong&gt;sessions&lt;/strong&gt; to store and persist user-specific data across multipile pages.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>webdev</category>
      <category>php</category>
      <category>mysql</category>
    </item>
  </channel>
</rss>
