skedari shuma.php
<?php
if(isset($_POST["nr1"])&& isset($_POST["nr2"])){
echo $_POST["nr1"]+$_POST["nr2"];
}
?>
<html>
<head>
<title>shuma</title>
</head>
<body>
<form name="frm" action="shuma.php" method="POST">
Nr1:<input type="text" id="nr1" name="nr1"><br/>
Nr2:<input type="text" id="nr2" name="nr2"><br/>
<input type="submit" value="llogarit"><br/>
</form>
</body>
</html>
Rezultati:
Ushtrim 1:
Ndertoni nje faqe e cila afishon 2 kuti dhe nje buton llogarit.Kur perdoruesit te fus 2 numra dhe te shtyp butonin llogarit duhet te afishohet shuma e te dy numrave dhe poshte shumes serish dy kutite dhe butoni llogarit.
Ushtrim 2:
Ndertoni nje faqe php qe afishon nje tabele shahu duke marre madhesine e tabeles nga nje fushe teksi paraprakisht nga perdoruesi.
tabeleshahu.php
<html>
<head>
<title></title>
</head>
<body>
<form action="tabeleshahu.php" method="post">
<input type="text" name="dim">
<input type="submit" value="dergo">
<?php
if (isset($_POST['dim']))
{ $dim=$_POST['dim'];
echo "<table width=\"50%\" height=\" 50% \">";
for($i=0; $i<=$dim ;$i++)
{ echo "<tr>";
for($j=0; $j<=$dim; $j++)
{ if(($i+$j)%2==0)
echo "<td bgcolor=\"000000\"></td>";
else
echo "<td bgcolor=\"FFFFFF\"></td>";
}
echo "</tr>";}
echo "</table>";
}
?>
</form>
</body>
</html>
Rezultati:
Ushtrim 3:
Ndertoni nje faqe php e cila merr nga nje fushe texti madhesine e matrices, dhe e bredh matricen si ne figure, duke ndryshuar nderkohe dhe ngjyren kur kalojme nga njera qelize ne nje tjeter. Ne momentin qe ngjyra arrin vleren ne kufijte e intervalit ne te cilin ajo merr ngjyren e fillimit.
bredhja_matrice.php
<html>
<?php
if(!isset($_REQUEST['dim'])) {
?>
<body>
<form action="bredhja_matrice.php" method="get">
<input type="text" name="dim">
<input type="submit" value="dergo">
</form>
<?php
}
else {
$rreshta = $_REQUEST['dim'];
?>
<head>
<script language="javascript">
function afisho(i,j,ngjyra){
document.getElementById("info").innerHTML = "i=" + i + " , j=" + j + " <br>" + ngjyra;
document.getElementById("info").style.backgroundColor = '' + ngjyra;
}
</script>
</head>
<body>
<?php
$dim = $_REQUEST['dim'];
$vlera_ngjyres = 0;
function ngjyra($vlera_ngjyres) {
if($vlera_ngjyres < 15) return "#0".dechex($vlera_ngjyres)."0000";
else return "#".dechex($vlera_ngjyres)."0000";
}
function ndryshoNgjyren() {
global $vlera_ngjyres;
$vlera_ngjyres += 4;
if($vlera_ngjyres > 255) $vlera_ngjyres=0;
}
?>
<table>
<?php
$mbrapsht = false;
for($i=1; $i<=$dim; $i++) {
echo "\n\t<tr>";
for($j=1; $j<=$dim; $j++) {
if($i%2 != 0) {
if(($i-1)%4!=0) {
$vektor[] = "\n\t\t<td bgcolor='".ngjyra($vlera_ngjyres)."' width='30 px' height='30 px' onClick='afisho(".$i.",".$j.",\"".ngjyra($vlera_ngjyres)."\")'> </td>";
$mbrapsht = true;
}
else echo "\n\t\t<td bgcolor='".ngjyra($vlera_ngjyres)."' width='30 px' height='30 px' onClick='afisho(".$i.",".$j.",\"".ngjyra($vlera_ngjyres)."\")'> </td>";
}
elseif($i%4 == 0 && $j==1) echo "\n\t\t<td bgcolor='".ngjyra($vlera_ngjyres)."' width='30 px' height='30 px' onClick='afisho(".$i.",".$j.",\"".ngjyra($vlera_ngjyres)."\")'> </td>";
elseif($i%2 == 0 && ($i%4!=0) && $j==$dim) echo "\n\t\t<td bgcolor='".ngjyra($vlera_ngjyres)."' width='30 px' height='30 px' onClick='afisho(".$i.",".$j.",\"".ngjyra($vlera_ngjyres)."\")'> </td>";
else {
echo "\n\t\t<td> </td>";
continue;
}
ndryshoNgjyren();
}
if($mbrapsht) {
for($k=$dim-1; $k>=0; $k--) echo $vektor[$k];
unset($vektor);
$mbrapsht=false;
}
echo "\n\t</tr>";
}
}
?>
</table>
<br><br>
<table width="300 px" height="300 px" style="text-align:center; color:#fff; font-weight:bold; font-family:Verdana; font-size:large">
<tr>
<td id="info"></td>
</tr>
</table>
</body></html>
Rezultati:
Ushtrim 4:
1. Nedrtoni nje faqe php e cila afishon nje matrice te kontuar me vija me dimensione nxn e cila ne rreshtin e mesit n/2 fsheh nje msg me gjatesi jo me te madhe se n-2. Perdoruesi duhet te jete ne gjendje qe nepermjet nje kliku te afishje shkronjen qe ndodhet ne qelizen perkatese. Ngjyra e backgroundit te tabeles duhet te jete e ndryshme nga ngjyra e backgrounditte qelizave ku fshihet mesazhi bardhe e gri. Perdoruesi me ane nje butoni dueht te jete ne gjendje te hap msg.
skedari fshehja_fjales.php
<html>
<?php
if(!isset($_REQUEST['fusha']))
{
?>
<body>
<form action="fshehja_fjales.php" method="post">
<input type="text" name="fusha" id="fusha"></input>
<input type="submit" value="dergo"></input>
</form>
<?php
}
else {
$fjala=$_REQUEST['fusha'];
?>
<head>
<script language="javascript">
function shfaq(nr) {
document.getElementById("germa"+nr).style.visibility = "visible";
}
function shfaqTeGjitha() {
for(i=0;i< <?php echo strlen($fjala); ?>; i++) document.getElementById("germa"+i).style.visibility = "visible";
}
</script>
<style type="text/css">
td {
text-align:center;
font-weight:bold;
font-size:large;
font-family:monospace;
}
</style>
</head>
<body>
<table border="1">
<?php // {}
$k=0;
for($i=1; $i<=strlen($fjala); $i++) {
echo "<tr height='40 px'>";
for($j=1; $j<=strlen($fjala)+2; $j++) {
if($i == ceil(strlen($fjala)/2) && ($j >= 2) && ($j<=strlen($fjala)+1))
echo "<td bgcolor='#A5A5A5' width='40 px' onClick='shfaq(".$k.")'><span id='germa".$k."' style='visibility:hidden'>".$fjala{$k++}."</span>";
else echo "<td width='40 px' bgcolor=''> ";
echo "</td>";
}
echo "\n\t</tr>";
}
?>
</table>
<br><br>
<a href="javascript:shfaqTeGjitha()">Shfaqi te gjitha</a>
<?php
}
?>
</body>
</html>
Rezultati:
Ushtrim 5:
Ndertoni nje faqe e cila perdoret nga studentet per tu regjistruar ne disa lende. Faqja permban 2 textbox(emri, mbiemri studentit), 4 checkbox(lendet ku do te regjistrohet) dhe nje buton regjistro. Ne klikim te butonit regjistro studentit i shfaqen zgjedhjet e bera.
skedari regjistro.php
<html>
<head>
</head>
<body>
<h2>Regjistrim Viti 3</h2>
<?php
if ( empty($_POST['lendet']) || empty($_POST['emri']) || empty($_POST['mbiemri'])){
?>
<form method="post">
Ju lutem zgjidhni lendet ku doni te regjistroheni: <br />
<input type="checkbox" value="Web" name="lendet[]" />Web<br>
<input type="checkbox" value="OS" name="lendet[]" />OS<br>
<input type="checkbox" value="GIS" name="lendet[]" />GIS<br>
<input type="checkbox" value="DB" name="lendet[]" />DB<br>
Ju lutem jepni emrin dhe mbiemrin tuaj: <br />
<input type="text" name="emri" /><br>
<input type="text" name="mbiemri" /><br>
<input type="submit" name="submit" value="Afisho Regjistrimin" />
</form>
<?php
}else{
$emri = $_POST["emri"];
$mbiemri=$_POST["mbiemri"];
echo $emri.'  '.$mbiemri.'ju jeni regjistruar ne keto lende:';
$i=0;
foreach($_POST['lendet'] as $zgjedhja) {
$i++;
echo '<br><b>'.$i.'.'.$zgjedhja.'</b><br>';
}
}
?>
</body>
</html>