Html Karakter Sınırlandırma

$al=new cutHTML;
$al->text="<p><a>Merhaba</a></p>";
$al->lenght="5";
echo $al->write();
//Çıktısı "Merha"
class cutHTML {
 public $text="";
 public $length="";
public function write(){
 $this->text=htmlspecialchars_decode($this->text);
 $entities = array('À'=>'&Agrave;','à'=>'&agrave;','Á'=>'&Aacute;','á'=>'&aacute;','Â'=>'&Acirc;','â'=>'&acirc;',
 'Ã'=>'&Atilde;','ã'=>'&atilde;','Ä'=>'&Auml;','ä'=>'&auml;','Å'=>'&Aring;','å'=>'&aring;','Æ'=>'&AElig;','æ'=>'&aelig;',
 'Ç'=>'&Ccedil;','ç'=>'&ccedil;','?'=>'&ETH;','?'=>'&eth;','È'=>'&Egrave;','è'=>'&egrave;','É'=>'&Eacute;','é'=>'&eacute;',
 'Ê'=>'&Ecirc;','ê'=>'&ecirc;','Ë'=>'&Euml;','ë'=>'&euml;','Ì'=>'&Igrave;','ì'=>'&igrave;','Í'=>'&Iacute;','í'=>'&iacute;',
 'Î'=>'&Icirc;','î'=>'&icirc;','Ï'=>'&Iuml;','ï'=>'&iuml;','Ñ'=>'&Ntilde;','ñ'=>'&ntilde;','Ò'=>'&Ograve;','ò'=>'&ograve;',
 'Ó'=>'&Oacute;','ó'=>'&oacute;','Ô'=>'&Ocirc;','ô'=>'&ocirc;','Õ'=>'&Otilde;','õ'=>'&otilde;','Ö'=>'&Ouml;','ö'=>'&ouml;',
 'Ø'=>'&Oslash;','ø'=>'&oslash;','Œ'=>'&OElig;','œ'=>'&oelig;','ß'=>'&szlig;','?'=>'&THORN;','?'=>'&thorn;','Ù'=>'&Ugrave;',
 'ù'=>'&ugrave;','Ú'=>'&Uacute;','ú'=>'&uacute;','Û'=>'&Ucirc;','û'=>'&ucirc;','Ü'=>'&Uuml;','ü'=>'&uuml;','?'=>'&Yacute;',
 '?'=>'&yacute;','Ÿ'=>'&Yuml;','ÿ'=>'&yuml;');
 foreach ($entities as $key => $value){$ent[] = $key;$html_ent[] = $value;}
 $this->text = str_replace( $html_ent, $ent, $this->text );
 $this->text=strip_tags($this->text);
 $this->text=substr($this->text, 0, $this->length);
 $this->text=htmlspecialchars($this->text);
 return $this->text;
 }
}

Css Url Ayrıştırma

HTML
37 lines
·<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
<style type="text/css">
div{
background-color:#eee;
padding:5px;
}
span{
background-color:#4fc81f;
display:block;
padding:5px;
}
</style>
<title></title>
</head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<body>
<span class="result1"></span>
<span class="result2"></span>
<div id="test1">background-image: url(../images/background.png)</div>
<div id="test2">background-image: url('../images/background.png')</div>
<div id="test3">background-image: url("/assets/images/loginlogo.png")</div>
<div id="test4">background-image: url(/assets/images/loginlogo.png)</div>
<div id="test4">background-image: url(assets/images/loginlogo.png)</div>
<script type="text/javascript">
var al= $( "#test3" ).text();
var url=/url\((.*?)\)/.exec(al);
purl=url[1].replace('"','').replace("'","").replace('"',"").replace("'","");
$( ".result1" ).html(url[0]);
$( ".result2" ).html(purl);
</script>
</body>
</html>
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

 

Menüye Tıklayarak Anlık Sayfa Çağırma

