Log In
Ground Weather Castform Don't have an account yet? Register now!
.

Forum Search

I'm Feeling Lucky

Searching for: Posts from Puru.
Posted: Thu, 06/08/2015 14:22 (9 Years ago)
Wow I have written these codes.Awesome

Now I will work on more codes

[Read more]
Posted: Thu, 06/08/2015 10:03 (9 Years ago)
Today was a real hectic day. I thought I will get a paper but no. But still it will be good if maths paper burn(I didn't performed good) :P

[Read more]
Posted: Wed, 05/08/2015 16:18 (9 Years ago)
Oooh yeah!!!!!!!!!!
I finally reached 508,672 PD


[Read more]
Posted: Wed, 05/08/2015 14:15 (9 Years ago)
So here I will be writing my diary here.First content will be my FA-3 exams results.Just wait and watch! ;)

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]
Posted: Mon, 27/07/2015 13:47 (9 Years ago)
Wow toothie you made such good thread. Thanks

[Read more]
Posted: Sun, 19/07/2015 12:18 (9 Years ago)
How can a mega salamece be so cheap

[Read more]
Posted: Fri, 17/07/2015 07:30 (9 Years ago)
Can I join?

[Read more]
Posted: Sun, 12/07/2015 06:15 (9 Years ago)

Title: PHP

Here We will learn that how to make a userlogin and user register PHP.Remeber you must have a localhost or a server to view PHP or it won't be any use and a PHP in use is never shown on inspect element
User 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]
Posted: Tue, 07/07/2015 14:43 (9 Years ago)
Here is a BB Code suggestion.
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]
Posted: Thu, 25/06/2015 07:09 (9 Years ago)
Human Character
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]
Posted: Tue, 23/06/2015 18:06 (9 Years ago)
Scarlette_Blade asks me how did I made that custom widget in my about me.Well the answer is

[center][spoiler][/center][/spoiler]
[center]
text image you want out of your about me here
[/center]



[Read more]
Posted: Mon, 22/06/2015 22:24 (9 Years ago)
Wool?

[Read more]
Posted: Sun, 21/06/2015 20:39 (9 Years ago)
It's on first page

[Read more]
Posted: Sat, 20/06/2015 10:20 (9 Years ago)

Title: Sorry :,(

um friends sorry I won't be able to put codes here as I have got a virus in my computer and it is undiscovarable by my antivirus.So my browsers are very aweful in condition right now.But if you want to edit any element of PH, ask me anytime and I will give you answer whole-heartedly :D

[Read more]
Posted: Sat, 20/06/2015 10:06 (9 Years ago)
edited code and now it works for me. Thanks Lirah

[Read more]
Posted: Sat, 20/06/2015 09:55 (9 Years ago)
Just let me see it

Now it isn't showing any image

[Read more]
Posted: Sat, 20/06/2015 09:29 (9 Years ago)
This custom widget thing doesn't work for me in about me I will send the code.
[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]
Posted: Sat, 20/06/2015 06:56 (9 Years ago)
I edited my about me and changed my signature today

I really like Brock.And his funny behavior to girls :D


[Read more]
Posted: Thu, 18/06/2015 15:55 (9 Years ago)
Kyorine's party

[Read more]
Posted: Wed, 10/06/2015 04:47 (10 Years ago)
Its garchomp actually
And for your answer its snorlax




I am fire-fight
I have a mega evolution
I was seen last in pokemon xy 8th episode
On of me belong to clement and bonnie's father

[Read more]

<-- Previous site || Next site -->