Sunday, May 1, 2011

What Is XAMPP and how to Install it?

XAMPP is a protocol which allows messages to be sent in XML, the messages are constrained to type, it can be anything, IM messages, or an application talking to another application over the internet. Jabber has the most popular implementation and it is the same protocol used by Gtalk. There might be PHP library that allows you to use XAMPP for communcation.

XAMPP is a free and open source cross-platform web server package, consisting mainly of the Apache HTTP Server, MySQL database, and interpreters for scripts written in the PHP and Perl programming languages.

It is used as a development tool, to allow website designers and programmers to test their work on their own computers without any access to the Internet.

XAMPP is developed by Apache Friends to promote the Apache web server. Apache Friends was founded in the spring of 2002 by Kai ‘Oswald’ Seidler and Kay Vogelgesang. It’s Alexa rank is 7,939 as on today. Because, I use any software or website based on it’s alexa rank, I am mentioning it’s rank here to help my blog readers. XAMPP Acronym is X(Apache, MySQL, PHP, PERL)

Apache Friends developed this software to help the people to install and configure Apache web server along with MySQL, PHP and Perl.


* The file name of the software after downloading from specified location is xampp-win32-1.7.3.exe
* Right click on the file and click Run as administrator and click Run in the Open File – Security warning
* Click Install in “XAMPP for Windows” screen
* Type “y” for the question “Should I add shortcuts to the start menu/desktop? (y/n):” and hit enter
* Type “y” for the question “Should I Proceed? (y/x=exit setup):”
* Type “y” for the question “Should I make a portable XAMPP without drive letters? Your choice:”
* Press Enter – Enter and Type x and Enter in the next 3 steps
* You have successfully installed XAMPP in your computer now

Now we will see how to test web server with PHP, MySQL. The following steps for testing Apache web server, PHP and MySQL

* Open web browser and type http://local host in address bar and hit enter
* If you get “Internet Explorer cannot display the webpage” message, we have forgotten to start the web server
* To start web server Click start – click all programs – click XAMPP for Windows – Click XAMPP Control Panel
* Click start button which opposite to Apache label
* Now try to browse using above url http://localhost
* Now you should get the welcome page of XAMPP for Windows
* If you can be able to see the XAMPP home page means you can understand that Apache web server is working fine
* Now click on the link phpinfo() from left navigation of XAMPP to get the information about PHP
* If you get the information about PHP version and other details in the right pane you can understand that PHP is installed and configured on your computer
* You also can check whether Perl installed and configured or not by clicking on the link perlinfo() in the left page. Detailed information should be displayed in the right pane
* You have to start MySQL from XAMPP control panel to test the phpMyAdmin. phpMyAdmin is a tool to manage MySql databases


Saturday, April 16, 2011

CREATE A CONTACT FORM IN DREAMWEAVER CS3 USING ASP

CREATE A CONTACT FORM IN DREAMWEAVER CS3 USING ASP
  • Create a new site in Dreamweaver CS 3. Save the new site in c:\inetpub\wwwroot\project.
  • Create a database in Access and save the database in the folder c:\inetpub\wwwroot\data. The database must save in MS Access 2002-2003 with .mdb file extension
  • create a table in database and create the following fields:
  1. name1
  2. username
  3. password
  4. remarks
  • 4. For remarks field, choose Memo as its data type.
  • 5. Then create connection in Dreamweaver CS3. Open the database panel, click at + button, select Custom Connection String. Enter a name for the connection as dmx. Enter the connection string as
"Driver={Microsoft Access Driver (*.mdb)};DBQ="& Server.MapPath("/data/guest.mdb").
  • Click the button Test to connect to the database and then click OK.

  • Create a new ASP VBScript page. Insert a form. Insert a table and insert the text and text field.
  • Give the name to the text field in Properties panel.
  • Save the page as daftar.asp in c:\inetpub\wwwroot\project
  • Then set the Insert Record to write data into database. Click Active Server Behaviors tab. Click the + button then select Insert Record, select the connection that you gad created then click ok. Save the file.
  • Create a new ASP VBScript page. Save the file as view.asp.
  • Create the text and text field for name, username, password and remarks.
  • Click Server Behaviors tab. Click the + button, select RecordSet. Select the connection that you had created. Select sort: name1 and Ascending to sort the data for viewing. Click Test.
  • Activate Bindings tab. Click + button select RecordSet. Click at + button sign in front of the RecordSet and you can see all the fields in the database.
  • Drag nama into cell 1 in column 2 in the table that you create in view.asp. drag other fields also into the following cell in column 2. Draw a line below the table. Next highlight the table including the line below the table. Click the + button on the panel, select Repeat Region. Click OK.
  • Open back your daftar.asp file. Double click Insert Record behavior in Server Behavior and add view.asp in After inserting go to: Click OK.
  • Click at Preview in Browser icon. Type any data and click save button. Automatically the view.asp file will be displayed and you can see the data that you typed.

