Wednesday, May 9, 2012

jQuery validate

How to check your forms in 5 mins or less?

I myself like to use jQuery Validate why because its easy to set up ill give an example below:

The first step is to include at the top of your page(You need to have jQuery in order to make jQuery validate work ):



<script type="text/javascript" src="http://jzaefferer.github.com/jquery-validation/jquery.validate.js"></script> 

Second step is to have a form:


<form  id="commentForm" method="get" action="">
 <fieldset>
   <legend>A simple comment form with submit validation and default messages</legend>
   <p>
     <label for="cname">Name</label>
     <em>*</em><input id="cname" name="name" size="25" class="required" minlength="2" />
   </p>
   <p>
     <label for="cemail">E-Mail</label>
     <em>*</em><input id="cemail" name="email" size="25"  class="required email" />
   </p>
   <p>
     <label for="curl">URL</label>
     <em>  </em><input id="curl" name="url" size="25"  class="url" value="" />
   </p>
   <p>
     <label for="ccomment">Your comment</label>
     <em>*</em><textarea id="ccomment" name="comment" cols="22"  class="required"></textarea>
   </p>
   <p>
     <input class="submit" type="submit" value="Submit"/>
   </p>
 </fieldset>
 </form>

Third step is to define the form:

$("#commentForm").validate();

Wednesday, February 22, 2012

PHP Functions

Functions

I myself like to use functions because they are easy to use and you can use a function if its made up well several times in your code.  

Example:

 <?

 function book($title,$auteur)
{
    echo $title;
    echo "<br/>";
    echo $auteur;
 }


 $this->book("Peterpan","writer")
?> 
This will give you 

Peterpan  
writer 

Thursday, February 16, 2012

Blog changes?

Struggling!

Im still struggling on how i want to present my blog, i have alot of ideas so there will be changes regarding tutorials. I think i will just post what triggers me at a certain moment. So be on the lookout for some crazy funny twisted tutorials!

regards.

From zero to hero!

The beginning!

Well today i started writing an class with functions from scrach, and when i was done i felt proud. I never actually started from scratch because i always used to believe it was better to copy paste from other examples.

When i started typing, it felt like i was writing a book,  i wastyping an exciting story with different plots anything could happen at any time.

And when you compare coding with writing an book, it actually is the same on a certainleve;. As long as you know the main characters and the plot. 

Lets say i wrote my own page today from scratch.


regards.



Monday, February 6, 2012

Step 2: First PHP page

PHP page


Bellow we will find a regular HTML page:

mypage.html
<html>
<head>
<title>This is my page</title>
</head>

<body>
This is the content of my page.

</body>

</html>

To create a PHP page using the page above as our model, the first important action is to rename our file. In our case we will name the file "mypage.php". When a file with ".php" extension is placed in the server and the corresponding url is visited, the server will process the file before sending it to the client, so that all PHP commands will be processed. We may just change the name of our file as propoused  and save it to our server (without any additional changes), and when visiting the corresponding URL the result will be exactly the same (because there is nothing to be processed in the page) . 

To this renamed page ("mypage.php") we will add a small PHP command within  <?php opening tag and ?> closing tag.

mypage.php
<html>
<head>
<title>This is my page</title>
</head>

<body>
This is the content of my page.
<?php
print "Do you like it?";
?>


</body>

</html>

When visiting the page, the server will process the page to execute all PHP commands in the page, which will be located within   <?php opening tag and ?> closing tags. In our case  "print" command will  write to the resulting page the text contained between brakets ("Do you like it?"). Often, instead of print command, echo command is used to output string. At the end of the line we will add ";" (otherway we will get an error). We may use "echo" command instead of "print", and the result will be identical.

We may also include all the php commands in one line by placing the code bellow in our page.
 <?php print "Do you like it?"; ?>

Between opening and closing tags we may include several lines with executable commands as shown bellow (we must write ";" at the end of each line):


mypage.php
<html>
<head>
<title>This is my page</title>
</head>

<body>
This is the content of my page.
<?php
print "Do you like it?";
print "<br>";
print "<b>If not, please visit a different page.</b>";
print "<br>";
print "<h1>Goodbay</h1>";
?>

</body>

</html>


Additionaly we may add  several opening and closing tags within our page with executable commands. 



mypage.php
<html>
<head>
<title>This is my page</title>
</head>

<body <?php print "bgcolor=#FFFFFF"; ?>>
<?php
print "Hello!<br>";
?>
This is the content of my page.
<?php
print "Do you like it?";
print "<br>";
print "<b>If not, please visit a different page.</b>";
print "<br>";
print "<h1>Goodbay</h1>";
?>

</body>

</html>

As sown in the example above we may add PHP scripts within HTML tags.

Concatenation of strings

Check the codes bellow:

Code 1
<?php
print "Hello!<br>";

print "I am Joe";

?>
Code 2
<?php
print "Hello!<br>".
"I am Joe";
?>

The pages containing any of the codes above will be exactly the same. We have just put both lines in one, and to do that we have use a point between the two texts we want to show in our pages. The point used in Code 2 will concatenated both strings.

Writing some special characters

Check the codes bellow:

The code The output
Use "\n" to add a line break
<pre>
<?php
print "AA\nBB\nCC\nDD\nEE";
?>
</pre>
Use "\n" to add a line break
AA
BB
CC
DD
EE
Use "\"" to add brakets<br>
<?php
print "He said \"Hello\" to John";
?>
Use "\"" to add brakets
He said "Hello" to John



