Skip to main content

Posts

Showing posts from September, 2011

Google map examples

These are 2 examples of integrating a google map on your page, using the latitude and longitude values.... First you need to register your site with google maps for a key. Example: 1 <html xmlns="http://www.w3.org/1999/xhtml">     <head>     <script src="http://maps.google.com/maps?file=api&v=1&key=ABQIAAAAYrPUQCb3Z6rFxSM-d0oOeBT2cMPdVrZpW5swiJunby9DzOBHxxSXFUXo_NM6mbf1GK95Z4irMylR4A" type="text/javascript"></script>     </head>     <body>     <div id="map" style="width: 400px; height: 300px"></div>         <script type="text/javascript">     var map = new GMap(document.getElementById("map"));     map.centerAndZoom(new GPoint(-83.022206, 39.998264), 3);     </script>     </body>     </html> Example: 2 <html xmlns="http://www.w3.org/1999/xhtml">     <head>     <script src="http://maps.

Javascript email and phone validation example

Email validation: var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/; var email = document.myform.email.value; if(reg.test(email) == false) { alert("Invalid email"); return false; } Phone number validation: var telnoRegxp = /^([0-9]+)$/; var phone = document.myform.phone.value; if (telnoRegxp.test(phone) != true) { alert("Invalid phone no"); return false; }

Swift mailer example php

It is common to use an smtp library to send emails in php. One such popular library is Swift mailer. It also facilitates the usage of gmail smtp settings, and attachments. Just download the library and try this sample code. <?php require_once 'lib/swift_required.php'; // Using smtp $transport = Swift_SmtpTransport::newInstance('my_smtp_host.com', 25) // Using Gmail // $transport = Swift_SmtpTransport::newInstance('smtp.gmail.com', 465, "ssl")   ->setUsername('my_smtp_username') // or your gmail username   ->setPassword('my_smtp_password'); // or your gmail password $mailer = Swift_Mailer::newInstance($transport); $message = Swift_Message::newInstance('Wonderful Subject')   ->setFrom(array('johndoe@gmail.com' => 'John Doe'))   ->setTo(array('dskanth.99@gmail.com'))   ->attach(Swift_Attachment::fromPath('doc.pdf'))   ->setBody('Here is the message itself

Embed a jwplayer video in a page

Example1:  <object type="application/x-shockwave-flash" style="width: 450px; height: 350px;" data="http://www.example.com/plugins/hwdvs-videoplayer/jwflv/mediaplayer.swf">         <param name="movie" value="http://www.example.com/plugins/hwdvs-videoplayer/jwflv/mediaplayer.swf">         <param name="quality" value="high">         <param name="wmode" value="transparent">         <param name="bgcolor" value="">         <param name="autoplay" value="true">         <param name="allowfullscreen" value="true">         <param name="allowscriptaccess" value="always">         <param name="flashvars" value="file=http://www.example.com/hwdvideos/uploads/d8wxa5cf8sagkn.flv&amp;image=http://www.example.com/hwdvideos/thumbs/dual.jpg&amp;autostart=tru