Solve IIS Installation Problem For Windows User

QUESTION:
I am a windows users and I always have face the same problem when installing IIS on my computer. What I need to do?

ANSWER:
Here are the solution for problems in Microsoft Windows.
  1. Open Windows Explorer > click tools > folder options > activate view tab.
  2. Then deactivate Use simple file sharing (recommended) options.
  3. Click OK.
  4. Open your inetpub folder at c:\Inetpub\wwwroot\folder using windows explorer.
  5. Right click at the folder that holds the access database file and click at properties.
  6. Click at security tab and click add button > then click advanced button.
  7. Click at find now button and choose everyone.Click ok.
  8. Then activate write options for everyone user.
  9. Click OK.

Friday, April 8, 2011

WEEK 12 - PHP

Buka xampp untuk Start MySQL

pilih SCM (window Services akan terbuka) dan stop kan IIS

C:\xampp\htdocs\learning
C:\xampp\mysql\data\data

Cuba tengok di bahagian Application dalam Dreamweaver
dah ada dmx

Cuba http://localhost/ di Firefox untuk ke xampp

Friday, April 1, 2011

PHP GUESTBOOK TUTORIAL

First off we need phpMyAdmin and to create admin table and insert some admins inside it, here is code you need for phpMyAdmin, use same database as your guestbook is in.

CREATE TABLE admins (
username varchar(50),
password varchar(50),
id int(11) NOT NULL auto_increment,
PRIMARY KEY (id)
) TYPE=MyISAM;

Now over phpMyAdmin you need to add admins, go to admins table and click insert, write in username and password, from scroll down box on left from password select MD5 so it protects it with md5 hash, when you have done that it’s start to do admin part of guestbook, make folder admin where your guestbook is and inside it make first file named form.php, put this code inside.














Username:
Password:


When you have made form we need login.php file that will check for login details and if successful it will log you in.

// Check if login button has been pressed
if(isset($_POST['login'])){
// Define username and password
$username = $_POST['username'];
$password = $_POST['password'];
// Do some stripslashes on them
$username = stripslashes($username);
$password = stripslashes($password);
$password = md5($password);
// Include our config file for mysql server connect and select database
include "../config.php";
// Query admins table and check if admin data is good
$query = "SELECT username, password FROM admins WHERE username = '$username' AND password = '$password' LIMIT 1";
$result = mysql_query($query);
$count = mysql_num_rows($result);
// If result is good start session and register it with s_logged_n
if($count == 1){
session_start();
$_SESSION['s_logged_n'] = 'true';
$_SESSION['s_username'] = $username;
// Display successful login message
echo "You have sucessfully logged in, click here to access admin area";
} else {
// If user or pass is wrong display it
echo "Invalid username or password";
}
} else {
// If someone try to open login.php only tells them to use form
echo "You must login over form, click here to go back to login";
}
?>

Now when we have login.php we need index.php where our post from guestbook and options to edit or delete them will be, so make file index.php and put this code inside

// Start sessions and check if sessions is registered from login form, if it is true display admin data, else display that you must login
session_start();
if(
$_SESSION['s_logged_n'] == 'true'){
?>
Welcome to admin area echo $_SESSION['s_username']; ?>, here you can administrate guestbook.




= "10";
// Include config file
include "../config.php";
// if we don't get page number get page number 1
if(!isset($_GET['page'])){
$page = 1;
} else {
$page = $_GET['page'];
}
// Max results per page
$max_results = "$max";
$from = (($page * $max_results) - $max_results);
// Do query on database table
$query = "SELECT * FROM guestbook ORDER BY id DESC LIMIT $from, $max_results";
$result = mysql_query($query);
// If query is ok then output messages from guestbook
if ($result) {
while (
$row = mysql_fetch_array($result)):
?>










endwhile ?>


Posted by echo $row['name']; ?> if($row['website'] == ''){
echo
"";
} else {
echo
". $row['website'] . "\">www";
}
?>
on echo $row['date']; ?> - echo $row['id']; ?>">click to edit - echo $row['id']; ?>">click to delete
echo $row['message']; ?>

Go to page #:= mysql_result(mysql_query("SELECT COUNT(*) as Num FROM guestbook"),0);
$total_pages = ceil($total_results / $max_results);
for(
$i = 1; $i <= $total_pages; $i++){
if((
$page) == $i){
echo
"$i ";
} else {
echo
".$_SERVER['PHP_SELF']."?page=$i\" title=\"Go to page $i\">$i ";
}
}
?>

// If query fails then output it
} else {
echo
"Unable to select data from database table";
}
?>
} else {
echo
"You must login to access admin area";
}
?>