Using variables: first step

With PHP we may also use variables. The variables used in PHP will always start with "$", as for example $i, $a, $mydata, $my_name etc. There are some words which we are not allow to use as a name for a variable, but as we probably do not know which ones are they, our best decission will be to use very descriptive variable names:
$my_favorite_song
$my_counter
$username
etc


In the example bellow we have write a PHP page using some variables:

mypage.php
<?php
$my_name="Joe";
$my_hello_text="Hello everybody!";
$year_create=2002;
?>


<html>
<head>
<title>This is <?php print  $my_name; ?>´spage</title>
</head>

<body>

<?php print $my_hello_text; ?>

This page was written in <?php print  $year_create; ?>.
</body>

</html>

In this example, we have defined three variables (line 2, 3 and 4) and we have included the information in the variable latter within the HTML code.

Check those variables carefully: $my_name, $my_hello_text and  $year_create has not been  defined in advance (we have add a value to the variables  the first time they have used them in the file, without letting know the program we will used it in advance), and the values do not contain the same kind of content:

$my_name, $my_hello_text  are strings
$year_create  is a number

We may also use variables in the following ways:

The code The output
<?php
$year_create=2002;
print  "This page was written in ".$year_create;
?>
This page was written in 2002
<?php
$year_create=2002;
print  "This page was written in $year_create";
 ?>
This page was written in 2002
<?php
$the_text="This page was written in ";
$year_create=2002;
print  $the_text.$year_create;
 ?>
This page was written in 2002
<?php
$the_text="This page was written in ";
$year_create=2002;
print  "$the_text$year_create";
 ?>
This page was written in 2002

Wednesday, October 5, 2011

Cascading Style Sheets


Cascading Style Sheets


What is CSS?

  • CSS stands for Cascading Style Sheets
  • Styles define how to display HTML elements
  • Styles were added to HTML 4.0 to solve a problem
  • External Style Sheets can save a lot of work
  • External Style Sheets are stored in CSS files
You can basically say, CSS is the colouring of your page at this stage.



Description

CSS stands for Cascading Style Sheet. CSS can format the document content(written in HTML or other markup language):
  • layout
  • colors
  • fonts
... etc.
CSS is designed primarily to enable the separation of the document content and document format. As a result, we can improve content accessibility, can similarly format two or more documents.

p{
  color: red;
  font-size: 12px;
  background-color: green;
}


dding style to HTML

There are three ways of providing styling information for the Web browsers.

Linking style sheet

You can separate style sheets from HTML documents. Style sheet files are imported to HTML documents by <link>.
This offers several benefits:
  • Authors and Web site managers may share style sheets across a number of documents (and sites).
  • Authors may change the style sheet without requiring modifications to the document.
  • User agents may load style sheets selectively (based on media descriptions).

[example.html]
 <head>
   <link rel="stylesheet" type="text/css" href="example.css">
 </head>
[example.css]
 p{
   color: red;
   foto-size: 120%;
 }

Webhosting

Web Hosting

 
Just about anybody can create a presence on the Internet. Building a web site can be as simple as using a word processor, but once you have the site you need a way to publish it on the World Wide Web. This is where web-hosting companies come in.

A web host rents you disk space and provides all the services necessary for others to see your web site on the Internet. Barring technical problems, a web host operates 24 hours a day, 7 days a week so that anybody in the world can access your web site at any time.


There are literally thousands of web hosts to choose from so choosing an appropriate host can be a difficult task. The prices range from free to hundreds of dollars a year. Hosting companies can offer a multitude of services that can be confusing to a newcomer. This series of articles will help you to sort out all the information available and give you the confidence to make the proper decision about choosing a web host.
Free or Paid?
There are plenty of hosting companies that provide free hosting, so why bother paying for it? The old adage ‘You get what you pay for’ is just as valid in the electronic age as it was 100 years ago. In web hosting, when you pay nothing you sometimes end up with nothing.


Most free web hosts offer limited services. Even though they are not charging you to host your website, they still need to make money. They often do this by placing advertising on your site. You probably won’t have any control over what kind of ads show up – it’s a matter of take it or leave it.


In addition, free hosts may restrict the content you place on your site. You may not be allowed to sell things or have certain content such as videos or music. Finally, your web site could simply disappear overnight. New companies that offer free hosting pop up almost everyday, but they also vanish with astonishing regularity. When your hosting company vanishes, your web site goes with it.
If you are serious about having a web site you need to use a reliable web host. Prices range considerably – some companies offer rates as low as $2 a month while others charge $60 or more. Be careful, though. High rates don’t always translate as high service. Some of the lower priced hosts offer reliable, stable environments that allow your website to be accessed day in day out for years.


Generally speaking the more you pay the more you get. Higher rates should bring you more storage space, more bandwidth to handle Internet traffic, and more services such as databases, email accounts, mass mailers, and the ability to add custom scripts. Higher rates can also mean better technical service if you have problems with your website.

What is a Web Server?

Whichever hosting company you choose, it helps to understand some of the technical details about their service. Every host has dedicated computers called servers which connect to the Internet and ’serve’ pages when they are requested. That is, whenever anyone wants to see a certain web page by clicking on a link the request is sent to the particular server where that web page is stored. The server responds by sending HTML data across the Internet. A web server must have fast connections to be able to serve pages quickly. For the greatest speed and reliability try to find a host that has multiple high-speed connections as well as reliable back up power supplies in case of power outages.

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | Best Web Hosting Coupons