Forum Search
I'm Feeling Lucky
Searching for: Posts from Puru.
Puru OFFLINE ![]() Forum Posts: 99 |
Posted: Thu, 06/08/2015 14:22 (9 Years ago) |
Now I will work on more codes [Read more] |
Puru OFFLINE ![]() Forum Posts: 99 |
Posted: Thu, 06/08/2015 10:03 (9 Years ago) |
[Read more] |
Puru OFFLINE ![]() Forum Posts: 99 |
Posted: Wed, 05/08/2015 16:18 (9 Years ago) |
I finally reached 508,672 PD ![]() [Read more] |
Puru OFFLINE ![]() Forum Posts: 99 |
Posted: Wed, 05/08/2015 14:15 (9 Years ago) |
Today was Hindi's exam and I think I will bring 9/10 in it.Its very bad that whole class cheats and teacher doesn't notices [Read more] |
Puru OFFLINE ![]() Forum Posts: 99 |
Posted: Mon, 27/07/2015 13:47 (9 Years ago) |
[Read more] |
Puru OFFLINE ![]() Forum Posts: 99 |
Posted: Sun, 19/07/2015 12:18 (9 Years ago) |
[Read more] |
Puru OFFLINE ![]() Forum Posts: 99 |
Posted: Sun, 12/07/2015 06:15 (9 Years ago) |
Title: PHPUser registration flow: 1. User fills in Register form in your mobile app and submits information to a server side PHP script 2. Server side PHP script accepts user registration information and stores it in MySQL database 3. Server side PHP script sends back response to mobile app in JSON format. User login flow: 1. User types in user name and password in your mobile app and taps on a login button to login 2. Mobile app sends information to a server side PHP script 3. Server side PHP script checks if user with provided user name and password exists 4. Server side PHP script sends back a response to my mobile app in a JSON format. Let’s assume we have MySQL database created and it is called “swift_developer”. In our database we have a table called “users” with a very simple structure: +---------------+-------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +---------------+-------------+------+-----+---------+----------------+ | id | int(11) | NO | PRI | NULL | auto_increment | | user_email | varchar(50) | NO | | NULL | | | user_password | varchar(32) | NO | | NULL | | +---------------+-------------+------+-----+---------+----------------+ To connect to this database I am going to create 4 PHP scripts: 1. Conn.php This file will contain database access details 2. MySQLDao.php This file will contain all MySQL queries 3. userRegister.php Business logic to store user registration details into a database table 4. userLogin.php Business logic to check if user with provided user name and password exist in our database Now, let’s implement Conn.php script <?phpclass Conn { public static $dbhost = “localhost”; public static $dbuser = “< provide here user name to your database>; public static $dbpass = “< password you use to access database >”; public static $dbname = ” <database name> “; } ?> Next, lets implement MySQLDao.php <?phpclass MySQLDao { var $dbhost = null; var $dbuser = null; var $dbpass = null; var $conn = null; var $dbname = null; var $result = null; function __construct() { $this->dbhost = Conn::$dbhost; $this->dbuser = Conn::$dbuser; $this->dbpass = Conn::$dbpass; $this->dbname = Conn::$dbname; } public function openConnection() { $this->conn = new mysqli($this->dbhost, $this->dbuser, $this->dbpass, $this->dbname); if (mysqli_connect_errno()) echo new Exception(“Could not establish connection with database”); } public function getConnection() { return $this->conn; } public function closeConnection() { if ($this->conn != null) $this->conn->close(); } public function getUserDetails($email) { $returnValue = array(); $sql = “select * from users where user_email='” . $email . “‘”; $result = $this->conn->query($sql); if ($result != null && (mysqli_num_rows($result) >= 1)) { $row = $result->fetch_array(MYSQLI_ASSOC); if (!empty($row)) { $returnValue = $row; } } return $returnValue; } public function getUserDetailsWithPassword($email, $userPassword) { $returnValue = array(); $sql = “select id,user_email from users where user_email='” . $email . “‘ and user_password='” .$userPassword . “‘”; $result = $this->conn->query($sql); if ($result != null && (mysqli_num_rows($result) >= 1)) { $row = $result->fetch_array(MYSQLI_ASSOC); if (!empty($row)) { $returnValue = $row; } } return $returnValue; } public function registerUser($email, $password) { $sql = “insert into users set user_email=?, user_password=?”; $statement = $this->conn->prepare($sql); if (!$statement) throw new Exception($statement->error); $statement->bind_param(“ss”, $email, $password); $returnValue = $statement->execute(); return $returnValue; } } ?> We can now make use of these two scripts to write business logic to register a new user: userRegister.php <?phprequire(“Conn.php”); require(“MySQLDao.php”); $email = htmlentities($_POST[“email”]); $password = htmlentities($_POST[“password”]); $returnValue = array(); if(empty($email) || empty($password)) { $returnValue[“status”] = “error”; $returnValue[“message”] = “Missing required field”; echo json_encode($returnValue); return; } $dao = new MySQLDao(); $dao->openConnection(); $userDetails = $dao->getUserDetails($email); if(!empty($userDetails)) { $returnValue[“status”] = “error”; $returnValue[“message”] = “User already exists”; echo json_encode($returnValue); return; } $secure_password = md5($password); // I do this, so that user password cannot be read even by me $result = $dao->registerUser($email,$secure_password); if($result) { $returnValue[“status”] = “Success”; $returnValue[“message”] = “User is registered”; echo json_encode($returnValue); return; } $dao->closeConnection(); ?> and the final script is to check is to check is user is found in our table of registered users or not: userLogin.php <?phprequire(“Conn.php”); require(“MySQLDao.php”); $email = htmlentities($_POST[“email”]); $password = htmlentities($_POST[“password”]); $returnValue = array(); if(empty($email) || empty($password)) { $returnValue[“status”] = “error”; $returnValue[“message”] = “Missing required field”; echo json_encode($returnValue); return; } $secure_password = md5($password); $dao = new MySQLDao(); $dao->openConnection(); $userDetails = $dao->getUserDetailsWithPassword($email,$secure_password); if(!empty($userDetails)) { $returnValue[“status”] = “Success”; $returnValue[“message”] = “User is registered”; echo json_encode($returnValue); } else { $returnValue[“status”] = “error”; $returnValue[“message”] = “User is not found”; echo json_encode($returnValue); } $dao->closeConnection(); ?> [Read more] |
Puru OFFLINE ![]() Forum Posts: 99 |
Posted: Tue, 07/07/2015 14:43 (9 Years ago) |
When you use [url] tag of with some other's website link(sorry for my bad grammer),The link you copy is like http://website.com/webpage.And when you are posting a huge post in notifications it is very important as even each character is very very important.So just remove the http: from the link and make your posts even more shorter for yours.Here is code and example Instead of
[url=http://gpxplux.net]GPX[/url]
use[url=//gpxplux.net]GPX[/url]
So I know it doesn't means that much but its still useful [Read more] |
Puru OFFLINE ![]() Forum Posts: 99 |
Posted: Thu, 25/06/2015 07:09 (9 Years ago) |
Username: NurseJoy Character Name:Joy Character Gender:Female Appearance: Cute,kind like Nurse Joy Biography: Having 15 same looking sisters,I am annoyed of being the smallest.I want to become the best Current Party:Mega able Garchomp,Greninja,eggs Password:Sycamore Human Character’s Pokémon Species:Mach Nickname: Mega Sharky Gender:Female Level:70 Ability:Sand Veil Rough Skin (hidden ability) Moveset:All attacks listed her.Only egg moves and moves learnt by level up Other: (Optional) [Read more] |
Puru OFFLINE ![]() Forum Posts: 99 |
Posted: Tue, 23/06/2015 18:06 (9 Years ago) |
[center][spoiler][/center][/spoiler]
[center] text image you want out of your about me here [/center] [Read more] |
Puru OFFLINE ![]() Forum Posts: 99 |
Posted: Sun, 21/06/2015 20:39 (9 Years ago) |
[Read more] |
Puru OFFLINE ![]() Forum Posts: 99 |
Posted: Sat, 20/06/2015 10:20 (9 Years ago) |
Title: Sorry :,([Read more] |
Puru OFFLINE ![]() Forum Posts: 99 |
Posted: Sat, 20/06/2015 10:06 (9 Years ago) |
[Read more] |
Puru OFFLINE ![]() Forum Posts: 99 |
Posted: Sat, 20/06/2015 09:55 (9 Years ago) |
Now it isn't showing any image [Read more] |
Puru OFFLINE ![]() Forum Posts: 99 |
Posted: Sat, 20/06/2015 09:29 (9 Years ago) |
[center][img]http://blog.flamingtext.com/blog/2015/06/20/flamingtext_com_1434782002_660110295.png[/img][img]//staticpokeheroes.com/img/dw_plushies/0656.png[/img]
[img]//staticpokeheroes.com/img/event_distribution/interact_progress.php?percent=24&col=1[/img] [color=aqua][size=16]12/50[/size][/color] [color=aqua][size=16]And help my specials please:D [/size][spoiler][widget=inter]3661349[/widget][widget=inter]3866770[/widget][widget=inter]3712976[/widget][widget=inter]3345078[/widget][widget=inter]3661106[/widget][widget=inter]3706067[/widget][widget=inter]3622856[/widget][/spoiler][/color] [/center] [center][spoiler] .[/spoiler] [img]http://blog.flamingtext.com/blog/2015/06/20/flamingtext_com_1434782002_660110295.png[/img] [/center] [Read more] |
Puru OFFLINE ![]() Forum Posts: 99 |
Posted: Sat, 20/06/2015 06:56 (9 Years ago) |
I really like Brock.And his funny behavior to girls :D [Read more] |