When index.php is done we need file edit.php and this code that goes in

// Start sessions and check if sessions is registered from login form, if it is true display admin data, else display that you must login
session_start();
if(
$_SESSION['s_logged_n'] == 'true'){
?>
// Get the id of the post
if(isset($_GET['id'])){
$id = $_GET['id'];
include
"../config.php";
$query = "SELECT * FROM guestbook WHERE id = '$id' LIMIT 1";
$result = mysql_query($query);
if (!
$result){
echo
"Please select what post to edit over index page";
} else {
while (
$row = mysql_fetch_array($result)):
?>

echo "$id"; ?>" method="post">





















Name:
echo $row['name']; ?>">
Email:
echo $row['email']; ?>">
Website:
echo $row['website']; ?>">
Message:



endwhile ?>
}
}
} else {
echo
"Please login over
form."
;
}
?>

And now our delete.php file that has this code

// Start sessions and check if sessions is registered from login form, if it is true display admin data, else display that you must login
session_start();
if(
$_SESSION['s_logged_n'] == 'true'){
?>
// Get the id of the post
if(isset($_GET['id'])){
$id = $_GET['id'];
include
"../config.php";
$query = "DELETE FROM guestbook WHERE id = '$id' LIMIT 1";
$result = mysql_query($query);
if (
$result){
echo
"Successfully deleted post";
} else {
echo
"There was an error deleting post";
}
}
} else {
echo
"Please login over form.";
}
?>

And now finally our update.php file that have contents of updating posts inside, code goes like this

