Latest Entries »
Sunday, December 20, 2009
Simple php sample code for privent SQL injection attacts
if(isset($_POST["un"]) && isset($_POST["pw"])){
mysql_connect("localhost","root","");
mysql_select_db("my_db");
$username = mysql_real_escape_string($_POST["un"]);
$password = mysql_real_escape_string($_POST["pw"]);
$sql = "SELECT * FROM user WHERE id = '$username' AND name = '$password';";
$result = mysql_query($sql);
if($result){
if(mysql_num_rows($result)>0){
echo "you loged in....";
}
}
}
?>
Wednesday, December 2, 2009
Mysql with C sharp
dot net commonly use sql server as DBMS. But now it is possible to us Mysql which is open source DBMS commonly use for web developers.
First download latestConnector/Net from http://dev.mysql.com/downloads/connector/net/ link. Install the connector to your pc. This will install the documentation too. You need to add Mysql.Data into the project references before use mysql in your project.
(Solution Explorer -> Your solution -> Your project -> References -> right click -> add reference... -> double click on Mysql.Data)
Now you have to add 'using MySql.Data.MySqlClient;' to the top of your source code.
Try to understand following simple code :
string MyConnString = "SERVER=localhost;" + "DATABASE=database;" + "UID=root;" + "PASSWORD=passoword;";
MySqlConnection connection = newMySqlConnection(MyConnString);
MySqlCommand command = connection.CreateCommand();
MySqlDataReader Reader;
command.CommandText = "select * from tablename";
connection.Open(); Reader = command.ExecuteReader();
while (Reader.Read()) {
string row = "";
for (int i = 0; i <>
row += Reader.GetValue(i).ToString() + " , ";
System.Console.WriteLine(row);
}
connection.Close();
Tuesday, December 1, 2009
How to execute php files without loading it
This method will execute the file_handle.php file and return the html result. So we can simply use this to database updates using this (use get method for pass inputs).
echo "Start";
$result = file("http://localhost/testing/file_handle.php");
echo "end";
?>
Subscribe to:
Posts (Atom)
About Me
Facebook Badge
Followers
Labels
- asterisk (1)
- autorun (1)
- c sharp (1)
- c# (1)
- c# and mysql (1)
- centOS (1)
- class diagram (1)
- cmd (1)
- compare databases (2)
- compare object orienterd databases (1)
- database (2)
- databases (2)
- datetime (1)
- DBMS (1)
- DBMS market (1)
- different detabases (1)
- different object oriented databases (1)
- enable javascript (1)
- ER diagram (2)
- hidden files (1)
- http (1)
- IP PBX (1)
- isNumaric() (1)
- javascript (3)
- jquery. prototype (1)
- linux (2)
- magic (1)
- mail validation (1)
- ms office (1)
- mysql (3)
- object oriented databases (1)
- OODB (1)
- open-source (1)
- opensource (1)
- php (6)
- php file handling function (2)
- report writting (1)
- shell script (1)
- sql (2)
- sql injection (1)
- stored procedure (1)
- target market of DBMSs (1)
- UML (2)
- UML diagrams (2)
- usecase (1)
- virus (1)
- widows (1)
- windows (1)
- windows xp autorun (2)
- word (1)