Tampilkan postingan dengan label html. Tampilkan semua postingan
Tampilkan postingan dengan label html. Tampilkan semua postingan

Kamis, 01 November 2012

HTMLSPECIALCHARS

HTMLSPECIALCHARS

Fungsi htmlspecialchars() diunakan untuk mnegubah fungsi tag html ke karakter tertentu menjadi kode-kode HTML. htmlspecialchars mempunyai kelebihan, yaitu membuat tampilan website agar tetap rapi sesuai dengan peraturan website/blog.
beberapa karakter tersebut adalah 


HTML
Hasil konversi
& (dan)
& (mencetak tanda & pada browser)
" (petik ganda)
" (mencetak tanda petik pada browser)
' (petik tunggal)
' (mencetak tanda petik tunggal pada browser)
< (lebih kecil)
< (mencetak tanda lebih kecil pada browser)
> (lebih besar)
> (mencetak tanda lebih besar pada browser)

Syntax 

htmlspecialchars(string,quotestyle,character-set)

Contoh


<?php
$text = '<a href=index.php>belajar</a> <?php echo " inject ah"; ?>';
$a = htmlentities($text);
$b = htmlspecialchars($text);
$c = strip_tags($text);
echo $a;
echo "<br>";
echo $b;
echo "<br>";
echo $c;
?>

Hasil Eksekusi



Minggu, 28 Oktober 2012

Introduction MySQL


MySQL is one of the databases, a place to put the data in a structured form of tables and we can do a query or process the data with SQL (Structured Query Language). Tools that can be used one of them is phpmyadmin, with this tool, we do not have to hafalm with SQL select command, create, update.
Here I will explain how to create web pages using PHP and MySQL.
The first step is to connect to the database. And make sure that our local server is already active.

<?php
$koneksi = mysql_connect("localhost","root","");

if($koneksi){
            echo "Koneksi berhasil";
}else{
            echo "Gagal";
}
?>

The next step is to create a database. There are 2 ways that can be used, the first one is using phpmyadmin



Once filled with the name of the database, click Create. Next is to create a table.




Enter the name of the table you want, then enter the number of columns, and click Go. Then the display appears as below


Note:
null means that at the time of filling the database, bukuid field can not be empty.
Index to define as the primary key or other
A_I short for auto increment, Auto Increment function to generate a unique number when a new data entered. This will happen automatically every the addition of new data


In addition, we can also create a database using PHP, the following syntax
<?php

//lakukan koneksi ke MySQL
mysql_connect("localhost","root","");

//pilih database tempat tabel akan dibuat
mysql_select_db("nama_database");

$query = "CREATE TABLE nama_tabel(
            bukuid int(5) auto_increment primary key,
            judul varchar(50),
            tahun year,
            pengarang varchar (50),
            penerbit varchar (30)
)";

//jalankan query
$buat = mysql_query($query);

if($buat){
            echo "Tabel nama_tabel berhasil dibuat";
}else{
            echo "Gagal";
}
?>

Good Luck!