kaise ho sab? hope aapko CodeIgniter installation ka samaj me aagaya hoga chaliye aaj ham login registration ka sikhenge database ke sath .
ham login form banane ke liye bootstrap inoput form use karenge full form with validation aapko ache se bataunga so pura jarur pade.
bootstarp input form
Register.php
Login.php
register or login php ke liye aap bootstrap starter tamplet header footer me use kar sakte hai jaisa hamane CodeIgniter installation me sikha tha register or login php aapko view me banana hai or controller me Register.php banaye usame aap view load kare jaise jamane home load kiya tha
REGISTER CONTROLLER FOR REGISTER/LOGIN LOAD
<?phpdefined(‘BASEPATH’) OR exit(‘No direct script access allowed’); class Home extends CI_Controller { public function index() { $this->load->view(‘header’); $this->load->view(‘register’); $this->load->view(‘footer’); } public function login() { $this->load->view(‘header’); $this->load->view(‘login’); $this->load->view(‘footer’); } }
http://localhost/mysite/register
http://localhost/mysite/register/login
Ab aap soch rahe honge register or login ka url alag kyu ? Dosto ham same controller me kam kar rahe hai isaliye by default register pehale call hoga usake bad login ya jo bhi function is view me call karenge wo call hoga. Aap is url ko short kar sakte hai route php se
$route[‘login’][‘GET’] = ‘register/login’;// in route php
Now you can acsess http://localhost/mysite/login hai na simple dost hogaya SEO friendly url ?
Chalo ab ham Php my admin me chalte hai database creat karlete hai kyu. ? Jab tak database or register login table nahi banayenge apana form submit kaise hoga hai na
To browser me http://localhost khole make sure your xamp app on xamp control panel khulega waha pe uper corner me hoga php my admin
Database creat karle mydb name se usake bad users name ka table creat kar. ye kam manually kare to acha hai aapko jyada idea aayega database ka ya aap niche diya code run karsakte hai sql me
DATABASE WITH TABLE -- phpMyAdmin SQL Dump -- version 5.0.2 -- https://www.phpmyadmin.net/ -- -- Host: 127.0.0.1 -- Generation Time: Nov 13, 2020 at 05:12 PM -- Server version: 10.4.13-MariaDB -- PHP Version: 7.4.8 SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; START TRANSACTION; SET time_zone = "+00:00"; /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; /*!40101 SET NAMES utf8mb4 */; -- -- Database: `mydb` -- -- -------------------------------------------------------- -- -- Table structure for table `users` -- CREATE TABLE `users` ( `ID` int(11) NOT NULL, `FullName` varchar(256) NOT NULL, `Email` varchar(256) NOT NULL, `Password` varchar(256) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -- -- Indexes for dumped tables -- -- -- Indexes for table `users` -- ALTER TABLE `users` ADD PRIMARY KEY (`ID`); -- -- AUTO_INCREMENT for dumped tables -- -- -- AUTO_INCREMENT for table `users` -- ALTER TABLE `users` MODIFY `ID` int(11) NOT NULL AUTO_INCREMENT; COMMIT; /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
REGISTER PHP (VIEW)
<h1>Register form</h1> <form> <div class="form-row"> <div class="form-group col-md-6"> <label for="inputEmail4">Full Name</label> <input type="text" class="form-control" name="FullName" placeholder="Full Name"> <label for="inputEmail4">Email</label> <input type="email" class="form-control" name="Email" placeholder="Email"> <label for="inputPassword4">Password</label> <input type="password" class="form-control" name="Password" placeholder="Password"> <label for="inputPassword4">Password Cnf</label> <input type="password" class="form-control" name="passwordcnf" placeholder="Password"> </div> </div> <button type="submit" class="btn btn-primary">Sign in</button> </form>
LOGIN PHP (VIEW)
<h1>Login Form</h1> <form> <div class="form-group row"> <div class="col-md-6"> <label for="exampleInputEmail1">Email address</label> <input type="email" class="form-control" name="Email" aria-describedby="emailHelp" placeholder="Enter email"> <small id="emailHelp" class="form-text text-muted">We'll never share your email with anyone else.</small> <label for="exampleInputPassword1">Password</label> <input type="password" class="form-control" name="Password" placeholder="Password"> </div> </div> <button type="submit" class="btn btn-primary">Submit</button> </form>
dosto itana sab karke run karke dekhle login or register page work kar raha proper mere me to chal raha aap bhi dekhale kuch issue aaye koi bhi doubt ho aap muje comments kar sakte hai. me aapki help jarur karung
thank you milate hai agale episode me
happy coding