• Connect with Me

    Follow Me @ Twitter
    My Facebook Profile
    My Orkut Profile
    My FriendFeed Profile
  • Archives


  • My blog is worth $2,258.16.
    How much is your blog worth?

  • My Creation

  • Creative Commons License

How To Create A Random Message Generator Using PHP

Objective: User gets a new message every time; he  refreshes the page.

Requirements: Adobe Dreamweaver or any Open Source Editor like Amaya, Aptana Studio etc.

Code:

<?php

$thoughts = “WORK IS WORSHIP

AS YOU SOW, SO YOU REAP

BARKING DOG SELDOM BITE

KNOWLEDGE IS POWER

SHOOT FOR THE MOON, YOU WILL REACH THE STARS

AN APPLE A DAY KEEPS THE DOCTOR AWAY

I AM WHAT, I AM

TO ERR IS HUMAN, TO FORGIVE IS DIVINE

WHEN THE NIGHT IS DARKEST, THE DAWN IS NEAREST

THEY CONQUER WHO BELIEVE THEY CAN

NOTHING IS IMPOSSIBLE

TIME &amp; TIDE WAITS FOR NONE

THINK BEFORE YOU LEAP”;

$thoughts = explode(“\n”, $thoughts);

$chosen = $thoughts[mt_rand(0, count($thoughts)-1)];

print $chosen;

?>

How To Create Simple PHP Widgets

Objective:

  • Creating a simple PHP Widget, which will allow the user to reach the result page of Google! from your site.

Requirement:

Creating the form(index.htm):

<form action=“google.php” method=“get” name=“query_form”>

<input id=“search” onclick=‘value=”” ‘ name=“search” type=“text” value=“Enter the search term” />

<input id=“submit” name=“submit” type=“submit” value=“Submit” />

</form>

PHP Script(google.php):

?php
$url=”http://www.google.com/search?q=&#8221;.$_REQUEST[‘search’];//Adding the user query with the URL
header(“Location:$url”);
?>

<?PHP

$url=http://www.google.com/search?q=&#8221;.$_REQUEST[‘search’];

header(“Location:$url”);

?>

Download the full script, here

Even you can create more widgets just by changing the URLs. I’m mentioning few search URLs:

Thanks to SachinKRaj for guiding me on this script. Do post your comments 🙂