Today, We want to share with you registration and signin form in php and mysql with validation code free download.In this post we will show you User Registration in PHP with Login: Form with MySQL and Code Download, hear for Registration and Login form in PHP and MySQL with Validation Code Free Download we will give you demo and example for implement.In this post, we will learn about Complete user registration system using PHP and MySQL database with an example.
registration and signin form in php and mysql with validation code free download
There are the Following The simple About Login and Signup form using PHP and MySQL with validation Full Information With Example and source code.
As I will cover this Post with live Working example to develop PHP User Registration Form (Sign up) with MySQL Database, so the php: complete Login and registration system with php & mysql download is used for this example is following below.
Database with Table structure
registration and signin form in php and mysql with validation Example
customer-registration.sql
-- -- Database: `customer-registration` -- -- -------------------------------------------------------- -- -- Table structure for table `tbl_visitor` -- CREATE TABLE `tbl_visitor` ( `id` int(11) NOT NULL, `customername` varchar(255) NOT NULL, `password` varchar(200) NOT NULL, `email` varchar(255) NOT NULL, `create_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Indexes for dumped tables -- -- -- Indexes for table `tbl_visitor` -- ALTER TABLE `tbl_visitor` ADD PRIMARY KEY (`id`); -- -- AUTO_INCREMENT for dumped tables -- -- -- AUTO_INCREMENT for table `tbl_visitor` -- ALTER TABLE `tbl_visitor` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
index.php
customer-registration
customer-registration-form.php
registerVisitor(); } ?>Registration
signin-form.php
signinVisitor(); } ?>
home.php
Welcome To Pakainfo.com Welcome To Pakainfo.com : -
Model/Visitor.php
ds = new DBConnection(); } public function isVisitorExists($email) { $query = 'SELECT * FROM tbl_visitor where email = ?'; $argumentType = 's'; $memberData = array( $email ); $insertRecord = $this->ds->select($query, $argumentType, $memberData); $count = 0; if (is_array($insertRecord)) { $count = count($insertRecord); } return $count; } public function registerVisitor() { $result = $this->isVisitorExists($_POST["email"]); if ($result < 1) { if (! empty($_POST["added-password"])) { $hashedPassword = password_hash($_POST["added-password"], PASSWORD_DEFAULT); } $query = 'INSERT INTO tbl_visitor (customername, password, email) VALUES (?, ?, ?)'; $argumentType = 'sss'; $memberData = array( $_POST["customername"], $hashedPassword, $_POST["email"] ); $visitorId = $this->ds->insert($query, $argumentType, $memberData); if(!empty($visitorId)) { $response = array("status" => "success", "message" => "You have registered successfully."); } } else if ($result == 1) { $response = array("status" => "error", "message" => "Email already exists."); } return $response; } public function getVisitor($customername) { $query = 'SELECT * FROM tbl_visitor where customername = ?'; $argumentType = 's'; $memberData = array( $customername ); $signinCustomer = $this->ds->select($query, $argumentType, $memberData); return $signinCustomer; } public function signinVisitor() { $signinCustomerResult = $this->getVisitor($_POST["customername"]); if (! empty($_POST["added-password"])) { $password = $_POST["added-password"]; } $hashedPassword = $signinCustomerResult[0]["password"]; $signinPassword = 0; if (password_verify($password, $hashedPassword)) { $signinPassword = 1; } if ($signinPassword == 1) { $_SESSION["customername"] = $signinCustomerResult[0]["customername"]; $url = "./home.php"; header("Location: $url"); } else if ($signinPassword == 0) { $signinStatus = "Invalid customername or password."; return $signinStatus; } } }
lib/DBConnection.php
conn = $this->getConnection(); } public function getConnection() { $conn = new \mysqli(self::HOST, self::USERNAME, self::PASSWORD, self::DATABASENAME); if (mysqli_connect_errno()) { trigger_error("Problem with connecting to database."); } $conn->set_charset("utf8"); return $conn; } public function select($query, $argumentType = "", $argDataBunch = array()) { $stmt = $this->conn->prepare($query); if (! empty($argumentType) && ! empty($argDataBunch)) { $this->bindQueryParams($stmt, $argumentType, $argDataBunch); } $stmt->execute(); $result = $stmt->get_result(); if ($result->num_rows > 0) { while ($row = $result->fetch_assoc()) { $resultset[] = $row; } } if (! empty($resultset)) { return $resultset; } } public function insert($query, $argumentType, $argDataBunch) { $stmt = $this->conn->prepare($query); $this->bindQueryParams($stmt, $argumentType, $argDataBunch); $stmt->execute(); $insertId = $stmt->insert_id; return $insertId; } public function execute($query, $argumentType = "", $argDataBunch = array()) { $stmt = $this->conn->prepare($query); if (! empty($argumentType) && ! empty($argDataBunch)) { $this->bindQueryParams($stmt, $argumentType, $argDataBunch); } $stmt->execute(); } public function bindQueryParams($stmt, $argumentType, $argDataBunch = array()) { $memberDataReference[] = & $argumentType; for ($i = 0; $i < count($argDataBunch); $i ++) { $memberDataReference[] = & $argDataBunch[$i]; } call_customer_func_array(array( $stmt, 'bind_param' ), $memberDataReference); } public function getRecordCount($query, $argumentType = "", $argDataBunch = array()) { $stmt = $this->conn->prepare($query); if (! empty($argumentType) && ! empty($argDataBunch)) { $this->bindQueryParams($stmt, $argumentType, $argDataBunch); } $stmt->execute(); $stmt->store_result(); $recordCount = $stmt->num_rows; return $recordCount; } }
assets/css/pakainfo-style.css
.pakainfo-container { -webkit-font-smoothing: antialiased; font-family: Arial, "Helvetica Neue", Helvetica, sans-serif; font-size: .9em; color: #1e2a28; width: 740px; margin: 0 auto; padding: 0px 20px 20px 20px; } .pakainfo-container table { border-collapse: collapse; width: 100%; margin-bottom: 30px; } .pakainfo-container td, .pakainfo-container th { text-align: left; padding: 8px; } .pakainfo-container h1 { font-weight: normal; } input[type=text].pakainfo-input, .pakainfo-container input, .pakainfo-container textarea, .pakainfo-container select, .pakainfo-input, .pakainfo-select { box-sizing: border-box; width: 200px; height: initial; padding: 8px 5px; border: 1px solid #9a9a9a; border-radius: 3px; } .pakainfo-container input[type="checkbox"] { width: auto; vertical-align: text-bottom; display: initial; opacity: initial; position: inherit; pointer-events: initial; } .pakainfo-container textarea, .pakainfo-textarea { width: 300px; } .pakainfo-container select, .pakainfo-select { display: initial; height: 30px; background-color: #fff; padding: 2px 5px; } .pakainfo-container button { width: 100px; padding: 6px 0px; font-size: 1em; cursor: pointer; border-radius: 3px; background: #1871e6; color: #FFF; margin: 0px 20px 20px 0; border: #1469d8 1px solid; } .pakainfo-container button:focus { outline: none; } .pakainfo-container .pakainfo-row { padding-top: 15px; } #pakainfo-message { padding: 6px 20px; font-size: 1em; color: rgb(40, 40, 40); box-sizing: border-box; margin: 0px; border-radius: 3px; width: 100%; overflow: auto; } .pakainfo-container .error { padding: 6px 20px; border-radius: 3px; background-color: #fb817c; border: 1px solid #e46b66; } .pakainfo-container .success { background-color: #48e0a4; border: #40cc94 1px solid; } #pakainfo-loader-icon { color: #1871e6; font-weight: bold; padding: 6px 20px 6px 0; display: none; vertical-align: middle; } #pakainfo-loader-ack-icon { color: #1871e6; font-weight: bold; padding: 6px 20px 6px 0; display: none; vertical-align: middle; } #pakainfo-btn-send:hover { background: #1363cc; border: #105bbd 1px solid; } .pakainfo-container .validation-message { color: #e20900; display: inline-block; } .pakainfo-container .label { margin-bottom: 3px; } .pakainfo-form, .pakainfo-section { border: #eaeaea 1px solid; padding: 10px 25px 10px 30px; border-radius: 3px; } .pakainfo-container .display-none { display: none; } .icon-add-more-attachemnt { cursor: pointer; font-style: italic; font-size: .9em; } .inline-block { display: inline-block; } @media all and (max-width: 780px) { .pakainfo-container { width: auto; } } @media all and (max-width: 400px) { .pakainfo-container { padding: 0px 20px; } .pakainfo-container h1 { font-size: 1.2em; } .pakainfo-container input, .pakainfo-container textarea, .pakainfo-container select { width: 100%; } .pakainfo-form { border: none; padding: 0; } }
assets/css/customer-registration.css
.register-container { border: 1px solid; border-color: #9a9a9a; background: #fff; border-radius: 4px; padding: 10px; width: 350px; margin: 50px auto; } .page-header { float: right; } .signin-added { margin: 10px; text-decoration: none; float: right; } .signin-added a { text-decoration: none; color: #000; font-weight: 700; } .added-heading { font-size: 2em; font-weight: bold; padding-top: 60px; text-align: center; } .inline-block { display: inline-block; } .row { margin: 15px 0px; text-align: center; } .form-label custom-point { margin-bottom: 5px; text-align: left; } input.input-box-330 { width: 250px; } .register-container .error { color: #ee0000; padding: 0px; background: none; border: #ee0000; } .register-container .error-field { border: 1px solid #d96557; } .register-container .error:before { content: '*'; padding: 0 3px; color: #D8000C; } .error-msg { padding-top: 10px; color: #D8000C; text-align: center; } .success-msg { padding-top: 10px; color: #23a600; text-align: center; } input.register-btn { background-color: #ffb932; border-color: #ffc87a #e2a348 #da9d0a; text-align: center; cursor: pointer; color: #000; width: 250px } .added-align { margin: 0 auto; } .page-content { font-weight: bold; padding-top: 60px; text-align: center; }
Web Programming Tutorials Example with Demo
Read :
Summary
You can also read about AngularJS, ASP.NET, VueJs, PHP.
I hope you get an idea about php code for registration form with mysql database.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.