Read XML file using PHP

0
COM
Reading XML file in PHP is as easy as copy-paste. We can read an XML file using simplexml_load_file() function which takes XML filename as a parameter:

simplexml_load_file($filename);

Let's read an XML file containing song list:



Now the PHP:


?php  
$filename = "sample.xml";
$xml = simplexml_load_file($filename);
?>

Now you access any tag in the XML using the variable $xml.
Let's see how it works: 





Now let's what it did for us:


You can also access the attributes like this: 



which will look like this:


And in the end if you want to read the whole XML, then abviously loop will be used, here is the code:



And here is the output: 




Hope this tutorial will be helpful to you...

Styling HTML5 Validation

0
COM
To change the style of the validation message bubble, four div elements with pseudo-classes are used:


::-webkit-validation-bubble
::-webkit-validation-bubble-arrow-clipper
::-webkit-validation-bubble-arrow
::-webkit-validation-bubble-message


You can clearly see the change in the validation message bubble


Before Styling

After Styling

Let's add some style in the validated input field I've created here:

CSS:


::-webkit-validation-bubble-arrow
{
border:2px solid #F00;
background:#FD8484;
-webkit-box-shadow:none;
}
::-webkit-validation-bubble-message
{
position: relative;
color:#F00;
background:#FD8484;
border:2px solid #F00;
-webkit-box-shadow: 2px 2px 3px rgba(0,0,0,0.333);
}

This is what it will give:

After Styling

You can learn more about this styling at WebKit wiki.
Credit goes to  WebKit wiki 

HTML5 Form Validation

0
COM
To validate a form in HTML5, you don't need to write tons of code, it is as easy as copy and paste in HTML5. All you have to do is this:


The 'required' attribute : 
To make the field required for the user, just add a 'required' attribute in any input field:


Your Name: <input type="text" name="name" required>


which gives you


The 'required' attribute
Other input types :
There are many other input types in HTML5 which gives you full control to validate you forms, some of the commonly used are given below:


1. Email : 
The input field with email attribute accepts only email addresses:


Your Email: <input type="email" name="email">
<input type="submit" name="submit" value="Submit">




Email Validation


2. Number :
The number attribute gives the user numbers to select, for example Age.


Enter Age: <input type="number" name="age">


You can define the 'min' and 'max' attributes to constrain the field:


Enter Age: <input type="number" name="age" min="18" max="50">


Number Attribute

3. Url :
The url attribute let you to take urls from user:

Enter URL: <input type="url" name="website">

URL Attribute

Similarly, there are other attributes by which you can validate your form:

  • search
  • date
  • month
  • week
  • tel
  • time
  • color
Now the question is can we style the validation bubble? And surely the answer is yes. The next tutorial shows you how to give style to the validation bubble.

How to give shadow in css

0
COM
To give shadow, box-shadow property is used.
Here is the general syntax to use this property:


box-shadow:h-value v-value blur spread color inset;


Let's make a rectangle with some shadow effect:
CSS:

.shadow
{
width:250px;
height:250px;
background-color:#666;
box-shadow:10px 10px 10px 5px #333;
-webkit-box-radius:10px 10px 10px 5px #333;
-moz-box-shadow:10px 10px 10px 5px #333;
}

HTML



   <div class="shadow"></div>



Here is what we create:




How to select the largest value in MySQL?

0
COM
To return the largest value from a column, MAX() function is used.
Here is the syntax:


SELECT MAX(column_name) FROM table_name



Example:
Look at the following "Orders" table. Now we want to find the largest value of the "OrderPrice" column.


OrderIdOrderDateOrderPrice
12010/11/121000
22010/10/231600
32010/09/02700
42010/09/03300
52010/08/302000
62010/10/04100


This can be done by using this statement:

SELECT MAX(OrderPrice) FROM Orders

Result:
2000

How to connect to MySQL database through PHP?

0
COM
In PHP, we can connect to the database with the mysql_connect() function.


<?php


   mysql_connect("server","user","password") or  die(mysql_error());


?>


