Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- c:\users\lalikali\desktop\web\txt\addcslash.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <body>
- <?php
- $str = "Welcome to my humble Homepage!";
- echo $str."<br>";
- echo addcslashes($str,'A..Z')."<br>";
- echo addcslashes($str,'a..z')."<br>";
- echo addcslashes($str,'a..g');
- ?>
- </body>
- </html>
- Welcome to my humble Homepage!
- \Welcome to my humble \Homepage!
- W\e\l\c\o\m\e \t\o \m\y \h\u\m\b\l\e H\o\m\e\p\a\g\e!
- W\el\com\e to my hum\bl\e Hom\ep\a\g\e!
- c:\users\lalikali\desktop\web\txt\addslash.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <body>
- <?php
- $str = addslashes('What does "yolo" mean?');
- echo($str);
- ?>
- </body>
- </html>
- Rezultati:What does \"yolo\" mean?
- c:\users\lalikali\desktop\web\txt\arsort.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <body>
- <?php
- $age = array("Peter"=>"35", "Ben"=>"37", "Joe"=>"43");
- arsort($age);
- foreach($age as $x => $x_value) {
- echo "Key=" . $x . ", Value=" . $x_value;
- echo "<br>";
- }
- ?>
- </body>
- </html>
- Key=Joe, Value=43
- Key=Ben, Value=37
- Key=Peter, Value=35
- c:\users\lalikali\desktop\web\txt\asort.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <body>
- <?php
- $age = array("Peter"=>"35", "Ben"=>"37", "Joe"=>"43");
- asort($age);
- foreach($age as $x => $x_value) {
- echo "Key=" . $x . ", Value=" . $x_value;
- echo "<br>";
- }
- ?>
- </body>
- </html>
- Key=Peter, Value=35
- Key=Ben, Value=37
- Key=Joe, Value=43
- c:\users\lalikali\desktop\web\txt\assignment.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <body>
- <h1>The += Operator</h1>
- <p id="demo"></p>
- <script>
- var x = 10;
- x += 5;
- document.getElementById("demo").innerHTML = x;
- </script>
- </body>
- </html>
- c:\users\lalikali\desktop\web\txt\assignment2.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <body>
- <h1>JavaScript Operators</h1>
- <p>The assignment operator += can concatenate strings.</p>
- <p id="demo"></p>
- <script>
- txt1 = "What a very ";
- txt1 += "nice day";
- document.getElementById("demo").innerHTML = txt1;
- </script>
- </body>
- </html>
- c:\users\lalikali\desktop\web\txt\assignment3.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <body>
- <h1>JavaScript Operators</h1>
- <p>Adding a number and a string, returns a string.</p>
- <p id="demo"></p>
- <script>
- var x = 5 + 5;
- var y = "5" + 5;
- var z = "Hello" + 5;
- document.getElementById("demo").innerHTML =
- x + "<br>" + y + "<br>" + z;
- </script>
- </body>
- </html>
- c:\users\lalikali\desktop\web\txt\attachments.txt
- <---------------------------------------------------------------------->
- <?php
- // kerkojme ndryshoret // e rendesishme
- $from = $_REQUEST["from"];
- $emaila = $_REQUEST["emaila"];
- $filea = $_REQUEST["filea"];
- if ($filea) {
- function mail_attachment ($from , $to, $subject, $message, $attachment){
- $fileatt = $attachment; // rruga e file-it
- $fileatt_type = "application/octet-stream"; //lloji i file-it
- $start = strrpos($attachment, '/') == -1 ?
- strrpos($attachment, '//') : strrpos($attachment, '/')+1;
- $fileatt_name = substr($attachment, $start,
- strlen($attachment)); // emri i file-it qe do perdoret per file-in si attachment
- $email_from = $from; // kush e dergon emailin
- $subject = "New Attachment Message";
- $email_subject = $subject; // subjekti
- $email_txt = $message; // mesazhi
- $email_to = $to; // kujt i dergohet
- $headers = "From: ".$email_from;
- $file = fopen($fileatt,'rb');
- $data = fread($file,filesize($fileatt));
- fclose($file);
- $msg_txt="\n\n You have recieved a new attachment message from $from";
- $semi_rand = md5(time());
- $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
- $headers .= "\nMIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n" . "
- boundary=\"{$mime_boundary}\"";
- $email_txt .= $msg_txt;
- $email_message .= "This is a multi-part message in MIME format.\n\n" .
- "--{$mime_boundary}\n" . "Content-Type:text/html;
- charset = \"iso-8859-1\"\n" . "Content-Transfer-Encoding: 7bit\n\n" .
- $email_txt . "\n\n";
- $data = chunk_split(base64_encode($data));
- $email_message .= "--{$mime_boundary}\n" . "Content-Type: {$fileatt_type};\n" .
- " name = \"{$fileatt_name}\"\n" . //"Content-Disposition: attachment;\n" .
- //" filename = \"{$fileatt_name}\"\n" . "Content-Transfer-Encoding:
- base64\n\n" . $data . "\n\n" . "--{$mime_boundary}--\n";
- $ok = mail($email_to, $email_subject, $email_message, $headers);
- if($ok) {
- echo "File Sent Successfully.";
- unlink($attachment); // delete a file after attachment sent.
- }else {
- die("Sorry but the email could not be sent. Please go back and try again!");
- }
- }
- move_uploaded_file($_FILES["filea"]["tmp_name"],
- 'temp/'.basename($_FILES['filea']['name']));
- mail_attachment("$from", "youremailaddress@gmail.com",
- "subject", "message", ("temp/".$_FILES["filea"]["name"]));
- }
- ?>
- <html>
- <head>
- <script language = "javascript" type = "text/javascript">
- function CheckData45() {
- with(document.filepost) {
- if(filea.value ! = "") {
- document.getElementById('one').innerText =
- "Attaching File ... Please Wait";
- }
- }
- }
- </script>
- </head>
- <body>
- <table width = "100%" height = "100%" border = "0"
- cellpadding = "0" cellspacing = "0">
- <tr>
- <td align = "center">
- <form name = "filepost" method = "post"
- action = "file.php" enctype = "multipart/form-data" id = "file">
- <table width = "300" border = "0" cellspacing = "0"
- cellpadding = "0">
- <tr valign = "bottom">
- <td height = "20">Your Name:</td>
- </tr>
- <tr>
- <td><input name = "from" type = "text"
- id = "from" size = "30"></td>
- </tr>
- <tr valign = "bottom">
- <td height = "20">Your Email Address:</td>
- </tr>
- <tr>
- <td class = "frmtxt2"><input name = "emaila"
- type = "text" id = "emaila" size = "30"></td>
- </tr>
- <tr>
- <td height = "20" valign = "bottom">Attach File:</td>
- </tr>
- <tr valign = "bottom">
- <td valign = "bottom"><input name = "filea"
- type = "file" id = "filea" size = "16"></td>
- </tr>
- <tr>
- <td height = "40" valign = "middle"><input
- name = "Reset2" type = "reset" id = "Reset2" value = "Reset">
- <input name = "Submit2" type = "submit"
- value = "Submit" onClick = "return CheckData45()"></td>
- </tr>
- </table>
- </form>
- <center>
- <table width = "400">
- <tr>
- <td id = "one">
- </td>
- </tr>
- </table>
- </center>
- </td>
- </tr>
- </table>
- </body>
- </html>
- c:\users\lalikali\desktop\web\txt\body.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <body>
- <h1>JavaScript in Body</h1>
- <p id="demo">A Paragraph.</p>
- <button type="button" onclick="myFunction()">Try it</button>
- <script>
- function myFunction() {
- document.getElementById("demo").innerHTML = "Paragraph changed.";
- }
- </script>
- </body>
- </html>
- c:\users\lalikali\desktop\web\txt\border-spacing.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <head>
- <style>
- table, th, td {
- border: 1px solid black;
- padding: 5px;
- }
- table {
- border-spacing: 15px;
- }
- </style>
- </head>
- <body>
- <table style="width:100%">
- <tr>
- <td>Jill</td>
- <td>Smith</td>
- <td>50</td>
- </tr>
- <tr>
- <td>Eve</td>
- <td>Jackson</td>
- <td>94</td>
- </tr>
- <tr>
- <td>John</td>
- <td>Doe</td>
- <td>80</td>
- </tr>
- </table>
- <p>Try to change the border-spacing to 5px.</p>
- </body>
- </html>
- c:\users\lalikali\desktop\web\txt\break.txt
- <---------------------------------------------------------------------->
- <html>
- <body>
- <?php
- $i = 0;
- while( $i < 10)
- {
- $i++;
- if( $i == 3 )break;
- }
- echo ("Loop stopped at i = $i" );
- ?>
- </body>
- </html>
- c:\users\lalikali\desktop\web\txt\caption.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <head>
- <style>
- table, th, td {
- border: 1px solid black;
- border-collapse: collapse;
- }
- th, td {
- padding: 5px;
- text-align: left;
- }
- </style>
- </head>
- <body>
- <table style="width:100%">
- <caption>Monthly savings</caption>
- <tr>
- <th>Month</th>
- <th>Savings</th>
- </tr>
- <tr>
- <td>January</td>
- <td>$100</td>
- </tr>
- <tr>
- <td>February</td>
- <td>$50</td>
- </tr>
- </table>
- </body>
- </html>
- c:\users\lalikali\desktop\web\txt\charAt.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <body>
- <p>The charAt() method returns the character at a given position in a string:</p>
- <p id="demo"></p>
- <script>
- var str = "HELLO WORLD";
- document.getElementById("demo").innerHTML = str.charAt(0);
- </script>
- </body>
- </html>
- c:\users\lalikali\desktop\web\txt\chop.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <body>
- <?php
- $str = "Hello World!\n\n";
- echo $str;
- echo chop($str);
- ?>
- </body>
- </html>
- Hello World! Hello World!
- c:\users\lalikali\desktop\web\txt\chunk_split.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <body>
- <?php
- $str = "Hello world!";
- echo chunk_split($str,1,".");
- ?>
- </body>
- </html>
- Rez: H.e.l.l.o. .w.o.r.l.d.!.
- c:\users\lalikali\desktop\web\txt\colgroup.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <head>
- <style>
- table, th, td {
- border: 1px solid black;
- }
- </style>
- </head>
- <body>
- <table>
- <colgroup>
- <col span="2" style="background-color:red">
- <col style="background-color:yellow">
- </colgroup>
- <tr>
- <th>ISBN</th>
- <th>Title</th>
- <th>Price</th>
- </tr>
- <tr>
- <td>3476896</td>
- <td>My first HTML</td>
- <td>$53</td>
- </tr>
- <tr>
- <td>5869207</td>
- <td>My first CSS</td>
- <td>$49</td>
- </tr>
- </table>
- </body>
- </html>
- c:\users\lalikali\desktop\web\txt\concat.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <body>
- <p>The concat() method joins two or more strings:</p>
- <p id="demo"></p>
- <script>
- var text1 = "Hello";
- var text2 = "World!";
- document.getElementById("demo").innerHTML = text1.concat(" ",text2);
- </script>
- </body>
- </html>
- c:\users\lalikali\desktop\web\txt\console.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <body>
- <h1>My First Web Page</h1>
- <p>My first paragraph.</p>
- <p>
- Activate debugging in your browser (Chrome, IE, Firefox) with F12, and select "Console" in the debugger menu.
- </p>
- <script>
- console.log(5 + 6);
- </script>
- </body>
- </html>
- c:\users\lalikali\desktop\web\txt\continue.txt
- <---------------------------------------------------------------------->
- <html>
- <body>
- <?php
- $array = array( 1, 2, 3, 4, 5);
- foreach( $array as $value )
- {
- if( $value == 3 )continue;
- echo "Value is $value <br />";
- }
- ?>
- </body>
- </html>
- Value is 1
- Value is 2
- Value is 4
- Value is 5
- c:\users\lalikali\desktop\web\txt\ctype.txt
- <---------------------------------------------------------------------->
- <?php
- $strings = array('1820.20', '10002', 'wsl!12');
- foreach ($strings as $testcase) {
- if (ctype_digit($testcase)) {
- echo "The string $testcase consists of all digits.\n";
- } else {
- echo "The string $testcase does not consist of all digits.\n";
- }
- }
- ?>
- The string 1820.20 does not consist of all digits.
- The string 10002 consists of all digits.
- The string wsl!12 does not consist of all digits.
- <?php
- $field = $_POST["field"];
- if(!ctype_digit($field)){
- echo "It's not a digit";
- }
- ?>
- c:\users\lalikali\desktop\web\txt\debug.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <body>
- <h1>My First Web Page</h1>
- <p>My first paragraph.</p>
- <p>
- Activate debugging in your browser (Chrome, IE, Firefox) with F12, and select "Console" in the debugger menu.
- </p>
- <script>
- console.log(5 + 6);
- </script>
- </body>
- </html>
- c:\users\lalikali\desktop\web\txt\dekrement.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <body>
- <h1>The -- Operator</h1>
- <p id="demo"></p>
- <script>
- var x = 5;
- x--;
- var z = x;
- document.getElementById("demo").innerHTML = z;
- </script>
- </body>
- </html>
- c:\users\lalikali\desktop\web\txt\do_while.txt
- <---------------------------------------------------------------------->
- <html>
- <body>
- <?php
- $i = 0;
- $num = 0;
- do{
- $i++;
- }
- while( $i < 10 );
- echo ("Loop stopped at i = $i" );
- ?>
- </body>
- </html>
- Loop stopped at i = 10
- c:\users\lalikali\desktop\web\txt\do+while.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <body>
- <p>Click the button to loop through a block of code as long as i is less than 10.</p>
- <button onclick="myFunction()">Try it</button>
- <p id="demo"></p>
- <script>
- function myFunction() {
- var text = ""
- var i = 0;
- do {
- text += "<br>The number is " + i;
- i++;
- }
- while (i < 10)
- document.getElementById("demo").innerHTML = text;
- }
- </script>
- </body>
- </html>
- c:\users\lalikali\desktop\web\txt\else_if.txt
- <---------------------------------------------------------------------->
- <html>
- <body>
- <?php
- $d=date("D");
- if ($d=="Fri")
- echo "Have a nice weekend!";
- elseif ($d=="Sun")
- echo "Have a nice Sunday!";
- else
- echo "Have a nice day!";
- ?>
- </body>
- </html>
- c:\users\lalikali\desktop\web\txt\explode.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <body>
- <?php
- $str = "Hello world. It's a beautiful day.";
- print_r (explode(" ",$str));
- ?>
- </body>
- </html>
- Array ( [0] => Hello [1] => world. [2] => Its [3] => a [4] => beautiful [5] => day. )())
- c:\users\lalikali\desktop\web\txt\external.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <body>
- <h1>External JavaScript</h1>
- <p id="demo">A Paragraph.</p>
- <button type="button" onclick="myFunction()">Try it</button>
- <p><strong>Note:</strong> myFunction is stored in an external file called "myScript.js".</p>
- <script src="myScript.js"></script>
- </body>
- </html>
- c:\users\lalikali\desktop\web\txt\file_plote_rekursiv.txt
- <---------------------------------------------------------------------->
- <!doctype html>
- <html lang="en">
- <head>
- <title>Rekursion: leximi i nje grupi skedaresh dhe direktorish</title>
- <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
- </head>
- <body>
- <h1>Rekursion</h1>
- <?php
- $folderPath = "photos";
- function readFolder( $path ) {
- // hapim direktorine
- if ( !( $dir = opendir( $path ) ) ) die( "Can't open $path" );
- $filenames = array();
- // Lexojme permbajtjen e nje direktorie , duke injoruar '.' dhe '..', dhe
- // duke shtuar '/' ne cdo nendirektori. Shtojme te gjithe skedaret dhe nendirektorite ne vektorin $filenames.
- while ( $filename = readdir( $dir ) ) {
- if ( $filename != '.' && $filename != '..' ) {
- if ( is_dir( "$path/$filename" ) ) $filename .= '/';
- $filenames[] = $filename;
- }
- }
- closedir ( $dir );
- // rendisim emrat e skedareve sipas alfabetit
- sort( $filenames );
- // shfaqim emrat
- echo "<ul>";
- foreach ( $filenames as $filename ) {
- echo "<li>$filename";
- if ( substr( $filename, -1 ) == '/' ) readFolder( "$path/" . substr( $filename, 0, -1 ) );
- echo "</li>";
- }
- echo "</ul>";
- }
- echo "<h2>Contents of '$folderPath':</h2>";
- readFolder( $folderPath );
- ?>
- </body>
- </html>
- c:\users\lalikali\desktop\web\txt\fontcss.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <head>
- <style>
- h1 {
- color:blue;
- font-family:verdana;
- font-size:300%;
- }
- p {
- color:red;
- font-family:courier;
- font-size:160%;
- }
- </style>
- </head>
- <body>
- <h1>This is a heading</h1>
- <p>This is a paragraph.</p>
- </body>
- </html>
- c:\users\lalikali\desktop\web\txt\for (2).txt
- <---------------------------------------------------------------------->
- <html>
- <body>
- <?php
- $a = 0;
- $b = 0;
- for( $i=0; $i<5; $i++ )
- {
- $a += 10;
- $b += 5;
- }
- echo ("At the end of the loop a=$a and b=$b" );
- ?>
- </body>
- </html>
- c:\users\lalikali\desktop\web\txt\for.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <body>
- <p id="demo"></p>
- <script>
- var cars = ["BMW", "Volvo", "Saab", "Ford"];
- var text = "";
- var i;
- for (i = 0; i < cars.length; i++) {
- text += cars[i] + "<br>";
- }
- document.getElementById("demo").innerHTML = text;
- </script>
- </body>
- </html>
- c:\users\lalikali\desktop\web\txt\for1.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <body>
- <p id="demo"></p>
- <script>
- var cars = ["BMW", "Volvo", "Saab", "Ford"];
- var text = "";
- var i;
- for (i = 0; i < cars.length; i++) {
- text += cars[i] + "<br>";
- }
- document.getElementById("demo").innerHTML = text;
- </script>
- </body>
- </html>
- c:\users\lalikali\desktop\web\txt\for2 (2).txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <body>
- <p>Click the button to loop through a block of code five times.</p>
- <button onclick="myFunction()">Try it</button>
- <p id="demo"></p>
- <script>
- function myFunction() {
- var text = "";
- var i;
- for (i = 0; i < 5; i++) {
- text += "The number is " + i + "<br>";
- }
- document.getElementById("demo").innerHTML = text;
- }
- </script>
- </body>
- </html>
- c:\users\lalikali\desktop\web\txt\for2.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <body>
- <p id="demo"></p>
- <script>
- var cars = ["BMW", "Volvo", "Saab", "Ford"];
- var i = 0;
- var len = cars.length;
- var text = "";
- for (; i < len; ) {
- text += cars[i] + "<br>";
- i++;
- }
- document.getElementById("demo").innerHTML = text;
- </script>
- </body>
- </html>
- c:\users\lalikali\desktop\web\txt\for3.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <body>
- <p id="demo"></p>
- <script>
- var cars = ["BMW", "Volvo", "Saab", "Ford"];
- var i, len, text;
- for (i = 0, len = cars.length, text = ""; i < len; i++) {
- text += cars[i] + "<br>";
- }
- document.getElementById("demo").innerHTML = text;
- </script>
- </body>
- </html>
- c:\users\lalikali\desktop\web\txt\foreach.txt
- <---------------------------------------------------------------------->
- <html>
- <body>
- <?php
- $array = array( 1, 2, 3, 4, 5);
- foreach( $array as $value )
- {
- echo "Value is $value <br />";
- }
- ?>
- </body>
- </html>
- Value is 1
- Value is 2
- Value is 3
- Value is 4
- Value is 5
- c:\users\lalikali\desktop\web\txt\form_get.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE HTML>
- <html>
- <body>
- <form action="welcome_get.php" method="get">
- Name: <input type="text" name="name"><br>
- E-mail: <input type="text" name="email"><br>
- <input type="submit">
- </form>
- </body>
- </html>
- c:\users\lalikali\desktop\web\txt\form_post.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE HTML>
- <html>
- <body>
- <form action="welcome.php" method="post">
- Name: <input type="text" name="name"><br>
- E-mail: <input type="text" name="email"><br>
- <input type="submit">
- </form>
- </body>
- </html>
- c:\users\lalikali\desktop\web\txt\form_validation.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE HTML>
- <html>
- <head>
- </head>
- <body>
- <?php
- // define variables and set to empty values
- $name = $email = $gender = $comment = $website = "";
- if ($_SERVER["REQUEST_METHOD"] == "POST") {
- $name = test_input($_POST["name"]);
- $email = test_input($_POST["email"]);
- $website = test_input($_POST["website"]);
- $comment = test_input($_POST["comment"]);
- $gender = test_input($_POST["gender"]);
- }
- function test_input($data) {
- $data = trim($data);
- $data = stripslashes($data);
- $data = htmlspecialchars($data);
- return $data;
- }
- ?>
- <h2>PHP Form Validation Example</h2>
- <form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
- Name: <input type="text" name="name">
- <br><br>
- E-mail: <input type="text" name="email">
- <br><br>
- Website: <input type="text" name="website">
- <br><br>
- Comment: <textarea name="comment" rows="5" cols="40"></textarea>
- <br><br>
- Gender:
- <input type="radio" name="gender" value="female">Female
- <input type="radio" name="gender" value="male">Male
- <br><br>
- <input type="submit" name="submit" value="Submit">
- </form>
- <?php
- echo "<h2>Your Input:</h2>";
- echo $name;
- echo "<br>";
- echo $email;
- echo "<br>";
- echo $website;
- echo "<br>";
- echo $comment;
- echo "<br>";
- echo $gender;
- ?>
- </body>
- </html>
- c:\users\lalikali\desktop\web\txt\form_validation2.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE HTML>
- <html>
- <head>
- <style>
- .error {color: #FF0000;}
- </style>
- </head>
- <body>
- <?php
- // define variables and set to empty values
- $nameErr = $emailErr = $genderErr = $websiteErr = "";
- $name = $email = $gender = $comment = $website = "";
- if ($_SERVER["REQUEST_METHOD"] == "POST") {
- if (empty($_POST["name"])) {
- $nameErr = "Name is required";
- } else {
- $name = test_input($_POST["name"]);
- }
- if (empty($_POST["email"])) {
- $emailErr = "Email is required";
- } else {
- $email = test_input($_POST["email"]);
- }
- if (empty($_POST["website"])) {
- $website = "";
- } else {
- $website = test_input($_POST["website"]);
- }
- if (empty($_POST["comment"])) {
- $comment = "";
- } else {
- $comment = test_input($_POST["comment"]);
- }
- if (empty($_POST["gender"])) {
- $genderErr = "Gender is required";
- } else {
- $gender = test_input($_POST["gender"]);
- }
- }
- function test_input($data) {
- $data = trim($data);
- $data = stripslashes($data);
- $data = htmlspecialchars($data);
- return $data;
- }
- ?>
- <h2>PHP Form Validation Example</h2>
- <p><span class="error">* required field.</span></p>
- <form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
- Name: <input type="text" name="name">
- <span class="error">* <?php echo $nameErr;?></span>
- <br><br>
- E-mail: <input type="text" name="email">
- <span class="error">* <?php echo $emailErr;?></span>
- <br><br>
- Website: <input type="text" name="website">
- <span class="error"><?php echo $websiteErr;?></span>
- <br><br>
- Comment: <textarea name="comment" rows="5" cols="40"></textarea>
- <br><br>
- Gender:
- <input type="radio" name="gender" value="female">Female
- <input type="radio" name="gender" value="male">Male
- <span class="error">* <?php echo $genderErr;?></span>
- <br><br>
- <input type="submit" name="submit" value="Submit">
- </form>
- <?php
- echo "<h2>Your Input:</h2>";
- echo $name;
- echo "<br>";
- echo $email;
- echo "<br>";
- echo $website;
- echo "<br>";
- echo $comment;
- echo "<br>";
- echo $gender;
- ?>
- </body>
- </html>
- c:\users\lalikali\desktop\web\txt\fshirja.txt
- <---------------------------------------------------------------------->
- <html>
- <head>
- <title>Delete a Record from MySQL Database</title>
- </head>
- <body>
- <?php
- if(isset($_POST['delete'])) {
- $dbhost = 'localhost:3036';
- $dbuser = 'root';
- $dbpass = 'rootpassword';
- $conn = mysql_connect($dbhost, $dbuser, $dbpass);
- if(! $conn ) {
- die('Could not connect: ' . mysql_error());
- }
- $emp_id = $_POST['emp_id'];
- $sql = "DELETE employee ". "WHERE emp_id = $emp_id" ;
- mysql_select_db('test_db');
- $retval = mysql_query( $sql, $conn );
- if(! $retval ) {
- die('Could not delete data: ' . mysql_error());
- }
- echo "Deleted data successfully\n";
- mysql_close($conn);
- }else {
- ?>
- <form method = "post" action = "<?php $_PHP_SELF ?>">
- <table width = "400" border = "0" cellspacing = "1"
- cellpadding = "2">
- <tr>
- <td width = "100">Employee ID</td>
- <td><input name = "emp_id" type = "text"
- id = "emp_id"></td>
- </tr>
- <tr>
- <td width = "100"> </td>
- <td> </td>
- </tr>
- <tr>
- <td width = "100"> </td>
- <td>
- <input name = "delete" type = "submit"
- id = "delete" value = "Delete">
- </td>
- </tr>
- </table>
- </form>
- <?php
- }
- ?>
- </body>
- </html>
- c:\users\lalikali\desktop\web\txt\funksion1 (2).txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <body>
- <?php
- function writeMsg() {
- echo "Hello world!";
- }
- writeMsg();
- ?>
- </body>
- </html>
- c:\users\lalikali\desktop\web\txt\funksion1.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <body>
- <p>This example calls a function which performs a calculation, and returns the result:</p>
- <p id="demo"></p>
- <script>
- function myFunction(a, b) {
- return a * b;
- }
- document.getElementById("demo").innerHTML = myFunction(4, 3);
- </script>
- </body>
- </html>
- c:\users\lalikali\desktop\web\txt\funksion2 (2).txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <body>
- <?php
- function familyName($fname) {
- echo "$fname Refsnes.<br>";
- }
- familyName("Jani");
- familyName("Hege");
- familyName("Stale");
- familyName("Kai Jim");
- familyName("Borge");
- ?>
- </body>
- </html>
- Jani Refsnes.
- Hege Refsnes.
- Stale Refsnes.
- Kai Jim Refsnes.
- Borge Refsnes.
- c:\users\lalikali\desktop\web\txt\funksion2.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <body>
- <p id="demo"></p>
- <script>
- document.getElementById("demo").innerHTML =
- "The temperature is " + toCelsius(77) + " Celsius";
- function toCelsius(fahrenheit) {
- return (5/9) * (fahrenheit-32);
- }
- </script>
- </body>
- </html>
- c:\users\lalikali\desktop\web\txt\funksion3.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <body>
- <?php
- function familyName($fname, $year) {
- echo "$fname Refsnes. Born in $year <br>";
- }
- familyName("Hege","1975");
- familyName("Stale","1978");
- familyName("Kai Jim","1983");
- ?>
- </body>
- </html>
- Hege Refsnes. Born in 1975
- Stale Refsnes. Born in 1978
- Kai Jim Refsnes. Born in 1983
- c:\users\lalikali\desktop\web\txt\funksion4.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <body>
- <?php
- function setHeight($minheight = 50) {
- echo "The height is : $minheight <br>";
- }
- setHeight(350);
- setHeight();
- setHeight(135);
- setHeight(80);
- ?>
- </body>
- </html>
- The height is : 350
- The height is : 50
- The height is : 135
- The height is : 80
- c:\users\lalikali\desktop\web\txt\funksion5.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <body>
- <?php
- function sum($x, $y) {
- $z = $x + $y;
- return $z;
- }
- echo "5 + 10 = " . sum(5,10) . "<br>";
- echo "7 + 13 = " . sum(7,13) . "<br>";
- echo "2 + 4 = " . sum(2,4);
- ?>
- </body>
- </html>
- 5 + 10 = 15
- 7 + 13 = 20
- 2 + 4 = 6
- c:\users\lalikali\desktop\web\txt\globale.txt
- <---------------------------------------------------------------------->
- <?php
- $somevar = 15;
- function addit() {
- GLOBAL $somevar;
- $somevar++;
- print "Somevar is $somevar";
- }
- addit();
- ?>
- Do afishoje:
- Somevar is 16
- c:\users\lalikali\desktop\web\txt\head.txt.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <head>
- <script>
- function myFunction() {
- document.getElementById("demo").innerHTML = "Paragraph changed.";
- }
- </script>
- </head>
- <body>
- <h1>JavaScript in Head</h1>
- <p id="demo">A Paragraph.</p>
- <button type="button" onclick="myFunction()">Try it</button>
- </body>
- </html
- c:\users\lalikali\desktop\web\txt\html-php_mysql.txt
- <---------------------------------------------------------------------->
- <html>
- <head>
- <title>Shtojme nje rekord te ri ne databaze</title>
- </head>
- <body>
- <?php
- if(isset($_POST['add'])) {
- $dbhost = 'localhost:3036';
- $dbuser = 'root';
- $dbpass = 'rootpassword';
- $conn = mysql_connect($dbhost, $dbuser, $dbpass);
- if(! $conn ) {
- die('Could not connect: ' . mysql_error());
- }
- if(! get_magic_quotes_gpc() ) {
- $emp_name = addslashes ($_POST['emp_name']);
- $emp_address = addslashes ($_POST['emp_address']);
- }else {
- $emp_name = $_POST['emp_name'];
- $emp_address = $_POST['emp_address'];
- }
- $emp_salary = $_POST['emp_salary'];
- $sql = "INSERT INTO employee ". "(emp_name,emp_address, emp_salary,
- join_date) ". "VALUES('$emp_name','$emp_address',$emp_salary, NOW())";
- mysql_select_db('test_db');
- $retval = mysql_query( $sql, $conn );
- if(! $retval ) {
- die('Could not enter data: ' . mysql_error());
- }
- echo "Entered data successfully\n";
- mysql_close($conn);
- }else {
- ?>
- <form method = "post" action = "<?php $_PHP_SELF ?>">
- <table width = "400" border = "0" cellspacing = "1"
- cellpadding = "2">
- <tr>
- <td width = "100">Employee Name</td>
- <td><input name = "emp_name" type = "text"
- id = "emp_name"></td>
- </tr>
- <tr>
- <td width = "100">Employee Address</td>
- <td><input name = "emp_address" type = "text"
- id = "emp_address"></td>
- </tr>
- <tr>
- <td width = "100">Employee Salary</td>
- <td><input name = "emp_salary" type = "text"
- id = "emp_salary"></td>
- </tr>
- <tr>
- <td width = "100"> </td>
- <td> </td>
- </tr>
- <tr>
- <td width = "100"> </td>
- <td>
- <input name = "add" type = "submit" id = "add"
- value = "Add Employee">
- </td>
- </tr>
- </table>
- </form>
- <?php
- }
- ?>
- </body>
- </html>
- c:\users\lalikali\desktop\web\txt\HTTP_USER_AGENT.txt
- <---------------------------------------------------------------------->
- <html>
- <body>
- <?php
- function getBrowser()
- {
- $u_agent = $_SERVER['HTTP_USER_AGENT'];
- $bname = 'Unknown';
- $platform = 'Unknown';
- $version= "";
- //gjejme fillimisht sistemin
- if (preg_match('/linux/i', $u_agent)) {
- $platform = 'linux';
- }
- elseif (preg_match('/macintosh|mac os x/i', $u_agent)) {
- $platform = 'mac';
- }
- elseif (preg_match('/windows|win32/i', $u_agent)) {
- $platform = 'windows';
- }
- // gjejme browserin
- if(preg_match('/MSIE/i',$u_agent) && !preg_match('/Opera/i',$u_agent))
- {
- $bname = 'Internet Explorer';
- $ub = "MSIE";
- }
- elseif(preg_match('/Firefox/i',$u_agent))
- {
- $bname = 'Mozilla Firefox';
- $ub = "Firefox";
- }
- elseif(preg_match('/Chrome/i',$u_agent))
- {
- $bname = 'Google Chrome';
- $ub = "Chrome";
- }
- elseif(preg_match('/Safari/i',$u_agent))
- {
- $bname = 'Apple Safari';
- $ub = "Safari";
- }
- elseif(preg_match('/Opera/i',$u_agent))
- {
- $bname = 'Opera';
- $ub = "Opera";
- }
- elseif(preg_match('/Netscape/i',$u_agent))
- {
- $bname = 'Netscape';
- $ub = "Netscape";
- }
- // gjejme cili version eshte
- $known = array('Version', $ub, 'other');
- $pattern = '#(?<browser>' . join('|', $known) . ')[/ ]+(?<version>[0-9.|a-zA-Z.]*)#';
- if (!preg_match_all($pattern, $u_agent, $matches)) {
- // nqs nuk e kemi gjetur numrin
- }
- shikojme sa kemi
- $i = count($matches['browser']);
- if ($i != 1) {
- //kemi 2
- //shikojme nqs versioni eshte para apo mbrapa emrit
- if (strripos($u_agent,"Version") < strripos($u_agent,$ub)){
- $version= $matches['version'][0];
- }
- else {
- $version= $matches['version'][1];
- }
- }
- else {
- $version= $matches['version'][0];
- }
- // kontrollojme nqs kemi nje numer
- if ($version==null || $version=="") {$version="?";}
- return array(
- 'userAgent' => $u_agent,
- 'name' => $bname,
- 'version' => $version,
- 'platform' => $platform,
- 'pattern' => $pattern
- );
- }
- // e kontrollojme
- $ua=getBrowser();
- $yourbrowser= "Your browser: " . $ua['name'] . " " . $ua['version'] . " on " .$ua['platform'] . " reports: <br >" . $ua['userAgent'];
- print_r($yourbrowser);
- ?>
- </body>
- </html>
- c:\users\lalikali\desktop\web\txt\id.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <head>
- <style>
- table, th, td {
- border: 1px solid black;
- border-collapse: collapse;
- }
- th, td {
- padding: 5px;
- text-align: left;
- }
- table#t01 {
- width: 100%;
- background-color: #f1f1c1;
- }
- </style>
- </head>
- <body>
- <table style="width:100%">
- <tr>
- <th>First Name</th>
- <th>Last Name</th>
- <th>Points</th>
- </tr>
- <tr>
- <td>Jill</td>
- <td>Smith</td>
- <td>50</td>
- </tr>
- <tr>
- <td>Eve</td>
- <td>Jackson</td>
- <td>94</td>
- </tr>
- <tr>
- <td>John</td>
- <td>Doe</td>
- <td>80</td>
- </tr>
- </table>
- <br>
- <table id="t01">
- <tr>
- <th>First Name</th>
- <th>Last Name</th>
- <th>Points</th>
- </tr>
- <tr>
- <td>Jill</td>
- <td>Smith</td>
- <td>50</td>
- </tr>
- <tr>
- <td>Eve</td>
- <td>Jackson</td>
- <td>94</td>
- </tr>
- <tr>
- <td>John</td>
- <td>Doe</td>
- <td>80</td>
- </tr>
- </table>
- </body>
- </html>
- c:\users\lalikali\desktop\web\txt\if (2).txt
- <---------------------------------------------------------------------->
- <html>
- <body>
- <?php
- $d=date("D");
- if ($d=="Fri")
- echo "Have a nice weekend!";
- else
- echo "Have a nice day!";
- ?>
- </body>
- </html>
- Rezultati:
- Have a nice day!
- c:\users\lalikali\desktop\web\txt\if.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <body>
- <p>Click the button to display a time-based greeting:</p>
- <button onclick="myFunction()">Try it</button>
- <p id="demo"></p>
- <script>
- function myFunction() {
- var hour = new Date().getHours();
- var greeting;
- if (hour < 18) {
- greeting = "Good day";
- } else {
- greeting = "Good evening";
- }
- document.getElementById("demo").innerHTML = greeting;
- }
- </script>
- </body>
- </html>
- c:\users\lalikali\desktop\web\txt\if2.txt
- <---------------------------------------------------------------------->
- !DOCTYPE html>
- <html>
- <body>
- <p>Click the button to get a time-based greeting:</p>
- <button onclick="myFunction()">Try it</button>
- <p id="demo"></p>
- <script>
- function myFunction() {
- var greeting;
- var time = new Date().getHours();
- if (time < 10) {
- greeting = "Good morning";
- } else if (time < 20) {
- greeting = "Good day";
- } else {
- greeting = "Good evening";
- }
- document.getElementById("demo").innerHTML = greeting;
- }
- </script>
- </body>
- </html>
- c:\users\lalikali\desktop\web\txt\implode.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <body>
- <?php
- $arr = array('Hello','World!','Beautiful','Day!');
- echo implode(" ",$arr);
- ?>
- </body>
- </html>
- Hello World! Beautiful Day!
- c:\users\lalikali\desktop\web\txt\infinity.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <body>
- <p>Infinity is returned if you calculate a number outside the largest possible number.</p>
- <button onclick="myFunction()">Try it</button>
- <p id="demo"></p>
- <script>
- function myFunction() {
- var myNumber = 2;
- var txt = "";
- while (myNumber != Infinity) {
- myNumber = myNumber * myNumber;
- txt = txt + myNumber + "<br>";
- }
- document.getElementById("demo").innerHTML = txt;
- }
- </script>
- </body>
- </html>
- c:\users\lalikali\desktop\web\txt\inkrement.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <body>
- <h1>The ++ Operator</h1>
- <p id="demo"></p>
- <script>
- var x = 5;
- x++;
- var z = x;
- document.getElementById("demo").innerHTML = z;
- </script>
- </body>
- </html>
- c:\users\lalikali\desktop\web\txt\inner.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <body>
- <h1>My First Web Page</h1>
- <p>My first paragraph.</p>
- <button type="button" onclick="document.write(5 + 6)">Try it</button>
- </body>
- </html>
- c:\users\lalikali\desktop\web\txt\javascript.body.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <body>
- <h1>JavaScript in Body</h1>
- <p id="demo">A Paragraph.</p>
- <button type="button" onclick="myFunction()">Try it</button>
- <script>
- function myFunction() {
- document.getElementById("demo").innerHTML = "Paragraph changed.";
- }
- </script>
- </body>
- </html>
- c:\users\lalikali\desktop\web\txt\javascript.external.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <body>
- <h1>External JavaScript</h1>
- <p id="demo">A Paragraph.</p>
- <button type="button" onclick="myFunction()">Try it</button>
- <p><strong>Note:</strong> myFunction is stored in an external file called "myScript.js".</p>
- <script src="myScript.js"></script>
- </body>
- </html>
- c:\users\lalikali\desktop\web\txt\javascript.head.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <head>
- <script>
- function myFunction() {
- document.getElementById("demo").innerHTML = "Paragraph changed.";
- }
- </script>
- </head>
- <body>
- <h1>JavaScript in Head</h1>
- <p id="demo">A Paragraph.</p>
- <button type="button" onclick="myFunction()">Try it</button>
- </body>
- </html>
- c:\users\lalikali\desktop\web\txt\javascript1.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <body>
- <h1>My First JavaScript</h1>
- <button type="button"
- onclick="document.getElementById('demo').innerHTML = Date()">
- Click me to display Date and Time.</button>
- <p id="demo"></p>
- </body>
- </html>
- c:\users\lalikali\desktop\web\txt\koment.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <body>
- <h1>Comments are NOT Executed</h1>
- <p id="demo"></p>
- <script>
- var x = 5;
- // var x = 6; I will not be executed
- document.getElementById("demo").innerHTML = x;
- </script>
- </body>
- </html>
- c:\users\lalikali\desktop\web\txt\konstante.txt
- <---------------------------------------------------------------------->
- // emrat te skate konstantesh
- define("ONE", "first thing");
- define("TWO2", "second thing");
- define("THREE_3", "third thing")
- // emra gabim
- define("2TWO", "second thing");
- define("__THREE__", "third value");
- c:\users\lalikali\desktop\web\txt\konturcss.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <head>
- <style>
- p {
- border:1px solid grey;
- }
- </style>
- </head>
- <body>
- <h1>This is a heading</h1>
- <p>This is a paragraph.</p>
- <p>This is a paragraph.</p>
- <p>This is a paragraph.</p>
- </body>
- </html>
- c:\users\lalikali\desktop\web\txt\krsort.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <body>
- <?php
- $age = array("Peter"=>"35", "Ben"=>"37", "Joe"=>"43");
- krsort($age);
- foreach($age as $x => $x_value) {
- echo "Key=" . $x . ", Value=" . $x_value;
- echo "<br>";
- }
- ?>
- </body>
- </html>
- Key=Peter, Value=35
- Key=Joe, Value=43
- Key=Ben, Value=37
- c:\users\lalikali\desktop\web\txt\ksort.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <body>
- <?php
- $age = array("Peter"=>"35", "Ben"=>"37", "Joe"=>"43");
- ksort($age);
- foreach($age as $x => $x_value) {
- echo "Key=" . $x . ", Value=" . $x_value;
- echo "<br>";
- }
- ?>
- </body>
- </html>
- Key=Ben, Value=37
- Key=Joe, Value=43
- Key=Peter, Value=35
- c:\users\lalikali\desktop\web\txt\kthimi_ndryshoreve_ne_numra.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <body>
- <p>The global JavaScript function Number() converts variables to numbers:</p>
- <p id="demo"></p>
- <script>
- document.getElementById("demo").innerHTML =
- Number(true) + "<br>" +
- Number(false) + "<br>" +
- Number(new Date()) + "<br>" +
- Number(" 10") + "<br>" +
- Number("10 ") + "<br>" +
- Number("10 6");
- </script>
- </body>
- </html>
- c:\users\lalikali\desktop\web\txt\kthimi_numrave.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <body>
- <p>The toString() method can output numbers as base 16 (hex), base 8 (octal), or base 2 (binary).</p>
- <p id="demo"></p>
- <button onclick="myFunction()">Try it</button>
- <script>
- function myFunction() {
- var myNumber = 128;
- document.getElementById("demo").innerHTML = "128 = " +
- myNumber + " Decimal, " +
- myNumber.toString(16) + " Hexadecimal, " +
- myNumber.toString(8) + " Octal, " +
- myNumber.toString(2) + " Binary."
- }
- </script>
- </body>
- </html>
- c:\users\lalikali\desktop\web\txt\kthimi_stringjeve_ne_numra.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <body>
- <p>The global JavaScript function parseInt() converts strings to numbers:</p>
- <p id="demo"></p>
- <script>
- document.getElementById("demo").innerHTML =
- parseInt("10") + "<br>" +
- parseInt("10.33") + "<br>" +
- parseInt("10 6") + "<br>" +
- parseInt("10 years") + "<br>" +
- parseInt("years 10");
- </script>
- </body>
- </html>
- c:\users\lalikali\desktop\web\txt\lastname.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <body>
- <h1>JavaScript is Case Sensitive</h1>
- <p>Try change lastName to lastname.</p>
- <p id="demo"></p>
- <script>
- var lastName = "Doe";
- var lastname = "Peterson";
- document.getElementById("demo").innerHTML = lastName;
- </script>
- </body>
- </html>
- c:\users\lalikali\desktop\web\txt\linkcss.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <head>
- <style>
- a:link {
- color: green;
- background-color: transparent;
- text-decoration: none;
- }
- a:visited {
- color: pink;
- background-color: transparent;
- text-decoration: none;
- }
- a:hover {
- color: red;
- background-color: transparent;
- text-decoration: underline;
- }
- a:active {
- color: yellow;
- background-color: transparent;
- text-decoration: underline;
- }
- </style>
- </head>
- <body>
- <p>You can change the default colors of links</p>
- <a href="html_images.asp" target="_blank">HTML Images</a>
- </body>
- </html>
- c:\users\lalikali\desktop\web\txt\literals.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <body>
- <h1>JavaScript Numbers</h1>
- <p>Number can be written with or without decimals.</p>
- <p id="demo"></p>
- <script>
- document.getElementById("demo").innerHTML = 10.50;
- </script>
- </body>
- </html>
- c:\users\lalikali\desktop\web\txt\literals2.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <body>
- <h1>JavaScript Strings</h1>
- <p>Strings can be written with double or single quotes.</p>
- <p id="demo"></p>
- <script>
- document.getElementById("demo").innerHTML = 'John Doe';
- </script>
- </body>
- </html>
- c:\users\lalikali\desktop\web\txt\local.txt
- <---------------------------------------------------------------------->
- <?php
- $x = 4;
- function assignx () {
- $x = 0;
- print "\$x brenda funksionit eshte $x. <br />";
- }
- assignx();
- print "\$x jashte funksionit eshte $x. <br />";
- ?>
- Do afishoje:
- $x brenda funksionit eshte 0.
- $x jashte funksionit eshte 4.
- c:\users\lalikali\desktop\web\txt\lower.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <body>
- <p>Convert string to lower case:</p>
- <button onclick="myFunction()">Try it</button>
- <p id="demo">Hello World!</p>
- <script>
- function myFunction() {
- var text = document.getElementById("demo").innerHTML;
- document.getElementById("demo").innerHTML = text.toLowerCase();
- }
- </script>
- </body>
- </html>
- c:\users\lalikali\desktop\web\txt\math_ceil.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <body>
- <p>Math.ceil() rounds a number <strong>up</strong> to its nearest integer.</p>
- <button onclick="myFunction()">Try it</button>
- <p id="demo"></p>
- <script>
- function myFunction() {
- document.getElementById("demo").innerHTML = Math.ceil(4.4);
- }
- </script>
- </body>
- </html>
- c:\users\lalikali\desktop\web\txt\math_constants.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <body>
- <p>Math constants are E, PI, SQR2, SQR1_2, LN2, LN10, LOG2E, LOG10E</p>
- <button onclick="myFunction()">Try it</button>
- <p id="demo"></p>
- <script>
- function myFunction() {
- document.getElementById("demo").innerHTML =
- Math.E + "<br>" +
- Math.PI + "<br>" +
- Math.SQRT2 + "<br>" +
- Math.SQRT1_2 + "<br>" +
- Math.LN2 + "<br>" +
- Math.LN10 + "<br>" +
- Math.LOG2E + "<br>" +
- Math.LOG10E + "<br>";
- }
- </script>
- </body>
- </html>
- c:\users\lalikali\desktop\web\txt\math_floor.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <body>
- <p>Math.floor() rounds a number <strong>down</strong> to its nearest integer.</p>
- <button onclick="myFunction()">Try it</button>
- <p id="demo"></p>
- <script>
- function myFunction() {
- document.getElementById("demo").innerHTML = Math.floor(4.7);
- }
- </script>
- </body>
- </html>
- c:\users\lalikali\desktop\web\txt\math_max.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <body>
- <p>Math.max() returns the highest value.</p>
- <button onclick="myFunction()">Try it</button>
- <p id="demo"></p>
- <script>
- function myFunction() {
- document.getElementById("demo").innerHTML =
- Math.max(0, 150, 30, 20, -8, -200);
- }
- </script>
- </body>
- </html>
- c:\users\lalikali\desktop\web\txt\math_min.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <body>
- <p>Math.min() returns the lowest value.</p>
- <button onclick="myFunction()">Try it</button>
- <p id="demo"></p>
- <script>
- function myFunction() {
- document.getElementById("demo").innerHTML =
- Math.min(0, 150, 30, 20, -8, -200);
- }
- </script>
- </body>
- </html>
- c:\users\lalikali\desktop\web\txt\math_random.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <body>
- <p>Math.random() returns a random number between 0 and 1.</p>
- <button onclick="myFunction()">Try it</button>
- <p id="demo"></p>
- <script>
- function myFunction() {
- document.getElementById("demo").innerHTML = Math.random();
- }
- </script>
- </body>
- </html>
- c:\users\lalikali\desktop\web\txt\math_round.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <body>
- <p>Math.round() rounds a number to its nearest integer.</p>
- <button onclick="myFunction()">Try it</button>
- <p id="demo"></p>
- <script>
- function myFunction() {
- document.getElementById("demo").innerHTML = Math.round(4.4);
- }
- </script>
- </body>
- </html>
- c:\users\lalikali\desktop\web\txt\max_value.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <body>
- <p id="demo"></p>
- <script>
- document.getElementById("demo").innerHTML = Number.MAX_VALUE;
- </script>
- </body>
- </html>
- c:\users\lalikali\desktop\web\txt\ndarjaStringut.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <body>
- <p>Click "Try it" to display the first array element, after a string split.</p>
- <button onclick="myFunction()">Try it</button>
- <p id="demo"></p>
- <script>
- function myFunction() {
- var str = "a,b,c,d,e,f";
- var arr = str.split(",");
- document.getElementById("demo").innerHTML = arr[0];
- }
- </script>
- </body>
- </html>
- c:\users\lalikali\desktop\web\txt\ndarjaStringut2.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <body>
- <p id="demo"></p>
- <script>
- var str = "Hello";
- var arr = str.split("");
- var text = "";
- var i;
- for (i = 0; i < arr.length; i++) {
- text += arr[i] + "<br>"
- }
- document.getElementById("demo").innerHTML = text;
- </script>
- </body>
- </html>
- c:\users\lalikali\desktop\web\txt\ndryshimi.imazhit.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <body>
- <h1>JavaScript Can Change Images</h1>
- <img id="myImage" onclick="changeImage()" src="pic_bulboff.gif" width="100" height="180">
- <p>Click the light bulb to turn on/off the light.</p>
- <script>
- function changeImage() {
- var image = document.getElementById('myImage');
- if (image.src.match("bulbon")) {
- image.src = "pic_bulboff.gif";
- } else {
- image.src = "pic_bulbon.gif";
- }
- }
- </script>
- </body>
- </html>
- c:\users\lalikali\desktop\web\txt\ndryshimi.permbajtjesHTML.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <body>
- <h1>What Can JavaScript Do?</h1>
- <p id="demo">JavaScript can change HTML content.</p>
- <button type="button"
- onclick="document.getElementById('demo').innerHTML = 'Hello JavaScript!'">
- Click Me!</button>
- </body>
- </html>
- c:\users\lalikali\desktop\web\txt\ndryshimi.stilit.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <body>
- <h1>What Can JavaScript Do?</h1>
- <p id="demo">JavaScript can change the style of an HTML element.</p>
- <script>
- function myFunction() {
- var x = document.getElementById("demo");
- x.style.fontSize = "25px";
- x.style.color = "red";
- }
- </script>
- <button type="button" onclick="myFunction()">Click Me!</button>
- </body>
- </html>
- c:\users\lalikali\desktop\web\txt\numeric.txt
- <---------------------------------------------------------------------->
- <body>
- <?php
- $temp = "";
- $msg = "";
- $rst = "";
- if (isset($_POST["submit"])) {
- $number = $_POST["custid"];
- if(empty($number)) {
- $msg = '<span class="error"> Please enter a value</span>';
- } else if(!is_numeric($number)) {
- $msg = '<span class="error"> Data entered was not numeric</span>';
- } else if(strlen($number) != 6) {
- $msg = '<span class="error"> The number entered was not 6 digits long</span>';
- } else {
- echo "valid";
- }
- }
- ?>
- <h1>Customer Information Collection <br /></h1>
- <form method="POST" action="<?php echo $_SERVER["PHP_SELF"];?>" id="custinfo" >
- <table>
- <tr>
- <td><label for="custid">Customer ID (integer value): </label></td>
- <td><input type="text" id="custid" name="custid" value="<?php echo $temp ?>" size=11 /><?php echo $msg; ?></td>
- </tr>
- <tr>
- <td><label for="customerfname">Customer Frist Name: </label></td>
- <td><input type="text" id="customerfname" name="fname" size=50/></td>
- </tr>
- <tr>
- <td><label for="customerlname">Customer Last Name: </label></td>
- <td><input type="text" id="customerlname" name="lname" size=50/></td>
- </tr>
- <tr>
- <td><label for="customeraddress">Customer Address: </label></td>
- <td><input type="text" id="customeraddress" name="custaddress" size=65/></td>
- <td><label for="suburb"> Suburb: </label></td>
- <td><input type="text" id="suburb" name="suburb"/></td>
- </tr>
- <tr>
- <td>
- State:<select name="state" id="state">
- <option value="select">--</option>
- <option value="ACT">ACT</option>
- <option value="NSW">NSW</option>
- <option value="NT">NT</option>
- <option value="QLD">QLD</option>
- <option value="SA">SA</option>
- <option value="TAS">TAS</option>
- <option value="VIC">VIC</option>
- <option value="WA">WA</option>
- </select>
- </td>
- <td><label for="postcode"> Post Code: </label><input type="text" id="postcode" name="postcode" size=4/></td>
- </tr>
- </table>
- <p><input type="submit" name="submit" value="Save Data"/> <input type="reset" value="Clear Form" />
- </tr>
- </form>
- </body>
- modifikim
- if(empty($number)) {
- $msg = '<span class="error"> Please enter a value</span>';
- } else if(!is_numeric($number)) {
- $msg = '<span class="error"> Data entered was not numeric</span>';
- } else if(strlen($number) != 6) {
- $msg = '<span class="error"> The number entered was not 6 digits long</span>';
- } else {
- }
- c:\users\lalikali\desktop\web\txt\numri+madh.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <body>
- <p>Finding the largest number.</p>
- <p id="demo"></p>
- <script>
- function findMax() {
- var i;
- var max = -Infinity;
- for(i = 0; i < arguments.length; i++) {
- if (arguments[i] > max) {
- max = arguments[i];
- }
- }
- return max;
- }
- document.getElementById("demo").innerHTML = findMax(4, 5, 6);
- </script>
- </body>
- </html>
- c:\users\lalikali\desktop\web\txt\objekt.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <body>
- <p id="demo"></p>
- <script>
- var person = {
- firstName : "John",
- lastName : "Doe",
- age : 50,
- eyeColor : "blue"
- };
- document.getElementById("demo").innerHTML =
- person.firstName + " is " + person.age + " years old.";
- </script>
- </body>
- </html>
- c:\users\lalikali\desktop\web\txt\onkeydown.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <body>
- <p>Click the button to display the date.</p>
- <button onkeydown="displayDate()">The time is?</button>
- <script>
- function displayDate() {
- document.getElementById("demo").innerHTML = Date();
- }
- </script>
- <p id="demo"></p>
- </body>
- </html>
- c:\users\lalikali\desktop\web\txt\onmouseout.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <body>
- <p>Click the button to display the date.</p>
- <button onmouseout="displayDate()">The time is?</button>
- <script>
- function displayDate() {
- document.getElementById("demo").innerHTML = Date();
- }
- </script>
- <p id="demo"></p>
- </body>
- </html>
- c:\users\lalikali\desktop\web\txt\operator_aritmetike.txt
- <---------------------------------------------------------------------->
- <html>
- <head>
- <title>Arithmetical Operators</title>
- </head>
- <body>
- <?php
- $a = 42;
- $b = 20;
- $c = $a + $b;
- echo "Addtion Operation Result: $c <br/>";
- $c = $a - $b;
- echo "Substraction Operation Result: $c <br/>";
- $c = $a * $b;
- echo "Multiplication Operation Result: $c <br/>";
- $c = $a / $b;
- echo "Division Operation Result: $c <br/>";
- $c = $a % $b;
- echo "Modulus Operation Result: $c <br/>";
- $c = $a++;
- echo "Increment Operation Result: $c <br/>";
- $c = $a--;
- echo "Decrement Operation Result: $c <br/>";
- ?>
- </body>
- </html>
- Rezultati:
- Addtion Operation Result: 62
- Substraction Operation Result: 22
- Multiplication Operation Result: 840
- Division Operation Result: 2.1
- Modulus Operation Result: 2
- Increment Operation Result: 42
- Decrement Operation Result: 43
- c:\users\lalikali\desktop\web\txt\operator_dhenie vlere.txt
- <---------------------------------------------------------------------->
- <html>
- <head>
- <title>Assignment Operators</title>
- </head>
- <body>
- <?php
- $a = 42;
- $b = 20;
- $c = $a + $b; /* operator dhenie vlere */
- echo "Addtion Operation Result: $c <br/>";
- $c += $a; /* vlera e c eshte 42 + 20 = 62 */
- echo "Add AND Assigment Operation Result: $c <br/>";
- $c -= $a; /* vlera e c eshte 42 + 20 + 42 = 104 */
- echo "Subtract AND Assignment Operation Result: $c <br/>";
- $c *= $a; /* vlera e c eshte 104 - 42 = 62 */
- echo "Multiply AND Assignment Operation Result: $c <br/>";
- $c /= $a; /* vlera e c eshte 62 * 42 = 2604 */
- echo "Division AND Assignment Operation Result: $c <br/>";
- $c %= $a; /* vlera e c eshte 2604/42 = 62*/
- echo "Modulus AND Assignment Operation Result: $c <br/>";
- ?>
- </body>
- </html>
- Rezultati:
- Addtion Operation Result: 62
- Add AND Assigment Operation Result: 104
- Subtract AND Assignment Operation Result: 62
- Multiply AND Assignment Operation Result: 2604
- Division AND Assignment Operation Result: 62
- Modulus AND Assignment Operation Result: 20
- c:\users\lalikali\desktop\web\txt\operator_krahasues.txt
- <---------------------------------------------------------------------->
- <html>
- <head>
- <title>Comparison Operators</title>
- </head>
- <body>
- <?php
- $a = 42;
- $b = 20;
- if( $a == $b ){
- echo "TEST1 : a is equal to b<br/>";
- }
- else{
- echo "TEST1 : a is not equal to b<br/>";
- }
- if( $a > $b ){
- echo "TEST2 : a is greater than b<br/>";
- }
- else{
- echo "TEST2 : a is not greater than b<br/>";
- }
- if( $a < $b ){
- echo "TEST3 : a is less than b<br/>";
- }
- else{
- echo "TEST3 : a is not less than b<br/>";
- }
- if( $a != $b ){
- echo "TEST4 : a is not equal to b<br/>";
- }
- else{
- echo "TEST4 : a is equal to b<br/>";
- }
- if( $a >= $b ){
- echo "TEST5 : a is either greater than or equal to b<br/>";
- }
- else{
- echo "TEST5 : a is neither greater than nor equal to b<br/>";
- }
- if( $a <= $b ){
- echo "TEST6 : a is either less than or equal to b<br/>";
- }
- else{
- echo "TEST6 : a is neither less than nor equal to b<br/>";
- }
- ?>
- </body>
- </html>
- Rezultati:
- TEST1 : a is not equal to b
- TEST2 : a is greater than b
- TEST3 : a is not less than b
- TEST4 : a is not equal to b
- TEST5 : a is either greater than or equal to b
- TEST6 : a is neither less than nor equal to b
- c:\users\lalikali\desktop\web\txt\operator_kushtor.txt
- <---------------------------------------------------------------------->
- <html>
- <head>
- <title>Arithmetical Operators</title>
- </head>
- <body>
- <?php
- $a = 10;
- $b = 20;
- /* nqs kushti i vertete kaloja vleren a perndryshe b */
- $result = ($a > $b ) ? $a :$b;
- echo "TEST1 : Value of result is $result<br/>";
- /* nqs kushti i vertete kaloja vleren a perndryshe b */
- $result = ($a < $b ) ? $a :$b;
- echo "TEST2 : Value of result is $result<br/>";
- ?>
- </body>
- </html>
- rezultati:
- TEST1 : Value of result is 20
- TEST2 : Value of result is 10
- c:\users\lalikali\desktop\web\txt\operator_llogjike.txt
- <---------------------------------------------------------------------->
- <html>
- <head>
- <title>Logical Operators</title>
- </head>
- <body>
- <?php
- $a = 42;
- $b = 0;
- if( $a && $b ){
- echo "TEST1 : Both a and b are true<br/>";
- }
- else{
- echo "TEST1 : Either a or b is false<br/>";
- }
- if( $a and $b ){
- echo "TEST2 : Both a and b are true<br/>";
- }
- else{
- echo "TEST2 : Either a or b is false<br/>";
- }
- if( $a || $b ){
- echo "TEST3 : Either a or b is true<br/>";
- }
- else{
- echo "TEST3 : Both a and b are false<br/>";
- }
- if( $a or $b ){
- echo "TEST4 : Either a or b is true<br/>";
- }
- else{
- echo "TEST4 : Both a and b are false<br/>";
- }
- $a = 10;
- $b = 20;
- if( $a ){
- echo "TEST5 : a is true <br/>";
- }
- else{
- echo "TEST5 : a is false<br/>";
- }
- if( $b ){
- echo "TEST6 : b is true <br/>";
- }
- else{
- echo "TEST6 : b is false<br/>";
- }
- if( !$a ){
- echo "TEST7 : a is true <br/>";
- }
- else{
- echo "TEST7 : a is false<br/>";
- }
- if( !$b ){
- echo "TEST8 : b is true <br/>";
- }
- else{
- echo "TEST8 : b is false<br/>";
- }
- ?>
- </body>
- </html>
- c:\users\lalikali\desktop\web\txt\operator1.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <body>
- <h1>Assigning Values</h1>
- <p>In JavaScript the = operator is used to assign values to variables.</p>
- <p id="demo"></p>
- <script>
- var x = 5;
- var y = 6;
- document.getElementById("demo").innerHTML = x + y;
- </script>
- </body>
- </html>
- c:\users\lalikali\desktop\web\txt\operator2.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <body>
- <h1>JavaScript Operators</h1>
- <p>JavaScript uses arithmetic operators to compute values (just like algebra).</p>
- <p id="demo"></p>
- <script>
- document.getElementById("demo").innerHTML = (5 + 6) * 10;
- </script>
- </body>
- </html>
- c:\users\lalikali\desktop\web\txt\parameter.txt
- <---------------------------------------------------------------------->
- <?php
- // shumezo me 10
- function multiply ($value) {
- $value = $value * 10;
- return $value;
- }
- $retval = multiply (10);
- Print "Return value is $retval\n";
- ?>
- Do afishoje:
- Return value is 100
- c:\users\lalikali\desktop\web\txt\print.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <body>
- <?php
- $str = "Hello world!";
- print $str;
- print "<br>What a nice day!";
- ?>
- </body>
- </html>
- Rez:
- Hello world!
- What a nice day!
- c:\users\lalikali\desktop\web\txt\printf.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <body>
- <?php
- $number = 9;
- $str = "Beijing";
- printf("There are %u million bicycles in %s.",$number,$str);
- ?>
- </body>
- </html>
- There are 9 million bicycles in Beijing.
- c:\users\lalikali\desktop\web\txt\program.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <body>
- <p>JavaScript code (or just JavaScript) is a list of JavaScript statements.</p>
- <p id="demo"></p>
- <script>
- var x = 5;
- var y = 6;
- var z = x + y;
- document.getElementById("demo").innerHTML = z;
- </script>
- </body>
- </html>
- c:\users\lalikali\desktop\web\txt\program2.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <body>
- <h1>My Web Page</h1>
- <p id="myPar">I am a paragraph.</p>
- <div id="myDiv">I am a div.</div>
- <p>
- <button type="button" onclick="myFunction()">Try it</button>
- </p>
- <script>
- function myFunction() {
- document.getElementById("myPar").innerHTML = "Hello Dolly.";
- document.getElementById("myDiv").innerHTML = "How are you?";
- }
- </script>
- <p>When you click on "Try it", the two elements will change.</p>
- </body>
- </html>
- c:\users\lalikali\desktop\web\txt\program3.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <body>
- <h1>JavaScript Variables</h1>
- <p>Add "5" + 2 + 3. and display the result:</p>
- <p id="demo"></p>
- <script>
- var x = "5" + 2 + 3;
- document.getElementById("demo").innerHTML = x;
- </script>
- </body>
- </html>
- c:\users\lalikali\desktop\web\txt\replace.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <body>
- <p>Replace "Microsoft" with "W3Schools" in the paragraph below:</p>
- <button onclick="myFunction()">Try it</button>
- <p id="demo">Please visit Microsoft!</p>
- <script>
- function myFunction() {
- var str = document.getElementById("demo").innerHTML;
- var txt = str.replace("Microsoft","Windows");
- document.getElementById("demo").innerHTML = txt;
- }
- </script>
- </body>
- </html>
- c:\users\lalikali\desktop\web\txt\round.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <body>
- <p>The toFixed() method rounds a number to a given number of digits.</p>
- <p>For working with money, toFixed(2) is perfect.</p>
- <p id="demo"></p>
- <script>
- var x = 9.656;
- document.getElementById("demo").innerHTML =
- x.toFixed(0) + "<br>" +
- x.toFixed(2) + "<br>" +
- x.toFixed(4) + "<br>" +
- x.toFixed(6);
- </script>
- </body>
- </html>
- c:\users\lalikali\desktop\web\txt\rsort_index.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <body>
- <?php
- $cars = array("Volvo", "BMW", "Toyota");
- rsort($cars);
- $clength = count($cars);
- for($x = 0; $x < $clength; $x++) {
- echo $cars[$x];
- echo "<br>";
- }
- ?>
- </body>
- </html>
- Volvo
- Toyota
- BMW
- c:\users\lalikali\desktop\web\txt\rsort_index2.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <body>
- <?php
- $numbers = array(4, 6, 2, 22, 11);
- rsort($numbers);
- $arrlength = count($numbers);
- for($x = 0; $x < $arrlength; $x++) {
- echo $numbers[$x];
- echo "<br>";
- }
- ?>
- </body>
- </html>
- 22
- 11
- 6
- 4
- 2
- c:\users\lalikali\desktop\web\txt\shoqerues.txt
- <---------------------------------------------------------------------->
- <html>
- <body>
- <?php
- /* Menyra e pare */
- $salaries = array("arben" => 2000, "mira" => 1000, "zara" => 500);
- echo "Salary of arben is ". $salaries['arben'] . "<br />";
- echo "Salary of mira is ". $salaries['mira']. "<br />";
- echo "Salary of zara is ". $salaries['zara']. "<br />";
- /* Menyra e dyte */
- $salaries['arben'] = "high";
- $salaries['mira'] = "medium";
- $salaries['zara'] = "low";
- echo "Salary of arben is ". $salaries['arben'] . "<br />";
- echo "Salary of mira is ". $salaries['mira']. "<br />";
- echo "Salary of zara is ". $salaries['zara']. "<br />";
- ?>
- </body>
- </html>
- Rezultati:
- Salary of arben is 2000
- Salary of mira is 1000
- Salary of zara is 500
- Salary of arben is high
- Salary of mira is medium
- Salary of zara is low
- c:\users\lalikali\desktop\web\txt\shprehje1.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <body>
- <h1>JavaScript Expressions</h1>
- <p>Expressions compute to values.</p>
- <p id="demo"></p>
- <script>
- document.getElementById("demo").innerHTML = 5 * 10;
- </script>
- </body>
- </html>
- c:\users\lalikali\desktop\web\txt\shprehje2.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <body>
- <h1>JavaScript Expressions</h1>
- <p>Expressions compute to values.</p>
- <p id="demo"></p>
- <script>
- var x = 5;
- document.getElementById("demo").innerHTML = x * 10;
- </script>
- </body>
- </html>
- c:\users\lalikali\desktop\web\txt\shprehje3.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <body>
- <h1>JavaScript Expressions</h1>
- <p>Expressions compute to values.</p>
- <p id="demo"></p>
- <script>
- document.getElementById("demo").innerHTML = "John" + " " + "Doe";
- </script>
- </body>
- </html>
- c:\users\lalikali\desktop\web\txt\shprehje4.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <body>
- <h1>The var Keyword Creates a Variable</h1>
- <p id="demo"></p>
- <script>
- var x = 5 + 6;
- var y = x * 10;
- document.getElementById("demo").innerHTML = y;
- </script>
- </body>
- </html>
- c:\users\lalikali\desktop\web\txt\shumedimensional.txt
- <---------------------------------------------------------------------->
- <html>
- <body>
- <?php
- $marks = array( "arben" => array
- (
- "physics" => 35,
- "maths" => 30,
- "chemistry" => 39
- ),
- "mira" => array
- (
- "physics" => 30,
- "maths" => 32,
- "chemistry" => 29
- ),
- "zara" => array
- (
- "physics" => 31,
- "maths" => 22,
- "chemistry" => 39
- )
- );
- /* Accessing multi-dimensional array values */
- echo "Marks for arben in physics : " ;
- echo $marks['arben']['physics'] . "<br />";
- echo "Marks for mira in maths : ";
- echo $marks['mira']['maths'] . "<br />";
- echo "Marks for zara in chemistry : " ;
- echo $marks['zara']['chemistry'] . "<br />";
- ?>
- </body>
- </html>
- Rezultati:
- Marks for arben in physics : 35
- Marks for mira in maths : 32
- Marks for zara in chemistry : 39
- c:\users\lalikali\desktop\web\txt\sort_index.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <body>
- <?php
- $cars = array("Volvo", "BMW", "Toyota");
- sort($cars);
- $clength = count($cars);
- for($x = 0; $x < $clength; $x++) {
- echo $cars[$x];
- echo "<br>";
- }
- ?>
- </body>
- </html>
- BMW
- Toyota
- Volvo
- c:\users\lalikali\desktop\web\txt\sort_index2.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <body>
- <?php
- $numbers = array(4, 6, 2, 22, 11);
- sort($numbers);
- $arrlength = count($numbers);
- for($x = 0; $x < $arrlength; $x++) {
- echo $numbers[$x];
- echo "<br>";
- }
- ?>
- </body>
- </html>
- 2
- 4
- 6
- 11
- 22
- c:\users\lalikali\desktop\web\txt\static.txt
- <---------------------------------------------------------------------->
- <?php
- function keep_track() {
- STATIC $count = 0;
- $count++;
- print $count;
- print "<br />";
- }
- keep_track();
- keep_track();
- keep_track();
- ?>
- Do afishoje:
- 1
- 2
- 3
- c:\users\lalikali\desktop\web\txt\stile.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <head>
- <style>
- table {
- width:100%;
- }
- table, th, td {
- border: 1px solid black;
- border-collapse: collapse;
- }
- th, td {
- padding: 5px;
- text-align: left;
- }
- table#t01 tr:nth-child(even) {
- background-color: #eee;
- }
- table#t01 tr:nth-child(odd) {
- background-color:#fff;
- }
- table#t01 th {
- background-color: black;
- color: white;
- }
- </style>
- </head>
- <body>
- <table>
- <tr>
- <th>First Name</th>
- <th>Last Name</th>
- <th>Points</th>
- </tr>
- <tr>
- <td>Jill</td>
- <td>Smith</td>
- <td>50</td>
- </tr>
- <tr>
- <td>Eve</td>
- <td>Jackson</td>
- <td>94</td>
- </tr>
- <tr>
- <td>John</td>
- <td>Doe</td>
- <td>80</td>
- </tr>
- </table>
- <br>
- <table id="t01">
- <tr>
- <th>First Name</th>
- <th>Last Name</th>
- <th>Points</th>
- </tr>
- <tr>
- <td>Jill</td>
- <td>Smith</td>
- <td>50</td>
- </tr>
- <tr>
- <td>Eve</td>
- <td>Jackson</td>
- <td>94</td>
- </tr>
- <tr>
- <td>John</td>
- <td>Doe</td>
- <td>80</td>
- </tr>
- </table>
- </body>
- </html>
- c:\users\lalikali\desktop\web\txt\str_replace.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <body>
- <?php
- echo str_replace("world","Peter","Hello world!");
- ?>
- </body>
- </html>
- Hello Peter!
- c:\users\lalikali\desktop\web\txt\str_word_count.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <body>
- <?php
- print_r(str_word_count("Hello world & good morning!",1));
- print "<br>";
- print_r(str_word_count("Hello world & good morning!",1,"&"));
- ?>
- </body>
- </html>
- Array ( [0] => Hello [1] => world [2] => good [3] => morning )
- Array ( [0] => Hello [1] => world [2] => & [3] => good [4] => morning )
- <!DOCTYPE html>
- <html>
- <body>
- <?php
- echo str_word_count("Hello world!");
- ?>
- </body>
- </html>
- Rez:2
- c:\users\lalikali\desktop\web\txt\strcasecmp.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <body>
- <?php
- echo strcasecmp("Hello world!","HELLO WORLD!")."<br>"; // te barabarte
- echo strcasecmp("Hello world!","HELLO")."<br>"; // String1 me i madh se string2
- echo strcasecmp("Hello world!","HELLO WORLD! HELLO!")."<br>"; // String1 me i vogle se string2
- ?>
- </body>
- </html>
- 0
- 7
- -7
- c:\users\lalikali\desktop\web\txt\strcmp.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <body>
- <?php
- echo strcmp("Hello world!","Hello world!");
- ?>
- <p>If this function returns 0, the two strings are equal.</p>
- </body>
- </html>
- 0
- If this function returns 0, the two strings are equal.
- c:\users\lalikali\desktop\web\txt\string.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <body>
- <p id="demo"></p>
- <script>
- var txt = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
- document.getElementById("demo").innerHTML = txt.length;
- </script>
- </body>
- </html>
- c:\users\lalikali\desktop\web\txt\string_indexof.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <body>
- <p id="p1">Please locate where 'locate' occurs!.</p>
- <button onclick="myFunction()">Try it</button>
- <p id="demo"></p>
- <script>
- function myFunction() {
- var str = document.getElementById("p1").innerHTML;
- var pos = str.indexOf("locate");
- document.getElementById("demo").innerHTML = pos;
- }
- </script>
- </body>
- </html>
- c:\users\lalikali\desktop\web\txt\string_lastindexindexof.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <body>
- <p id="p1">Please locate where 'locate' occurs!.</p>
- <button onclick="myFunction()">Try it</button>
- <p id="demo"></p>
- <script>
- function myFunction() {
- var str = document.getElementById("p1").innerHTML;
- var pos = str.lastIndexOf("locate");
- document.getElementById("demo").innerHTML = pos;
- }
- </script>
- </body>
- </html>
- c:\users\lalikali\desktop\web\txt\string_search.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <body>
- <p id="p1">Please locate where 'locate' occurs!.</p>
- <button onclick="myFunction()">Try it</button>
- <p id="demo"></p>
- <script>
- function myFunction() {
- var str = document.getElementById("p1").innerHTML;
- var pos = str.search("locate");
- document.getElementById("demo").innerHTML = pos;
- }
- </script>
- </body>
- </html>
- c:\users\lalikali\desktop\web\txt\string_slice.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <body>
- <p>The slice() method extract a part of a string
- and returns the extracted parts in a new string:</p>
- <p id="demo"></p>
- <script>
- var str = "Apple, Banana, Kiwi";
- document.getElementById("demo").innerHTML = str.slice(7,13);
- </script>
- </body>
- </html>
- c:\users\lalikali\desktop\web\txt\string_slice2.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <body>
- <p>The slice() method extract a part of a string
- and returns the extracted parts in a new string:</p>
- <p id="demo"></p>
- <script>
- var str = "Apple, Banana, Kiwi";
- document.getElementById("demo").innerHTML = str.slice(7);
- </script>
- </body>
- </html>
- c:\users\lalikali\desktop\web\txt\string_substr.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <body>
- <p>The substr() method extract a part of a string
- and returns the extracted parts in a new string:</p>
- <p id="demo"></p>
- <script>
- var str = "Apple, Banana, Kiwi";
- document.getElementById("demo").innerHTML = str.substr(7,6);
- </script>
- </body>
- </html>
- c:\users\lalikali\desktop\web\txt\string1.txt
- <---------------------------------------------------------------------->
- <?php
- $variable = "name";
- $literally = 'My $variable will not print!\\n';
- print($literally);
- print "<br />";
- $literally = "My $variable will print!\\n";
- print($literally);
- ?>
- My $variable will not print!\n
- My name will print
- c:\users\lalikali\desktop\web\txt\strtolower.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <body>
- <?php
- echo strtolower("Hello WORLD.");
- ?>
- </body>
- </html>
- hello world.
- c:\users\lalikali\desktop\web\txt\strtoupper.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <body>
- <?php
- echo strtoupper("Hello WORLD!");
- ?>
- </body>
- </html>
- HELLO WORLD!
- c:\users\lalikali\desktop\web\txt\substr_replace.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <body>
- <?php
- echo substr_replace("Hello","world",0); // 0 will start replacing at the first character in the string
- ?>
- </body>
- </html>
- world
- c:\users\lalikali\desktop\web\txt\switch (2).txt
- <---------------------------------------------------------------------->
- <html>
- <body>
- <?php
- $d=date("D");
- switch ($d)
- {
- case "Mon":
- echo "Today is Monday";
- break;
- case "Tue":
- echo "Today is Tuesday";
- break;
- case "Wed":
- echo "Today is Wednesday";
- break;
- case "Thu":
- echo "Today is Thursday";
- break;
- case "Fri":
- echo "Today is Friday";
- break;
- case "Sat":
- echo "Today is Saturday";
- break;
- case "Sun":
- echo "Today is Sunday";
- break;
- default:
- echo "Wonder which day is this ?";
- }
- ?>
- </body>
- </html>
- c:\users\lalikali\desktop\web\txt\switch.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <body>
- <p id="demo"></p>
- <script>
- var day;
- switch (new Date().getDay()) {
- case 0:
- day = "Sunday";
- break;
- case 1:
- day = "Monday";
- break;
- case 2:
- day = "Tuesday";
- break;
- case 3:
- day = "Wednesday";
- break;
- case 4:
- day = "Thursday";
- break;
- case 5:
- day = "Friday";
- break;
- case 6:
- day = "Saturday";
- break;
- }
- document.getElementById("demo").innerHTML = "Today is " + day;
- </script>
- </body>
- </html>
- c:\users\lalikali\desktop\web\txt\thead.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <head>
- <style>
- thead {color:green;}
- tbody {color:blue;}
- tfoot {color:red;}
- table, th, td {
- border: 1px solid black;
- }
- </style>
- </head>
- <body>
- <table>
- <thead>
- <tr>
- <th>Month</th>
- <th>Savings</th>
- </tr>
- </thead>
- <tfoot>
- <tr>
- <td>Sum</td>
- <td>$180</td>
- </tr>
- </tfoot>
- <tbody>
- <tr>
- <td>January</td>
- <td>$100</td>
- </tr>
- <tr>
- <td>February</td>
- <td>$80</td>
- </tr>
- </tbody>
- </table>
- <p><b>Tip:</b> The thead, tbody, and tfoot elements will not affect the layout of the table by default. However, you can use CSS to style these elements.</p>
- </body>
- </html>
- c:\users\lalikali\desktop\web\txt\this.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <body>
- <button onclick="this.innerHTML=Date()">The time is?</button>
- </body>
- </html>
- c:\users\lalikali\desktop\web\txt\thonjeza.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <body>
- <p id="demo"></p>
- <script>
- var carName1 = "Volvo XC60";
- var carName2 = 'Volvo XC60';
- var answer1 = "It's alright";
- var answer2 = "He is called 'Johnny'";
- var answer3 = 'He is called 'Johnny'';
- document.getElementById("demo").innerHTML =
- carName1 + "<br>" +
- carName2 + "<br>" +
- answer1 + "<br>" +
- answer2 + "<br>" +
- answer3;
- </script>
- </body>
- </html>
- c:\users\lalikali\desktop\web\txt\trim.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <body>
- <?php
- $str = "Hello World!";
- echo $str . "<br>";
- echo ltrim($str,"Hello");
- ?>
- </body>
- </html>
- Hello World!
- World!
- <!DOCTYPE html>
- <html>
- <body>
- <?php
- $str = "Hello World!";
- echo $str . "<br>";
- echo rtrim($str,"World!");
- ?>
- </body>
- </html>
- Hello World!
- Hello
- <!DOCTYPE html>
- <html>
- <body>
- <?php
- $str = "Hello World!";
- echo $str . "<br>";
- echo trim($str,"Hed!");
- ?>
- </body>
- </html>
- Hello World!
- llo Worl
- c:\users\lalikali\desktop\web\txt\typeof.txt
- <---------------------------------------------------------------------->
- !DOCTYPE html>
- <html>
- <body>
- <p>The typeof operator returns the type of a variable or an expression.</p>
- <p id="demo"></p>
- <script>
- document.getElementById("demo").innerHTML =
- typeof "john" + "<br>" +
- typeof 3.14 + "<br>" +
- typeof false + "<br>" +
- typeof [1,2,3,4] + "<br>" +
- typeof {name:'john', age:34};
- </script>
- </body>
- </html>
- c:\users\lalikali\desktop\web\txt\ucfirst.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <body>
- <?php
- echo ucfirst("hello world!");
- ?>
- </body>
- </html>
- Hello world!
- c:\users\lalikali\desktop\web\txt\ucwords.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <body>
- <?php
- echo ucwords("hello world");
- ?>
- </body>
- </html>
- Hello World
- c:\users\lalikali\desktop\web\txt\updatimi.txt
- <---------------------------------------------------------------------->
- <html>
- <head>
- <title>Update a Record in MySQL Database</title>
- </head>
- <body>
- <?php
- if(isset($_POST['update'])) {
- $dbhost = 'localhost:3036';
- $dbuser = 'root';
- $dbpass = 'rootpassword';
- $conn = mysql_connect($dbhost, $dbuser, $dbpass);
- if(! $conn ) {
- die('Could not connect: ' . mysql_error());
- }
- $emp_id = $_POST['emp_id'];
- $emp_salary = $_POST['emp_salary'];
- $sql = "UPDATE employee ". "SET emp_salary = $emp_salary ".
- "WHERE emp_id = $emp_id" ;
- mysql_select_db('test_db');
- $retval = mysql_query( $sql, $conn );
- if(! $retval ) {
- die('Could not update data: ' . mysql_error());
- }
- echo "Updated data successfully\n";
- mysql_close($conn);
- }else {
- ?>
- <form method = "post" action = "<?php $_PHP_SELF ?>">
- <table width = "400" border =" 0" cellspacing = "1"
- cellpadding = "2">
- <tr>
- <td width = "100">Employee ID</td>
- <td><input name = "emp_id" type = "text"
- id = "emp_id"></td>
- </tr>
- <tr>
- <td width = "100">Employee Salary</td>
- <td><input name = "emp_salary" type = "text"
- id = "emp_salary"></td>
- </tr>
- <tr>
- <td width = "100"> </td>
- <td> </td>
- </tr>
- <tr>
- <td width = "100"> </td>
- <td>
- <input name = "update" type = "submit"
- id = "update" value = "Update">
- </td>
- </tr>
- </table>
- </form>
- <?php
- }
- ?>
- </body>
- </html>
- c:\users\lalikali\desktop\web\txt\UPPER.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <body>
- <p>Convert string to upper case:</p>
- <button onclick="myFunction()">Try it</button>
- <p id="demo">Hello World!</p>
- <script>
- function myFunction() {
- var text = document.getElementById("demo").innerHTML;
- document.getElementById("demo").innerHTML = text.toUpperCase();
- }
- </script>
- </body>
- </html>
- c:\users\lalikali\desktop\web\txt\uuencode.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <body>
- <?php
- $str = "Hello world!";
- // shifrojme
- $encodeString = convert_uuencode($str);
- echo $encodeString . "<br>";
- // deshifrojme
- $decodeString = convert_uudecode($encodeString);
- echo $decodeString;
- ?>
- </body>
- </html>
- Rez:
- ,2&5L;&\@=V]R;&0A `
- Hello world!
- c:\users\lalikali\desktop\web\txt\validation_new.txt
- <---------------------------------------------------------------------->
- <form method="post" action='cake-form-proc.php' id="cakeform" >
- <div>
- <div class="cont_order">
- <fieldset>
- <legend>Make your cake!</legend>
- <div class='field_container'>
- <label >Size Of the Cake</label>
- <label class='radiolabel'><input type="radio" name="selectedcake" value="Round6" />Round cake 6" - serves 8 people</label><br/>
- <label class='radiolabel'><input type="radio" name="selectedcake" value="Round8" />Round cake 8" - serves 12 people</label><br/>
- <label class='radiolabel'><input type="radio" name="selectedcake" value="Round10" />Round cake 10" - serves 16 people</label><br/>
- <label class='radiolabel'><input type="radio" name="selectedcake" value="Round12" />Round cake 12" - serves 30 people</label><br/>
- </div>
- <div class='field_container'>
- <label for="flavor">Select Flavor:</label >
- <select id="flavor" name='flavor' >
- <option value="">Select Flavor</option>
- <option >Yellow</option>
- <option >White</option>
- <option >Chocolate</option>
- <option >Combo</option>
- </select>
- </div>
- <div class='field_container'>
- <label >Fillings:</label>
- <label><input type="checkbox" value="Lemon" name='Filling[]' />Lemon</label>
- <label><input type="checkbox" value="Custard" name='Filling[]' />Custard</label>
- <label><input type="checkbox" value="Fudge" name='Filling[]' />Fudge</label>
- <label><input type="checkbox" value="Mocha" name='Filling[]' />Mocha</label>
- <label><input type="checkbox" value="Raspberry" name='Filling[]' />Raspberry</label>
- <label><input type="checkbox" value="Pineapple" name='Filling[]' />Pineapple</label>
- </div>
- <div class='field_container'>
- <label class="inlinelabel"><input type="checkbox" id="agree" name='agree' /> I agree to the <a href="javascript:void(0);">terms and conditions</a></label>
- </div>
- </fieldset>
- </div>
- <div class="cont_details">
- <fieldset>
- <legend>Contact Details</legend>
- <label for='name'>Name</label>
- <input type="text" id="name" name='name' />
- <br/>
- <label for='address'>Address</label>
- <input type="text" id="address" name='address' />
- <br/>
- <label for='phonenumber'>Phone Number</label>
- <input type="text" id="phonenumber" name='phonenumber'/>
- <br/>
- </fieldset>
- </div>
- <input type='submit' id='submit' value='Submit' />
- </div>
- </form>
- c:\users\lalikali\desktop\web\txt\validation_new2.txt
- <---------------------------------------------------------------------->
- <body>
- <?php
- $temp = "";
- $msg = "";
- $rst = "";
- if (isset($_POST["submit"])) {
- $number = $_POST["custid"];
- if(empty($number)) {
- $msg = '<span class="error"> Please enter a value</span>';
- } else if(!is_numeric($number)) {
- $msg = '<span class="error"> Data entered was not numeric</span>';
- } else if(strlen($number) != 6) {
- $msg = '<span class="error"> The number entered was not 6 digits long</span>';
- } else {
- echo "valid";
- }
- }
- ?>
- <h1>Customer Information Collection <br /></h1>
- <form method="POST" action="<?php echo $_SERVER["PHP_SELF"];?>" id="custinfo" >
- <table>
- <tr>
- <td><label for="custid">Customer ID (integer value): </label></td>
- <td><input type="text" id="custid" name="custid" value="<?php echo $temp ?>" size=11 /><?php echo $msg; ?></td>
- </tr>
- <tr>
- <td><label for="customerfname">Customer Frist Name: </label></td>
- <td><input type="text" id="customerfname" name="fname" size=50/></td>
- </tr>
- <tr>
- <td><label for="customerlname">Customer Last Name: </label></td>
- <td><input type="text" id="customerlname" name="lname" size=50/></td>
- </tr>
- <tr>
- <td><label for="customeraddress">Customer Address: </label></td>
- <td><input type="text" id="customeraddress" name="custaddress" size=65/></td>
- <td><label for="suburb"> Suburb: </label></td>
- <td><input type="text" id="suburb" name="suburb"/></td>
- </tr>
- <tr>
- <td>
- State:<select name="state" id="state">
- <option value="select">--</option>
- <option value="ACT">ACT</option>
- <option value="NSW">NSW</option>
- <option value="NT">NT</option>
- <option value="QLD">QLD</option>
- <option value="SA">SA</option>
- <option value="TAS">TAS</option>
- <option value="VIC">VIC</option>
- <option value="WA">WA</option>
- </select>
- </td>
- <td><label for="postcode"> Post Code: </label><input type="text" id="postcode" name="postcode" size=4/></td>
- </tr>
- </table>
- <p><input type="submit" name="submit" value="Save Data"/> <input type="reset" value="Clear Form" />
- </tr>
- </form>
- </body>
- modifikim
- if(empty($number)) {
- $msg = '<span class="error"> Please enter a value</span>';
- } else if(!is_numeric($number)) {
- $msg = '<span class="error"> Data entered was not numeric</span>';
- } else if(strlen($number) != 6) {
- $msg = '<span class="error"> The number entered was not 6 digits long</span>';
- } else {
- }
- c:\users\lalikali\desktop\web\txt\validimi.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <body>
- <h1>JavaScript Can Validate Input</h1>
- <p>Please input a number between 1 and 10:</p>
- <input id="numb" type="number">
- <button type="button" onclick="myFunction()">Submit</button>
- <p id="demo"></p>
- <script>
- function myFunction() {
- var x, text;
- // Get the value of the input field with id="numb"
- x = document.getElementById("numb").value;
- // If x is Not a Number or less than one or greater than 10
- if (isNaN(x) || x < 1 || x > 10) {
- text = "Input not valid";
- } else {
- text = "Input OK";
- }
- document.getElementById("demo").innerHTML = text;
- }
- </script>
- </body>
- </html>
- c:\users\lalikali\desktop\web\txt\validimi_javascript_forme.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <head>
- <script>
- function validateForm() {
- var x = document.forms["myForm"]["fname"].value;
- if (x == null || x == "") {
- alert("Name must be filled out");
- return false;
- }
- }
- </script>
- </head>
- <body>
- <form name="myForm" action="demo_form.asp"
- onsubmit="return validateForm()" method="post">
- Name: <input type="text" name="fname">
- <input type="submit" value="Submit">
- </form>
- </body>
- </html>
- c:\users\lalikali\desktop\web\txt\valimi_email.txt
- <---------------------------------------------------------------------->
- //validimi i emrit
- $name = test_input($_POST["name"]);
- if (!preg_match("/^[a-zA-Z ]*$/",$name)) {
- $nameErr = "Only letters and white space allowed";
- }
- //validimi emailit
- $email = test_input($_POST["email"]);
- if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
- $emailErr = "Invalid email format";
- }
- //validimi url
- $website = test_input($_POST["website"]);
- if (!preg_match("/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i",$website)) {
- $websiteErr = "Invalid URL";
- }
- c:\users\lalikali\desktop\web\txt\valimi_email2.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE HTML>
- <html>
- <head>
- <style>
- .error {color: #FF0000;}
- </style>
- </head>
- <body>
- <?php
- // define variables and set to empty values
- $nameErr = $emailErr = $genderErr = $websiteErr = "";
- $name = $email = $gender = $comment = $website = "";
- if ($_SERVER["REQUEST_METHOD"] == "POST") {
- if (empty($_POST["name"])) {
- $nameErr = "Name is required";
- } else {
- $name = test_input($_POST["name"]);
- // check if name only contains letters and whitespace
- if (!preg_match("/^[a-zA-Z ]*$/",$name)) {
- $nameErr = "Only letters and white space allowed";
- }
- }
- if (empty($_POST["email"])) {
- $emailErr = "Email is required";
- } else {
- $email = test_input($_POST["email"]);
- // check if e-mail address is well-formed
- if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
- $emailErr = "Invalid email format";
- }
- }
- if (empty($_POST["website"])) {
- $website = "";
- } else {
- $website = test_input($_POST["website"]);
- // check if URL address syntax is valid
- if (!preg_match("/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i",$website)) {
- $websiteErr = "Invalid URL";
- }
- }
- if (empty($_POST["comment"])) {
- $comment = "";
- } else {
- $comment = test_input($_POST["comment"]);
- }
- if (empty($_POST["gender"])) {
- $genderErr = "Gender is required";
- } else {
- $gender = test_input($_POST["gender"]);
- }
- }
- function test_input($data) {
- $data = trim($data);
- $data = stripslashes($data);
- $data = htmlspecialchars($data);
- return $data;
- }
- ?>
- <h2>PHP Form Validation Example</h2>
- <p><span class="error">* required field.</span></p>
- <form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
- Name: <input type="text" name="name">
- <span class="error">* <?php echo $nameErr;?></span>
- <br><br>
- E-mail: <input type="text" name="email">
- <span class="error">* <?php echo $emailErr;?></span>
- <br><br>
- Website: <input type="text" name="website">
- <span class="error"><?php echo $websiteErr;?></span>
- <br><br>
- Comment: <textarea name="comment" rows="5" cols="40"></textarea>
- <br><br>
- Gender:
- <input type="radio" name="gender" value="female">Female
- <input type="radio" name="gender" value="male">Male
- <span class="error">* <?php echo $genderErr;?></span>
- <br><br>
- <input type="submit" name="submit" value="Submit">
- </form>
- <?php
- echo "<h2>Your Input:</h2>";
- echo $name;
- echo "<br>";
- echo $email;
- echo "<br>";
- echo $website;
- echo "<br>";
- echo $comment;
- echo "<br>";
- echo $gender;
- ?>
- </body>
- </html>
- c:\users\lalikali\desktop\web\txt\variables.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <body>
- <h1>JavaScript Variables</h1>
- <p>In this example, x is defined as a variable.
- Then, x is assigned the value of 6:</p>
- <p id="demo"></p>
- <script>
- var x;
- x = 6;
- document.getElementById("demo").innerHTML = x;
- </script>
- </body>
- </html>
- c:\users\lalikali\desktop\web\txt\vektor.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <body>
- <p id="demo"></p>
- <script>
- var cars = ["Saab","Volvo","BMW"];
- document.getElementById("demo").innerHTML = cars[0];
- </script>
- </body>
- </html>
- c:\users\lalikali\desktop\web\txt\vektor_loop_index.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <body>
- <?php
- $cars = array("Volvo", "BMW", "Toyota");
- $arrlength = count($cars);
- for($x = 0; $x < $arrlength; $x++) {
- echo $cars[$x];
- echo "<br>";
- }
- ?>
- </body>
- </html>
- Volvo
- BMW
- Toyota
- c:\users\lalikali\desktop\web\txt\vektor_loop_shoqerues.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <body>
- <?php
- $age = array("Peter"=>"35", "Ben"=>"37", "Joe"=>"43");
- foreach($age as $x => $x_value) {
- echo "Key=" . $x . ", Value=" . $x_value;
- echo "<br>";
- }
- ?>
- </body>
- </html>
- Key=Peter, Value=35
- Key=Ben, Value=37
- Key=Joe, Value=43
- c:\users\lalikali\desktop\web\txt\vektor1.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <body>
- <?php
- $cars = array("Volvo", "BMW", "Toyota");
- echo count($cars);
- ?>
- </body>
- </html>
- 3
- c:\users\lalikali\desktop\web\txt\welcome_get_php.txt
- <---------------------------------------------------------------------->
- <html>
- <body>
- Welcome <?php echo $_GET["name"]; ?><br>
- Your email address is: <?php echo $_GET["email"]; ?>
- </body>
- </html>
- c:\users\lalikali\desktop\web\txt\welcome_php.txt
- <---------------------------------------------------------------------->
- <html>
- <body>
- Welcome <?php echo $_POST["name"]; ?><br>
- Your email address is: <?php echo $_POST["email"]; ?>
- </body>
- </html>
- c:\users\lalikali\desktop\web\txt\while (2).txt
- <---------------------------------------------------------------------->
- <html>
- <body>
- <?php
- $i = 0;
- $num = 50;
- while( $i < 10)
- {
- $num--;
- $i++;
- }
- echo ("Loop stopped at i = $i and num = $num" );
- ?>
- </body>
- </html>
- rezultati:
- Loop stopped at i = 10 and num = 40
- c:\users\lalikali\desktop\web\txt\while.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <body>
- <p>Click the button to loop through a block of code as long as i is less than 10.</p>
- <button onclick="myFunction()">Try it</button>
- <p id="demo"></p>
- <script>
- function myFunction() {
- var text = "";
- var i = 0;
- while (i < 10) {
- text += "<br>The number is " + i;
- i++;
- }
- document.getElementById("demo").innerHTML = text;
- }
- </script>
- </body>
- </html>
- c:\users\lalikali\desktop\web\txt\window.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <body>
- <h1>My First Web Page</h1>
- <p>My first paragraph.</p>
- <script>
- window.alert(5 + 6);
- </script>
- </body>
- </html>
- c:\users\lalikali\desktop\web\txt\wordwrap.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <body>
- <?php
- $str = "An example of a long word is: Supercalifragulistic";
- echo wordwrap($str,15,"<br>\n",TRUE);
- ?>
- </body>
- </html>
- Rez:
- An example of a
- long word is:
- Supercalifragul
- istic
- c:\users\lalikali\desktop\web\txt\write.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <body>
- <h1>My First Web Page</h1>
- <p>My first paragraph.</p>
- <script>
- document.write(5 + 6);
- </script>
- </body>
- </html>
- c:\users\lalikali\desktop\web\txt\write2.txt
- <---------------------------------------------------------------------->
- <!DOCTYPE html>
- <html>
- <body>
- <h1>My First Web Page</h1>
- <p>My first paragraph.</p>
- <button type="button" onclick="document.write(5 + 6)">Try it</button>
- </body>
- </html>
Add Comment
Please, Sign In to add comment