// Start sessions and check if sessions is registered from login form, if it is true display admin data, else display that you must login
session_start();
if(
$_SESSION['s_logged_n'] == 'true'){
?>
// If form button has been pressed then do the following
if(isset($_POST['update'])){
// Get id of post
$id = $_GET['id'];
// Include config file
include "../config.php";
$name = $_POST['name'];
$email = $_POST['email'];
$website = $_POST['website'];
$message = $_POST['message'];
// Make some preg replaces
$name = preg_replace("/>/",">",$name);
$name = preg_replace("/,"<",$name);
$email = preg_replace("/>/",">",$email);
$email = preg_replace("/,"<",$email);
$website = preg_replace("/>/",">",$website);
$website = preg_replace("/,"<",$website);
$message = preg_replace("/>/",">",$message);
$message = preg_replace("/,"<",$message);
// Add few stripslashes...
$name = stripslashes($name);
$email = stripslashes($email);
$website = stripslashes($website);
$message = stripslashes($message);
// Check if fields name, email and message are empty
if ((( empty($name) ) || ( empty($email) ) || ( empty($message) ))){
// If they are empty then output message
echo "Please write in all fields, name, email and message";
// Else if they are filled in check if email is valid
} elseif ((!strstr($email , "@")) || (!strstr($email , "."))) {
// If email is invalid then output it
echo "Please use valid email address";
} else {
// If all fields and email is valid then update data to database
// Do the query
$query = "UPDATE guestbook SET name = '$name', email = '$email', website = '$website', message = '$message' WHERE id = '$id' LIMIT 1";
$result = mysql_query($query);
if (
$result){
echo
"Successfully edited post";
} else {
echo
"There was error editing post";
}
}
}
} else {
echo
"Please login over form.";
}
?>

And that would be it, all this files must be inside guestbook/admin folder

Friday, March 4, 2011

ASP versus PHP 4 MAC 2011

ASP = Actives Server Pages, PHP Hypertext Preprocessor

ASP and PHP are both programming languages that are commonly used to create websites. Unlike the usual static html web pages, ASP and PHP websites are more dynamic and can allow users to interact and exchange information using the website's databases.

ASP is the short term for Active Server Pages, a type of program that works with Microsoft alongside IIS or Internet Information Server. ASP needs a Microsoft Server for the website to work. On the other, PHP or Hypertext Preprocessor, runs using Linux or Unix server. The more updated PHP programs can now run on an NT server.

Platfrom
PHP programs can also run in Windows, Solaris, Unix and Linux while ASP can only work with Window-based platforms. Just recently, ASP can now run on a Linux platform given that there is an ASP-Apache program installed on its server.

Language Programme
If you were a programmer adept with the C++ language, you would probably be more comfortable using PHP than ASP. PHP uses C/C++ as base language and most syntax are similar to each other. Because a big chunk of programmers are still using C++ language, PHP are by far more popular than ASP.


ASP is very much similar to the syntax and interface of Visual Basic programming. This is basically because Visual Basic is basically correlated with Microsoft products and programs. So if you were a programmer, choosing between ASP and PHP would basically depend on which language you are more adept with.

Server Installation Cost
When it comes to costing and expenses, ASP programs needs to run on Windows with IIS installed on the server. You need to purchase both of these components in order for ASP to work. On the other hand, a PHP would only require running on a Linux server, which you can get at no cost.

Database
PHP is very much flexible when it terms of database connectivity. It can connect to several databases of which the most commonly used is the MySQL. Note that MySQL would not cost you a thing to use. But if you were to use ASP, you need to purchase MS-SQL, which is a Microsoft product.

Speed and Secure
Loading speed is a big factor in maintaining a website. If you are particular about speed, then you need to go with PHP. PHP codes runs much quicker than ASP basically because it runs in its very own memory space while ASP uses an overhead server and is uses a COM based architecture.

Cost
In working with PHP, most tools associated with the program are mostly open source software so you need not pay for them. As for ASP, you might need to buy additional tools to work with its programs.


In conclusion, both PHP and ASP have its own advantages and disadvantages. It basically depends on which part of developing a website you are most concerned with. Are you worried about the cost of creating your website? Do you want to use a programming language that you are more familiar with? Do you want a more stable and faster website? Choosing between ASP and PHP basically depends on your own personal preference. It doesn't hurt to confer with other programmers or webmasters and research more information on which programming would best fit the requirements of your website.
ASP versus PHP

Tuesday, March 1, 2011

Drag And Drop Flash CS3

This Flash CS3 Tutorial is about controlling graphics with the mouse, creating the tweens will not be covered. However, you will learn how to make the smiley face react to the mouse. Lets make the MovieClip do something every time the mouse moves over it. Start by coping the code from the example to the first key frame in the actions layer.

smiley_mc.addEventListener(MouseEvent.MOUSE_OVER , smiley);
function smiley(event:MouseEvent):void{

smiley_mc.play()
};

The code creates an Event Listener and adds that Event Listener to the MovieClip smiley_mc. Event listeners have been covered in more depth other Flash CS3 Tutorials. The Event Listener is simply listening for the MouseEvent Mouse over. Then once the event happens ActionScript is telling the MovieClip smiley_mc to play.

Press Control-Enter to see the Smiley Face react.

If you once again go into the Smiley MovieClip and look at the key Frames you will see how this works. When the Event Listeners detects that the mouse has passed over or onto the smiley_mc, actionScript tells the smiley_mc to play, thus playing the movie until something tells the smiley_mc movie to stop. In this case there are key frames in the actions layer that simply have the stop action added to them. You can create any form of animation inside a movie clip then use action script to control when the movie plays.

Drag and Drop
Lets add some more interactivity to the smiley face by adding a drag and drop ability.

Copy the example code and add it below the current event listener.
smiley_mc.addEventListener(MouseEvent.MOUSE_DOWN , smileyDrag);
function smileyDrag(event:MouseEvent):void{

smiley_mc.startDrag();
};

Once again you will see the slandered event listener. What is new would be the smiley_mc.startDrag();. The startDrag method tells Flash CS3 to enable a MovieClip to be moved around the stage. You define which MovieClip by placing the name of the MovieClip in front of the startDrag method, separated with a period. If you test the movie at this point you will see that when you click on the smiley face it movies with the mouse cursor., but how do you stop dragging the smiley around. Well, you need to add another Event Listener.
smiley_mc.addEventListener(MouseEvent.MOUSE_UP , smileyStopDrag);
function smileyStopDrag(event:MouseEvent):void{

smiley_mc.stopDrag();
};

The first Event Listener listened for the mouse to be pressed down. This time you need Flash CS3 to listen for the mouse up event. Since you want the smiley_mc to stop dragging when the mouse button is released you will add the method stopDrag to the MovieClip. Basically, you use the same thing to stop dragging as you do to start dragging.

RESOURCE: http://www.squidoo.com/flash_cs3_tutorial_DragAndDrop

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | belt buckles