where "server" is the host name (usually 'localhost'), 
"user" and "password" is the username and password for that database respectively.
The "or die(mysql..." code displays an error message in your browser if --you've probably guessed it -- there is an error in processing the connection! Double-check your username, password, or server if you receive this error.

How to create Navigation Bar using CSS?

0
COM
Navigation Bar using CSS
Live Demo

HTML Part:
The HTML part is very simple, the structure is a <ul> list with a <li>
element for each link in the navigation bar:

     <ul>
    <li><a href="#">Home</a></li>
        <li><a href="#">Services</a></li>
        <li><a href="#">About</a></li>
        <li><a href="#">Contact</a></li>
    </ul>

CSS Part:
Copy the css code and paste in the <header> section of your webpage:

<style>
ul
{
list-style:none;
padding:0px;
margin:0px;
}
li
{
float:left;
}
a:link, a:visited
{
display:block;
width:150px;
text-align:center;
font-family:Tahoma, Verdana;
color:#333333;
text-decoration:none;
padding:6px;
font-weight:bold;
background-color:#66CCFF;
}
a:hover
{
background-color:#6699CC;
}
</style>


How to redirect in PHP?

0
COM
In PHP, header() function is used redirect from one page to another:


<?php


header("Location:http://www.webistuffs.blogspot.com");


?>

How to create a Contact Form with Validation in Dreamweaver?

0
COM
First of all, select "FORM" from the insert tab as shown in figure(1).
figure(1)

This will create a form indicated with red dots. [figure(2)]

figure(2)

Now add a text field like in figure(3).
figure(3)

Give it a label of Name:
figure(4)

This will create a text box with label "Name:"  [figure(5)]
figure(5)

Simply repeat a step to create another text field with label "E-mail:" [figure(6)]
figure(6)
 Now select the Text Area from the bar where you select the Text Field and give it a label "Message:". It will look like this:
figure(7)

Now add buttons through which we can submit or reset our form. Select Button
and press OK.
figure(8)

Now you can see in the below picture that couple of buttons are added to submit and reset our form. But both have the same value i.e. Submit and both will submit the form but we want one to submit and other one to reset the form. For this change the value of the second button as shown in figure(9) and its action to Reset Form.
figure(9)

Now we have completed our work. The form will look like this:
figure(10)


Now to validate our form, go to Tag Inspector and open Behaviors tab and click on the plus sign. [figure(11)]
figure(11)

Select "Validate Form"
figure(12)


Validate the form as your requirement.
figure(13)
 Run the webpage in the browser and test your work.
figure(14)

Hope its helpful...

Redirection Through Javascript

0
COM
To create a Javascript redirection, place the following code in the <head> section of your webpage:







<script type="text/javascript">
<!--
window.location = "http://www.webistuffs.blogspot.com"
//-->
</script>

How to Add favicon icon in the Website?

0
COM

  1. Create a 16 pixel wide by 16 pixel high favicon.bmp file in a Program like MS-Paint, Adobe Photoshop , or Jasc's Paint Shop Pro , then use a program (such as the free IrFanView app  [for Windows]) to reduce the colors to 16 colors [Image -> Decrease Color Depth], and then 'save as...' to a Windows Icon Format (favicon.ico).
  2. Upload the image (favicon.ico) to the root section of you site.
  3. Add the following code to the <head> section of your webpage:
    <link rel="icon" type="image/ico" href="favicon.ico" />


What is PHP?

0
COM
PHP (recursive acronym for PHP: Hypertext Preprocessor) is a widely-used open source general-purpose scripting language that is especially suited for web development and can be embedded into HTML.
Nice, but what does that mean? An example:


*************************************************************
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
<html>
    <head>
        <title>Example</title>
    </head>
    <body>

        <?php
            echo "Hi, I'm a PHP script!";
        ?>

    </body>
</html>

************************************************************

Instead of lots of commands to output HTML (as seen in C or Perl), PHP pages contain HTML with embedded code that does "something" (in this case, output "Hi, I'm a PHP script!"). The PHP code is enclosed in special start and end processing instructions <?php and ?> that allow you to jump into and out of "PHP mode".