PHP
34 lines
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
<title></title>
<script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>
<style type="text/css">
body{min-width:600px;}
div{float:left;margin:1vh;padding:1vw;border:1vh solid #ccc;}
.AdminMenu{width:15vw;}
.Icerik{width:70vw;}
</style>
</head>
<body>
<span id="Kapsa">
<div class="AdminMenu">
<a href="#" data="sayfa1.php" class="adminlink">Sayfa 1</a>
<a href="#" data="sayfa2.php" class="adminlink">Sayfa 2</a>
<script>
$( ".adminlink" ).click(function() {
var link = $( this ).attr( "data" );
$.ajax({url: link,success: function(data) { $('.Icerik').html(data);}});
});
</script>
</div>
<div class="Icerik">
ben bir varsayılan içeriğim<br>
tıklanan linkteki html içerikler benimle değişir.
linklerdeki data="" kısmına yazdığınız adresler çağırır.
</div>
</span>
</body>
</html>
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

 

Konu İsmini Başlığa Yazdırmak

Bildiğiniz üzere php’de değişkeni kendisinden sonra echo ile yazdırabiliyoruz.Genelde konular body kısmında olduğu için head daki <title> tagına jquery ile ulaşıp değiştirebiliriz.

<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
	<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
</head>
<body>
	<div class="sayfam">
	<?php
	$baslik  ="Merhaba Dünya";
	?>
		<div id="baslik">
		<?php echo $baslik; ?>
		<script type="text/javascript">$(document).attr('title', '<?php echo $baslik; ?>');</script>
		</div>
	</div>
</body>
</html>

Şifre Zorluğu Gösterimi

HTML
161 lines
<html>
<head>
<style>
body
{
/*ie needs this*/
margin:0px;
padding:0px;
/*set global font settings*/
font-size:10px;
font-family:Tahoma,Verdana,Arial;
}
a:hover
{
color:#fff;
}
#user_registration
{
border:1px solid #cccccc;
margin:auto auto;
margin-top:100px;
width:400px;
}
#user_registration label
{
display: block; /* block float the labels to left column, set a width */
float: left;
width: 70px;
margin: 0px 10px 0px 5px;
text-align: right;
line-height:1em;
font-weight:bold;
}
#user_registration input
{
width:250px;
}
#user_registration p
{
clear:both;
}
#submit
{
border:1px solid #cccccc;
width:100px !important;
margin:10px;
}
h1
{
text-align:center;
}
#passwordStrength
{
height:10px;
display:block;
float:left;
}
.strength0
{
width:250px;
background:#cccccc;
}
.strength1
{
width:50px;
background:#ff0000;
}
.strength2
{
width:100px;
background:#ff5f5f;
}
.strength3
{
width:150px;
background:#56e500;
}
.strength4
{
background:#4dcd00;
width:200px;
}
.strength5
{
background:#399800;
width:250px;
}
</style>
</style>
<script>
function passwordStrength(password)
{
var desc = new Array();
desc[0] = "Çok Zayıf";
desc[1] = "Zayıf";
desc[2] = "İdare Eder";
desc[3] = "Orta";
desc[4] = "Güçlü";
desc[5] = "Çok Güçlü";
var score = 0;
//if password bigger than 6 give 1 point
if (password.length > 6) score++;
//if password has both lower and uppercase characters give 1 point
if ( ( password.match(/[a-z]/) ) && ( password.match(/[A-Z]/) ) ) score++;
//if password has at least one number give 1 point
if (password.match(/d+/)) score++;
//if password has at least one special caracther give 1 point
if ( password.match(/.[!,@,#,$,%,^,&,*,?,_,~,-,(,)]/) ) score++;
//if password bigger than 12 give another 1 point
if (password.length > 12) score++;
document.getElementById("passwordDescription").innerHTML = desc[score];
document.getElementById("passwordStrength").className = "strength" + score;
}
</script>
</head>
<body>
<form method="post" action="" id="user_registration" name="user_registration">
<p><h1>Kayıt Formu</h1></p>
<p>
<label for="user">Kullanıcı Adı</label><input type="text" name="user" id="user"/>
</p>
<p>
<label for="pass">Şifre</label><input type="password" name="pass" id="pass" onkeyup="passwordStrength(this.value)"/>
</p>
<p>
<label for="passwordStrength">Şifre Zorluğu</label>
<div id="passwordDescription">Şifre Girilmedi</div>
<div id="passwordStrength" class="strength0"></div>
</p>
<p>
<input type="submit" name="submit" id="submit" value="Kayıt Ol">
</p>
</form>
</body>
</html>
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

 

E-Mail Adresi Doğruluğunu Kontrol Etmek

PHP
17 lines
<?php
function mailKontrol($mail) {
if ( filter_var($mail, FILTER_VALIDATE_EMAIL) ) {
echo "Doğru email adresi";
} else {
echo "Hatalı email adresi";
}
}
if($_POST){
mailKontrol($_POST["email"]);
}
?>
<form method="post" action="">
<input type="email" name="email"/>
<button type="submit">Kontrol Et</button>
</form>
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

 

Seçenek Seçerek Otomatik Yönlendirme

HTML
6 lines
<SELECT onchange='window.location.href="?sehir="+this.options[this.selectedIndex].value'>
<OPTION selected VALUE="0">Bir şehir seçmelisiniz</OPTION>
<OPTION VALUE="3">Konya</OPTION>
<OPTION VALUE="2">Ankara</OPTION>
<OPTION VALUE="1">Eskişehir</OPTION>
</SELECT>
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

 

Onaya Göre İsim Listelemek

Veritabanımızı oluşturalım

MySQL
14 lines
CREATE TABLE uretim
(
id int auto_increment primary key,
musteri varchar(255),
adet int(11),
onay int(1)
);
INSERT INTO uretim (id,musteri,adet,onay)
VALUES
(1, '1.Müşteri',5,0),
(2, '2.Müşteri',8,1),
(3, '3.Müşteri',2,2),
(4, '4.Müşteri',7,3);
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

baglan.php adlı dosyamızdan veritabanı bağlantımızı oluşturmuş varsayıp, kodlarımızı ekliyoruz.

PHP
82 lines
<?php include "baglan.php";
?>
<table border="1" bordercolor="#111111" width="100%">
<tr>
<td width="25%" >
<table border="1" bordercolor="#111111" width="100%">
<tbody>
<th>Bekleyen</th>
</tbody>
<thead>
<tr>
<td>Müşteri Adı</td><td>Adet</td>
</tr>
<?php
$veri=mysql_query("select * table uretim Where onay = 1");
while($v=mysql_fetch_array($veri)){
echo '<tr><td>'.$v["musteri"].'</td><td>'.$v["adet"].'</td>';
}
?>
</tr>
</thead>
</table>
</td>
<td width="25%" >
<table border="1" bordercolor="#111111" width="100%">
<tbody>
<th>Kaplama</th>
</tbody>
<thead>
<tr>
<td>Müşteri Adı</td><td>Adet</td>
</tr>
<?php
$veri=mysql_query("select * table uretim Where onay = 2");
while($v=mysql_fetch_array($veri)){
echo '<tr><td>'.$v["musteri"].'</td><td>'.$v["adet"].'</td>';
}
?>
</tr>
</thead>
</table>
</td>
<td width="25%" >
<table border="1" bordercolor="#111111" width="100%">
<tbody>
<th>Taşlama</th>
</tbody>
<thead>
<tr>
<td>Müşteri Adı</td><td>Adet</td>
</tr>
<?php
$veri=mysql_query("select * table uretim Where onay = 3");
while($v=mysql_fetch_array($veri)){
echo '<tr><td>'.$v["musteri"].'</td><td>'.$v["adet"].'</td>';
}
?>
</tr>
</thead>
</table>
</td>
<td width="25%" >
<table border="1" bordercolor="#111111" width="100%">
<tbody>
<th>Sevkiyat</th>
</tbody>
<thead>
<tr>
<td>Müşteri Adı</td><td>Adet</td>
</tr>
<?php
$veri=mysql_query("select * table uretim Where onay = 1");
while($v=mysql_fetch_array($veri)){
echo '<tr><td>'.$v["musteri"].'</td><td>'.$v["adet"].'</td>';
}
?>
</tr>
</thead>
</table>
</td>
</tr>
</table>
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX