Menu
Forums
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Trending
What's new
New posts
New profile posts
Latest activity
Members
Current visitors
New profile posts
Search profile posts
Upgrades
Log in
Register
What's new
Search
Search
Search titles only
By:
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
Software Development
Programming
Programming Q&A
[PHP]Code-Review
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="Mikee" data-source="post: 428149" data-attributes="member: 76567"><p>Since devbest's community has a lot of php programmers I'm interested in getting criticized; also this subforum is lacking activity imo.</p><p>I'm Learning how to pull POST Data for a register page and send it to a db. Let me know how I did.</p><p>Note, I've never developed for the web before.</p><p>[PHP]<?php</p><p>require_once("Template/index.php");</p><p>require("Engine/DBConnect");</p><p></p><p>$Database = DBConnect::EstablishConnect();</p><p></p><p></p><p>if (isset($_REQUEST["submit"]) && $_POST['username'] != null && $_POST['password'] == $_POST['confirm_password']){</p><p> $Username = $_POST['username'];</p><p> $EncryptedPassword = password_hash($_POST['password'], PASSWORD_BCRYPT);</p><p></p><p> $NewUser = $Database->prepare("INSERT INTO users (username, password) VALUES (?, ?)");</p><p> $NewUser->execute([$Username,$EncryptedPassword]);</p><p></p><p>}else if(!isset($_REQUEST["submit"])){</p><p> return;</p><p>}else{</p><p> echo "Some fields are missing values";</p><p>}</p><p></p><p>[/PHP]</p><p></p><p>[CODE]<?php</p><p></p><p>class DBConnect{</p><p> function __construct(){</p><p></p><p> }</p><p></p><p> public static function EstablishConnect(){</p><p> $PDO = new PDO("mysql:host=localhost;dbname=first_site", "root", "password");</p><p> return $PDO;</p><p> }</p><p>}</p><p></p><p>?></p><p>[/CODE]</p><p>[CODE]<HTML></p><p> <head></p><p> <title>Mike's Website</title></p><p> </head></p><p> <body></p><p> <form name = "form" method = "POST"></p><p> <center></p><p> Username:</br></p><p> <input type = "text" name="username"></br></p><p></p><p> Password:</br></p><p> <input type = "text" name="password"></br></p><p> </p><p> Confirm Password:</br></p><p> <input type = "text" name="confirm_password"></br></p><p> <button type = "submit" name = "submit">Register</button></p><p> </center></p><p></p><p></p><p> </form></p><p></p><p> </body></p><p></p><p></p><p></HTML></p><p>[/CODE]</p></blockquote><p></p>
[QUOTE="Mikee, post: 428149, member: 76567"] Since devbest's community has a lot of php programmers I'm interested in getting criticized; also this subforum is lacking activity imo. I'm Learning how to pull POST Data for a register page and send it to a db. Let me know how I did. Note, I've never developed for the web before. [PHP]<?php require_once("Template/index.php"); require("Engine/DBConnect"); $Database = DBConnect::EstablishConnect(); if (isset($_REQUEST["submit"]) && $_POST['username'] != null && $_POST['password'] == $_POST['confirm_password']){ $Username = $_POST['username']; $EncryptedPassword = password_hash($_POST['password'], PASSWORD_BCRYPT); $NewUser = $Database->prepare("INSERT INTO users (username, password) VALUES (?, ?)"); $NewUser->execute([$Username,$EncryptedPassword]); }else if(!isset($_REQUEST["submit"])){ return; }else{ echo "Some fields are missing values"; } [/PHP] [CODE]<?php class DBConnect{ function __construct(){ } public static function EstablishConnect(){ $PDO = new PDO("mysql:host=localhost;dbname=first_site", "root", "password"); return $PDO; } } ?> [/CODE] [CODE]<HTML> <head> <title>Mike's Website</title> </head> <body> <form name = "form" method = "POST"> <center> Username:</br> <input type = "text" name="username"></br> Password:</br> <input type = "text" name="password"></br> Confirm Password:</br> <input type = "text" name="confirm_password"></br> <button type = "submit" name = "submit">Register</button> </center> </form> </body> </HTML> [/CODE] [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
Software Development
Programming
Programming Q&A
[PHP]Code-Review
Top