Hello, my name is Modestas and I am working with php. So I am newbie in this forum and i want to listen to your opinion about php.(How to do something the best and secured way.)…
Here is my code:
[php]class Withdraw
{
private $errors;
public function connect()
{
mysql_connect( SQL_HOST, SQL_USER, SQL_PASS ) or die ( mysql_error() );
mysql_select_db( SQL_DB ) or die ( mysql_error() );
}
public function __construct()
{
$this->errors = array();
$this->id = 0;
}
public function getWithDraw( $id, $username )
{
$this->connect();
$data = mysql_query( "SELECT * FROM accounts WHERE id = '$id' AND username = '$username'" );
$list = mysql_fetch_array( $data );
return $list[‘withdraw’];
}
public function show_errors()
{
echo “
Errros
”;foreach( $this->errors as $key=>$value )
echo $value."
";
}
}[/php]
As you can see, i use only “public” function so i wanted to ask you guys about other strings like “private”,“static” and so on.
So question: is my code secure? In this code what should i use in functions for more secure and better code? or maybe i need to rename functions for more secure class?
This code is only example i just coded it like i usualy code, but i think my coding has some wrong coded parts. so it would be great if you give me some opinion or examples, how should it look.