How to make an e-mail contact form on your website?
->
This is a simple form mail PHP script that displays a contact form to enable visitors to your site to send the website administrator a message via email. Built in security will prevent spammers hijacking it from another domain.
<?php /** * Change the email address to your own. * * $empty_fields_message and $thankyou_message can be changed * if you wish. */ // Change to your own email address $your_email = "you@example.com"; // This is what is displayed in the email subject line // Change it if you want $subject = "Message via your contact form"; // This is displayed if all the fields are not filled in $empty_fields_message = "<p>Please go back and complete all the fields in the form.</p>"; // This is displayed when the email has been sent $thankyou_message = "<p>Thankyou. Your message has been sent.</p>"; // You do not need to edit below this line $name = stripslashes($_POST['txtName']); $email = stripslashes($_POST['txtEmail']); $message = stripslashes($_POST['txtMessage']); if (!isset($_POST['txtName'])) { ?> <form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>"> <p><label for="txtName">Name:</label><br /> <input type="text" title="Enter your name" name="txtName" /></p> <p><label for="txtEmail">Email:</label><br /> <input type="text" title="Enter your email address" name="txtEmail" /></p> <p><label for="txtMessage">Your message:</label><br /> <textarea title="Enter your message" name="txtMessage"></textarea></p> <p><label title="Send your message"> <input type="submit" value="Send" /></label></p> </form> <?php } elseif (empty($name) || empty($email) || empty($message)) { echo $empty_fields_message; } else { // Stop the form being used from an external URL // Get the referring URL $referer = $_SERVER['HTTP_REFERER']; // Get the URL of this page $this_url = "http://".$_SERVER['HTTP_HOST'].$_SERVER["REQUEST_URI"]; // If the referring URL and the URL of this page don't match then // display a message and don't send the email. if ($referer != $this_url) { echo "You do not have permission to use this script from another URL."; exit; } // The URLs matched so send the email mail($your_email, $subject, $message, "From: $name <$email>"); // Display the thankyou message echo $thankyou_message; } ?>
The code is referenced from http://www.totallyphp.co.uk
How to make text dance on your website
Here is how you can make text dance on your website.
Put the code below within your site's source code. If you dont know how to implement this code into your site, please goto how to implement the code to your website
Code:
<!-- this script is from www.manycodes.com --> <script language="JavaScript1.2"> //configure message message="Welcome to www.javascriptfreecode.com" //animate text in NS6? (0 will turn it off) ns6switch=1 var ns6=document.getElementById&&!document.all mes=new Array(); mes[0]=-1; mes[1]=-4; mes[2]=-7;mes[3]=-10; mes[4]=-7; mes[5]=-4; mes[6]=-1; num=0; num2=0; txt=""; function jump0(){ if (ns6&&!ns6switch){ jump.innerHTML=message return } if(message.length > 6){ for(i=0; i != message.length;i++){ txt=txt+"<span style='position:relative;' id='n"+i+"'>"+message.charAt(i)+"</span>"}; jump.innerHTML=txt; txt=""; jump1a() } else{ alert("Your message is to short") } } function jump1a(){ nfinal=(document.getElementById)? document.getElementById("n0") : document.all.n0 nfinal.style.left=-num2; if(num2 != 9){ num2=num2+3; setTimeout("jump1a()",50) } else{ jump1b() } } function jump1b(){ nfinal.style.left=-num2; if(num2 != 0){num2=num2-3; setTimeout("jump1b()",50) } else{ jump2() } } function jump2(){ txt=""; for(i=0;i != message.length;i++){ if(i+num > -1 && i+num < 7){ txt=txt+"<span style='position:relative;top:"+mes[i+num]+"'>"+message.charAt(i)+"</span>" } else{txt=txt+"<span>"+message.charAt(i)+"</span>"} } jump.innerHTML=txt; txt=""; if(num != (-message.length)){ num--; setTimeout("jump2()",50)} else{num=0; setTimeout("jump0()",50)}} </script> </head> <body> <h2><div id="jumpx" style="color:green"></div></h2> <script> if (document.all||document.getElementById){ jump=(document.getElementById)? document.getElementById("jumpx") : document.all.jumpx jump0() } else document.write(message) </script> <font face="Tahoma"><a target="_blank" href="http://www.manycodes.com/category/java/javascript-codes/"><span style="font-size: 8pt; text-decoration: none">JavaScript Free Code</span></a></font>
How to make falling leaves appear in the background of your webpage
Here is how you can make the title of the your webpage scroll.
Put the code below within your site's source code. If you dont know how to implement this code into your site, please goto how to implement the code to your website
Code:
<!-- this script is from www.manycodes.com --> <script language="JavaScript1.2"> //Pre-load your image below! grphcs=new Array(6) Image0=new Image(); Image0.src=grphcs[0]="http://javascriptfreecode.com/images/barg.gif"; Image1=new Image(); Image1.src=grphcs[1]="http://javascriptfreecode.com/images/barg.gif" Image2=new Image(); Image2.src=grphcs[2]="http://javascriptfreecode.com/images/barg.gif" Image3=new Image(); Image3.src=grphcs[3]="http://javascriptfreecode.com/images/barg.gif" Image4=new Image(); Image4.src=grphcs[4]="http://javascriptfreecode.com/images/barg.gif" Image5=new Image(); Image5.src=grphcs[5]="http://javascriptfreecode.com/images/barg.gif" Amount=8; //Smoothness depends on image file size, the smaller the size the more you can use! Ypos=new Array(); Xpos=new Array(); Speed=new Array(); Step=new Array(); Cstep=new Array(); ns=(document.layers)?1:0; ns6=(document.getElementById&&!document.all)?1:0; if (ns){ for (i = 0; i < Amount; i++){ var P=Math.floor(Math.random()*grphcs.length); rndPic=grphcs[P]; document.write("<LAYER NAME='sn"+i+"' LEFT=0 TOP=0><img src="+rndPic+"></LAYER>"); } } else{ document.write('<div style="position:absolute;top:0px;left:0px"><div style="position:relative">'); for (i = 0; i < Amount; i++){ var P=Math.floor(Math.random()*grphcs.length); rndPic=grphcs[P]; document.write('<img id="si'+i+'" src="'+rndPic+'" style="position:absolute;top:0px;left:0px">'); } document.write('</div></div>'); } WinHeight=(ns||ns6)?window.innerHeight:window.document.body.clientHeight; WinWidth=(ns||ns6)?window.innerWidth-70:window.document.body.clientWidth; for (i=0; i < Amount; i++){ Ypos[i] = Math.round(Math.random()*WinHeight); Xpos[i] = Math.round(Math.random()*WinWidth); Speed[i]= Math.random()*5+3; Cstep[i]=0; Step[i]=Math.random()*0.1+0.05; } function fall(){ var WinHeight=(ns||ns6)?window.innerHeight:window.document.body.clientHeight; var WinWidth=(ns||ns6)?window.innerWidth-70:window.document.body.clientWidth; var hscrll=(ns||ns6)?window.pageYOffset:document.body.scrollTop; var wscrll=(ns||ns6)?window.pageXOffset:document.body.scrollLeft; for (i=0; i < Amount; i++){ sy = Speed[i]*Math.sin(90*Math.PI/180); sx = Speed[i]*Math.cos(Cstep[i]); Ypos[i]+=sy; Xpos[i]+=sx; if (Ypos[i] > WinHeight){ Ypos[i]=-60; Xpos[i]=Math.round(Math.random()*WinWidth); Speed[i]=Math.random()*5+3; } if (ns){ document.layers['sn'+i].left=Xpos[i]; document.layers['sn'+i].top=Ypos[i]+hscrll; } else if (ns6){ document.getElementById("si"+i).style.left=Math.min(WinWidth,Xpos[i]); document.getElementById("si"+i).style.top=Ypos[i]+hscrll; } else{ eval("document.all.si"+i).style.left=Xpos[i]; eval("document.all.si"+i).style.top=Ypos[i]+hscrll; } Cstep[i]+=Step[i]; } setTimeout('fall()',20); } window.onload=fall //--> </script> <pre><font face="Tahoma"><a target="_blank" href="http://www.manycodes.com/"><span style="font-size: 8pt; text-decoration: none">JavaScript Free Code</span></a></font></pre> </pre>
How to make snow fall on your webpage
Here is how you can make snow fall on your webpage.
Put the code below within your site's source code. If you dont know how to implement this code into your site, please goto how to implement the code to your website
Code:
<!-- this script is from www.manycodes.com --> <script> // Set the number of snowflakes (more than 30 - 40 not recommended) var snowmax=35 // Set the colors for the snow. Add as many colors as you like var snowcolor=new Array("#aaaacc","#ddddFF","#ccccDD") // Set the fonts, that create the snowflakes. Add as many fonts as you like var snowtype=new Array("Arial Black","Arial Narrow","Times","Comic Sans MS") // Set the letter that creates your snowflake (recommended:*) var snowletter="*" // Set the speed of sinking (recommended values range from 0.3 to 2) var sinkspeed=0.6 // Set the maximal-size of your snowflaxes var snowmaxsize=22 // Set the minimal-size of your snowflaxes var snowminsize=8 // Set the snowing-zone // Set 1 for all-over-snowing, set 2 for left-side-snowing // Set 3 for center-snowing, set 4 for right-side-snowing var snowingzone=3 /////////////////////////////////////////////////////////////////////////// // CONFIGURATION ENDS HERE /////////////////////////////////////////////////////////////////////////// // Do not edit below this line var snow=new Array() var marginbottom var marginright var timer var i_snow=0 var x_mv=new Array(); var crds=new Array(); var lftrght=new Array(); var browserinfos=navigator.userAgent var ie5=document.all&&document.getElementById&&!browserinfos.match(/Opera/) var ns6=document.getElementById&&!document.all var opera=browserinfos.match(/Opera/) var browserok=ie5||ns6||opera function randommaker(range) { rand=Math.floor(range*Math.random()) return rand } function initsnow() { if (ie5 || opera) { marginbottom = document.body.clientHeight marginright = document.body.clientWidth } else if (ns6) { marginbottom = window.innerHeight marginright = window.innerWidth } var snowsizerange=snowmaxsize-snowminsize for (i=0;i<=snowmax;i++) { crds[i] = 0; lftrght[i] = Math.random()*15; x_mv[i] = 0.03 + Math.random()/10; snow[i]=document.getElementById("s"+i) snow[i].style.fontFamily=snowtype[randommaker(snowtype.length)] snow[i].size=randommaker(snowsizerange)+snowminsize snow[i].style.fontSize=snow[i].size snow[i].style.color=snowcolor[randommaker(snowcolor.length)] snow[i].sink=sinkspeed*snow[i].size/5 if (snowingzone==1) {snow[i].posx=randommaker(marginright-snow[i].size)} if (snowingzone==2) {snow[i].posx=randommaker(marginright/2-snow[i].size)} if (snowingzone==3) {snow[i].posx=randommaker(marginright/2-snow[i].size)+marginright/4} if (snowingzone==4) {snow[i].posx=randommaker(marginright/2-snow[i].size)+marginright/2} snow[i].posy=randommaker(2*marginbottom-marginbottom-2*snow[i].size) snow[i].style.left=snow[i].posx snow[i].style.top=snow[i].posy } movesnow() } function movesnow() { for (i=0;i<=snowmax;i++) { crds[i] += x_mv[i]; snow[i].posy+=snow[i].sink snow[i].style.left=snow[i].posx+lftrght[i]*Math.sin(crds[i]); snow[i].style.top=snow[i].posy if (snow[i].posy>=marginbottom-2*snow[i].size || parseInt(snow[i].style.left)>(marginright-3*lftrght[i])){ if (snowingzone==1) {snow[i].posx=randommaker(marginright-snow[i].size)} if (snowingzone==2) {snow[i].posx=randommaker(marginright/2-snow[i].size)} if (snowingzone==3) {snow[i].posx=randommaker(marginright/2-snow[i].size)+marginright/4} if (snowingzone==4) {snow[i].posx=randommaker(marginright/2-snow[i].size)+marginright/2} snow[i].posy=0 } } var timer=setTimeout("movesnow()",50) } for (i=0;i<=snowmax;i++) { document.write("<span id='s"+i+"' style='position:absolute;top:-"+snowmaxsize+"'>"+snowletter+"</span>") } if (browserok) { window.onload=initsnow } </script> <font face="Tahoma"><a target="_blank" href="http://www.manycodes.com/"><span style="font-size: 8pt; text-decoration: none">JavaScript Free Code</span></a></font>
How to make the title of the your webpage scroll
Here is how you can make the title of the your webpage scroll.
Put the code below within your site's source code. If you dont know how to implement this code into your site, please goto how to implement the code to your website
Code:
<!-- this script is from www.manycodes.com --> <SCRIPT language=javascript> msg = "Krishna edyatoula is the best programmer in the world"; msg = "..." + msg;pos = 0; function scrollMSG() { document.title = msg.substring(pos, msg.length) + msg.substring(0, pos); pos++; if (pos > msg.length) pos = 0 window.setTimeout("scrollMSG()",200); } scrollMSG(); </SCRIPT> <font face="Tahoma"><a target="_blank" href="http://www.manycodes.com/"><span style="font-size: 8pt; text-decoration: none">JavaScript Free Code</span></a></font>
How to make stars moving in background of your website
Here is how you can make stars moving in background of your website. Make your website the sky and have lots and lots of stars showing on it.
Put the code below within your site's <head> </head> tags. If you dont know how to implement this code into your site, please goto how to implement the code to your website
Code:
<pre><!-- this script is from www.manycodes.com --></pre> <body> <!-- STEP ONE: Insert the onLoad event handler into your BODY tag --> <BODY BGCOLOR="#000000" onLoad="fly()"> <!-- STEP TWO: Paste this code into the BODY of your HTML document --> <SCRIPT LANGUAGE="JavaScript"> <!-- Begin SmallStars = 30; LargeStars = 10; SmallYpos = new Array(); SmallXpos = new Array(); LargeYpos = new Array(); LargeXpos = new Array(); Smallspeed= new Array(); Largespeed= new Array(); ns=(document.layers)?1:0; if (ns) { for (i = 0; i < SmallStars; i++) { document.write("<LAYER NAME='sn"+i+"' LEFT=0 TOP=0 BGCOLOR='#FFFFF0' CLIP='0,0,1,1'></LAYER>"); } for (i = 0; i < LargeStars; i++) { document.write("<LAYER NAME='ln"+i+"' LEFT=0 TOP=0 BGCOLOR='#FFFFFF' CLIP='0,0,2,2'></LAYER>"); } } else { document.write('<div style="position:absolute;top:0px;left:0px">'); document.write('<div style="position:relative">'); for (i = 0; i < SmallStars; i++) { document.write('<div id="si" style="position:absolute;top:0;left:0;width:1px;height:1px;background:#fffff0;font-size:1px"></div>'); } document.write('</div>'); document.write('</div>'); document.write('<div style="position:absolute;top:0px;left:0px">'); document.write('<div style="position:relative">'); for (i = 0; i < LargeStars; i++) { document.write('<div id="li" style="position:absolute;top:0;left:0;width:2px;height:2px;background:#ffffff;font-size:2px"></div>'); } document.write('</div>'); document.write('</div>'); } WinHeight = (document.layers)?window.innerHeight:window.document.body.clientHeight; WinWidth = (document.layers)?window.innerWidth:window.document.body.clientWidth; for (i = 0; i < SmallStars; i++) { SmallYpos[i] = Math.round(Math.random() * WinHeight); SmallXpos[i] = Math.round(Math.random() * WinWidth); Smallspeed[i]= Math.random() * 5 + 1; } for (i = 0; i < LargeStars; i++) { LargeYpos[i] = Math.round(Math.random() * WinHeight); LargeXpos[i] = Math.round(Math.random() * WinWidth); Largespeed[i] = Math.random() * 10 + 5; } function fly() { var WinHeight = (document.layers)?window.innerHeight:window.document.body.clientHeight; var WinWidth = (document.layers)?window.innerWidth:window.document.body.clientWidth; var hscrll = (document.layers)?window.pageYOffset:document.body.scrollTop; var wscrll = (document.layers)?window.pageXOffset:document.body.scrollLeft; for (i = 0; i < LargeStars; i++) { LargeXpos[i] -= Largespeed[i]; if (LargeXpos[i] < -10) { LargeXpos[i] = WinWidth; LargeYpos[i] = Math.round(Math.random() * WinHeight); Largespeed[i] = Math.random() * 10 + 5; } if (ns) { document.layers['ln'+i].left = LargeXpos[i]; document.layers['ln'+i].top = LargeYpos[i] + hscrll; } else { li[i].style.pixelLeft = LargeXpos[i]; li[i].style.pixelTop = LargeYpos[i] + hscrll; } } for (i = 0; i < SmallStars; i++) { SmallXpos[i] -= Smallspeed[i]; if (SmallXpos[i] < -10) { SmallXpos[i] = WinWidth; SmallYpos[i] = Math.round(Math.random()*WinHeight); Smallspeed[i] = Math.random() * 5 + 1; } if (ns) { document.layers['sn'+i].left = SmallXpos[i]; document.layers['sn'+i].top = SmallYpos[i]+hscrll; } else { si[i].style.pixelLeft = SmallXpos[i]; si[i].style.pixelTop = SmallYpos[i]+hscrll; } } setTimeout('fly()', 10); } // End --> </script> <!-- Script Size: 3.79 KB --> <pre><font face="Tahoma"><a target="_blank" href="http://www.manycodes.com/"><span style="font-size: 8pt; text-decoration: none">JavaScript Free Code</span></a></font></pre>
How to make hearts following the mouse pointer trail on your webpage
Here is how you can make hearts following the mouse pointer trail on your webpage. Brighten your webpage by adding this trail to the mouse pointer on your site.
Put the code below within your site's source code. If you dont know how to implement this code into your site, please goto how to implement the code to your website
Code:
<!-- this script is from www.manycodes.com --> <div id="dot0" style="position: absolute; visibility: hidden; height: 11; width: 11;"> <img src="http://www.javascriptfreecode.com/heart.gif" height=11 width=11> </div> <div id="dot1" style="position: absolute; height: 11; width: 11;"> <img src="http://www.javascriptfreecode.com/heart.gif" height=11 width=11> </div> <div id="dot2" style="position: absolute; height: 11; width: 11;"> <img src="http://www.javascriptfreecode.com/heart.gif" height=11 width=11> </div> <div id="dot3" style="position: absolute; height: 11; width: 11;"> <img src="http://www.javascriptfreecode.com/heart.gif" height=11 width=11> </div> <div id="dot4" style="position: absolute; height: 11; width: 11;"> <img src="http://www.javascriptfreecode.com/heart.gif" height=11 width=11> </div> <div id="dot5" style="position: absolute; height: 11; width: 11;"> <img src="http://www.javascriptfreecode.com/heart.gif" height=11 width=11> </div> <div id="dot6" style="position: absolute; height: 11; width: 11;"> <img src="http://www.javascriptfreecode.com/heart.gif" height=11 width=11> </div> <script LANGUAGE="JavaScript"> <!-- hide code var nDots = 7; var Xpos = 0; var Ypos = 0; // fixed time step, no relation to real time var DELTAT = .01; // size of one spring in pixels var SEGLEN = 10; // spring constant, stiffness of springs var SPRINGK = 10; // all the physics is bogus, just picked stuff to // make it look okay var MASS = 1; // Positive XGRAVITY pulls right, negative pulls left // Positive YGRAVITY pulls down, negative up var XGRAVITY = 0; var YGRAVITY = 50; // RESISTANCE determines a slowing force proportional to velocity var RESISTANCE = 10; // stopping criterea to prevent endless jittering // doesn't work when sitting on bottom since floor // doesn't push back so acceleration always as big // as gravity var STOPVEL = 0.1; var STOPACC = 0.1; var DOTSIZE = 11; // BOUNCE is percent of velocity retained when // bouncing off a wall var BOUNCE = 0.75; var isNetscape = navigator.appName=="Netscape"; // always on for now, could be played with to // let dots fall to botton, get thrown, etc. var followmouse = true; var dots = new Array(); init(); function init() { var i = 0; for (i = 0; i < nDots; i++) { dots[i] = new dot(i); } if (!isNetscape) { // I only know how to read the locations of the // <LI> items in IE //skip this for now // setInitPositions(dots) } // set their positions for (i = 0; i < nDots; i++) { dots[i].obj.left = dots[i].X; dots[i].obj.top = dots[i].Y; } if (isNetscape) { // start right away since they are positioned // at 0, 0 startanimate(); } else { // let dots sit there for a few seconds // since they're hiding on the real bullets setTimeout("startanimate()", 1000); } } function dot(i) { this.X = Xpos; this.Y = Ypos; this.dx = 0; this.dy = 0; if (isNetscape) { this.obj = eval("document.dot" + i); } else { this.obj = eval("dot" + i + ".style"); } } function startanimate() { setInterval("animate()", 20); } // This is to line up the bullets with actual LI tags on the page // Had to add -DOTSIZE to X and 2*DOTSIZE to Y for IE 5, not sure why // Still doesn't work great function setInitPositions(dots) { // initialize dot positions to be on top // of the bullets in the <ul> var startloc = document.all.tags("LI"); var i = 0; for (i = 0; i < startloc.length && i < (nDots - 1); i++) { dots[i+1].X = startloc[i].offsetLeft startloc[i].offsetParent.offsetLeft - DOTSIZE; dots[i+1].Y = startloc[i].offsetTop + startloc[i].offsetParent.offsetTop + 2*DOTSIZE; } // put 0th dot above 1st (it is hidden) dots[0].X = dots[1].X; dots[0].Y = dots[1].Y - SEGLEN; } // just save mouse position for animate() to use function MoveHandler(e) { Xpos = e.pageX; Ypos = e.pageY; return true; } // just save mouse position for animate() to use function MoveHandlerIE() { Xpos = window.event.x + document.body.scrollLeft; Ypos = window.event.y + document.body.scrollTop; } if (isNetscape) { document.captureEvents(Event.MOUSEMOVE); document.onMouseMove = MoveHandler; } else { document.onmousemove = MoveHandlerIE; } function vec(X, Y) { this.X = X; this.Y = Y; } // adds force in X and Y to spring for dot[i] on dot[j] function springForce(i, j, spring) { var dx = (dots[i].X - dots[j].X); var dy = (dots[i].Y - dots[j].Y); var len = Math.sqrt(dx*dx + dy*dy); if (len > SEGLEN) { var springF = SPRINGK * (len - SEGLEN); spring.X += (dx / len) * springF; spring.Y += (dy / len) * springF; } } function animate() { // dots[0] follows the mouse, // though no dot is drawn there var start = 0; if (followmouse) { dots[0].X = Xpos; dots[0].Y = Ypos; start = 1; } for (i = start ; i < nDots; i++ ) { var spring = new vec(0, 0); if (i > 0) { springForce(i-1, i, spring); } if (i < (nDots - 1)) { springForce(i+1, i, spring); } // air resisitance/friction var resist = new vec(-dots[i].dx * RESISTANCE, -dots[i].dy * RESISTANCE); // compute new accel, including gravity var accel = new vec((spring.X + resist.X)/MASS + XGRAVITY, (spring.Y + resist.Y)/ MASS + YGRAVITY); // compute new velocity dots[i].dx += (DELTAT * accel.X); dots[i].dy += (DELTAT * accel.Y); // stop dead so it doesn't jitter when nearly still if (Math.abs(dots[i].dx) < STOPVEL && Math.abs(dots[i].dy) < STOPVEL && Math.abs(accel.X) < STOPACC && Math.abs(accel.Y) < STOPACC) { dots[i].dx = 0; dots[i].dy = 0; } // move to new position dots[i].X += dots[i].dx; dots[i].Y += dots[i].dy; // get size of window var height, width; if (isNetscape) { height = window.innerHeight + window.pageYOffset; width = window.innerWidth + window.pageXOffset; } else { height = document.body.clientHeight + document.body.scrollTop; width = document.body.clientWidth + document.body.scrollLeft; } // bounce off 3 walls (leave ceiling open) if (dots[i].Y >= height - DOTSIZE - 1) { if (dots[i].dy > 0) { dots[i].dy = BOUNCE * -dots[i].dy; } dots[i].Y = height - DOTSIZE - 1; } if (dots[i].X >= width - DOTSIZE) { if (dots[i].dx > 0) { dots[i].dx = BOUNCE * -dots[i].dx; } dots[i].X = width - DOTSIZE - 1; } if (dots[i].X < 0) { if (dots[i].dx < 0) { dots[i].dx = BOUNCE * -dots[i].dx; } dots[i].X = 0; } // move img to new position dots[i].obj.left = dots[i].X; dots[i].obj.top = dots[i].Y; } } // end code hiding --> </script> <font face="Tahoma"><a target="_blank" href="http://www.manycodes.com/"><span style="font-size: 8pt; text-decoration: none">JavaScript Free Code</span></a></font>
Make a USB Boot CD for Ubuntu 9.04
The following tutorial explains how to create a USB Boot CD that can be used to boot a Ubuntu 9.04 USB flash drive on computers with a BIOS that does not natively support booting from USB. The boot CD contains a grub bootloader that loads the initrd and vmlinuz kernel from the CD and then proceeds to locate the filesystem on the USB drive. Because the USB driver modules are preloaded from the initrd on the CD, the compressed filesystem can then be detected and loaded from the USB device.
USB Boot CD for Ubuntu 9.04 creation essentials
- PC with a BIOS that does not support booting from USB
- Working CD Drive and USB Port
- Ubuntu 9.04 Live CD
- USB flash drive with Ubuntu 9.04 preinstalled
- Insert the Ubuntu 9.04 Live CD and restart your computer, booting from the CD
- Open a Terminal and Type mkdir -p ubcd/boot/grub
- Type cp /usr/lib/grub/i386-pc/stage2_eltorito ubcd/boot/grub
- Type gedit ubcd/boot/grub/menu.lst
Add the following information to your menu.lst file and click save:title Run Ubuntu 9.04 from USB DISK
root (cd)
kernel /boot/vmlinuz file=/cdrom/preseed/ubuntu.seed boot=casper noprompt cdrom-detect/try-usb=true persistent
initrd /boot/initrd.gz
boot - Type cp /cdrom/casper/initrd.gz ~/ubcd/boot
- Type cp /cdrom/casper/vmlinuz ~/ubcd/boot
- Type sudo gedit /etc/initramfs-tools/modules
Add the following lines to the modules file and click save:usbcore usb-storage uhci_hcd ohci_hcd ehci_hcd sd_mod scsi_mod
- Type sudo gedit /etc/initramfs-tools/initramfs.conf
Add the following line to the bottom of the file and click save:WAIT=8
- Type sudo mkinitramfs -o ubcd/boot/initrd.gz 2.6.2*
- Type mkisofs -R -b boot/grub/stage2_eltorito -no-emul-boot -boot-load-size 4 -boot-info-table -o usbcd.iso ubcd
- Burn the usbcd.iso to a CD
Replacing 2.6.2* with your actual kernel version.
Type uname -r to find your kernel version. I.E. initrd.gz 2.6.28-11-generic