Thanks Powah :D
Update:
I've set-up 3 pages for the community. Community, News and Staff. All I've added is content boxes so far.
![]()
Thanks Powah :D
Update:
I've set-up 3 pages for the community. Community, News and Staff. All I've added is content boxes so far.
![]()
Some of the snippets that you posted aren't the best... BUT this project is obviously to learn PHP, so that's fine :D you're learning which is a lot more than most people in this section are doing![]()
>using MySQL real escape string
What if the developer puts the data being inputted as an interger (such as an article ID, where quotes aren't necessary)
Instead, actually figure out the things your users should never put in your fields anyway.
Here's my quick script, along with a test result (see attachment):
PHP Code:<?php
mysql_connect("localhost", "root", "lolwat");
class Security
{
private $BadChars = array(
'"',
"--",
"%",
"#",
";",
"SELECT * FROM",
"DELETE FROM",
"DROP TABLE",
"DROP DATABASE"
);
public function secureData($Data)
{
$Data = $this->XSS($Data);
$Data = $this->SQLi($Data);
$Data = trim($Data);
return $Data;
}
private function XSS($Data)
{
return htmlentities($Data);
}
private function SQLi($Data)
{
$Data = mysql_real_escape_string($Data);
$Data = str_ireplace($this->BadChars, "", $Data);
return $Data;
}
}
$Security = new Security();
echo $Security->secureData("' or 1=1;--").'<br />';
echo $Security->secureData("DROP TABLE users;--").'<br />';
echo $Security->secureData("'; SELECT * FROM mysql.users;--").'<br />';
echo $Security->secureData("'; UPDATE users SET password = 'test123';--").'<br />';
?>
After reviewing my code, I figured out that the quotes would make the query error regardless. To fix this, you can easily just filter out the quotes before it does mysql_real_escape_string. ;)
Have fun with this project.
Last edited by Hexadecimal; 14-02-12 at 12:21 AM.
Disappointed, tbh.
It's obviously a learning project, so help the guy out instead of flaming him.
Just make sure you're filtering all dynamic material that will eventually be submitted to the database. Learn and practice security now, so later it'll be an unbreakable habit.![]()
MM good luck I guess.
As far as I was aware, Nominals style was HabboRP's style so I took them from it, My bad.
Ok Registration works 100%, I attempted a new method for logging in and failed, So that is currently broke. What is the best way to log in?
No updates tonight, I'll look into fixing up the login tomorrow.
Looks nice. Good luck. I hope to fully learn PHP one day :)
Very nice Luc :)
Posted via Mobile Device
Ok, I'm stuck on the login system.
What is wrong with that?PHP Code:<?php
include ('global.php');
if(isset($_SESSION['M_USER'] = $username;) == "1")
{
echo 'You are already logged in';
}
else
{
if(isset($_POST['login']))
{
$username = strip_tags(mysql_real_escape_string($_POST['username']));
$password = md5(strip_tags(mysql_real_escape_string($_POST['password'])));
if (empty ($username)||empty($password))
{
echo 'Please enter both fields and try again';
}
else
{
$userQ = mysql_query ("SELECT * FROM users WHERE `username` = '{$username}' ");
if (mysql_num_rows ($userQ)==0)
{
echo 'Please enter a valid username and try again';
}
else
{
$userA = mysql_fetch_array( $userQ );
if ( $password !== $userA["password"] )
{
echo 'This user exists but the password is incorrect please try again';
}
else
{
$_SESSION['M_USER'] = $username;
Header("Location: me.php");
define('LOGGED_IN', true);
}
}
}
}
}