Get IP address of the visitor , PHP Script get ip funtion in (PHP) function getIP() { if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; else if (isset($_SERVER['REMOTE_ADDR'])) $ip = $_SERVER['REMOTE_ADDR']; else $ip = "UNKNOWN"; return $ip; } This will show the IP address of the visitor the simple way: < ?php echo $_SERVER['REMOTE_ADDR']; ?> PHP: *iTrade me if u appreciate this!!
This tutorial will explain how to simply randomly rotate multiple banners. Here is all the code you need. <?php $ads = array(); $ads[] = '<a href="http://www.php.net"><img src="banner2.gif" alt="PHP and MySQL" /></a>'; $ads[] = '<a href="http://crazy-coderz.net"><img src="banner1.gif" alt="Crazy-Coderz" /></a>'; shuffle($ads); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>BrendenWilson.com</title> <style type="text/css"> img { border:none;} </style> </head> <body style="text-align:center;"> <?php echo $ads[0]; ?> </body> </html> PHP: Code Explanation The first line of code sets up the variable $ads to be an arrary. An arrary is basically a set of values and keys associated with the values. For more information Google, “php arrayâ€. The third and forth line of code add the HTML image code for the banner. In this example there are just two banner being randomly rotated, but you could easily add more. Line five randomly shuffles the array. Two values are added to the array on line three and four. The ray is then shuffled so the information in the array is randomized. In the body section of the HTML, (line 21), the 1st value stored in the array is echoed out. $ads[0] is the first value in the array, $ads[1] is the second value and so on. Each time you refresh the page, the first value of the array will be randomized. Refresh the page several times to make sure the image is rotated through.
As many of you have seen you can send emails using php but a lot of people dont know how, so i have created a tutorials on how to . <? if($_POST[submit]){ // Checks to see if the form has been submitted or not $to = "YOUREMAIL@YOURSITE.COM"; // Your Email Address $subject = $_POST['subject']; // Gets the fields from the form $message = $_POST['message']; if($subject==NULL|$message==NULL) { // Checks to see if the fields are left blank and if so it display the message die("Sorry, but one of the fields was left blank. Please Return To The Form"); } $mailsend = mail($to,$subject,$message); // Puts the information into order and then sends it { header("Location: ?message=Thank you"); // Redirects the page back to contact.php and then displays a message } } ?><form method="POST" action="submit.php"> <p><label for="fp2">Subject:<br> </label> <input type="text" name="subject" size="20" id="fp2"><br> <label for="fp1">Message:<br> </label> <textarea rows="6" name="message" cols="16" id="fp1"></textarea><br> <input type="submit" value="Submit" name="submit"><input type="reset" value="Reset" name="B2"></p> </form> <? echo $message ?> PHP: iTrade are appreciate!!!
<?PHP $from_name = "Mr. Anonymous"; $from_email = "mr.anonymous@sender-domain.com"; $to_email = "zahid@somedomain.com"; $subject = "Mail Subject"; $message = "Your text goes here...."; $headers = "From: ".$from_name." <".$from_email.">\r\n"; $headers .= "Reply-To: ".$from_email."\r\n"; mail($to_email, $subject, $message, $headers, "-f".$from_email); echo "Mail Sent!"; ?> PHP:
Learn how to output the time a page takes to load. Have you ever noticed that lots of websites feature a little "Page loading took x.xxx seconds to load" at the bottom of their pages? It's a pretty simple thing to make and gives your site something that we all love... Stats! Here is what we have to do: 1. Get the time in micro-seconds using the function: microtime(). 2. Turn the micro-time into an array using the explode() function. 3. Add the two parts to the array together (the micro-seconds to the seconds). 4. Repeat steps 1,2 and 3 for the bottom of the page 5. Find the total loading time by taking the time taken at the end of the page from the time taken at the top of the page 6. Round the microtime and return it to the browser Here is the code: - Put at the top of your page: <? $m_time = explode(" ",microtime()); $m_time = $m_time[0] + $m_time[1]; $starttime = $m_time; ?> PHP: Put at the bottom of your page. <? $round = 3;// The number of decimal places to round the micro time to. $m_time = explode(" ",microtime()); $m_time = $m_time[0] + $m_time[1]; $endtime = $m_time; $totaltime = ($endtime - $starttime); echo "Page loading took:". round($totaltime,$round) ." seconds"; ?> PHP: Enjoy!!! iTrade are giveness to me
The only problem with using the "simple" version of the IP grabber, is that it will not look through Proxies, and other things. The "full" version of it will try to get the IP in pretty much every way before it stops, meaning that you will have a better chance of seeing through transparent proxies and such. Summed up: It's better to use the full getIP script rather than the simple REMOTE_ADDR method.
Ok, so, basically a switch is to make all the pages load faster... its kind of like an iframe in that instead of reloading the whole layout, it only loads a section. That section is usually content like news or a list of files to download. Also switches make the address ?x=page, get it? Here is an example: To start off, add this in the place where you want your content to be: <?php switch ($HTTP_GET_VARS[x]) { default: include "http://www.yoursite.com/newspath/news.php"; break; case 'files': include 'yourpath/downloads.php'; break; case 'gallery': include 'gallery.php'; break; case'about': include 'about.php'; break; } ?> Code (markup): Now then, lets break it down: case will be what it says as the location, so, ?x=about include is the page that its including (obviously) break; is saying that you're finished with that line Now then, after you add that you'll need to add links, right? Right! <a href="?x=index">Home</a><br> <a href="?x=files">Files</a><br> <a href="?x=about">About</a><br> <a href="?x=gallery">Gallery</a><br> Code (markup): So you see that instead of making the link to another page its linking to the switch within your content, that way instead of loading the entire layout you can just make another page that is the bare bones. <html> <head> <title>Yoursite.com</title> <link href="css.css" style="text/css" rel="stylesheet"> </head> <body> <div align="center"> <? include("http://yoursite.com/affiliatespath/showthem.php"); ?> </div> </body> </html> Code (markup): That would be the affiliates in the content portion, and it loads that small section which really cuts down on loading time!
<!-- Step1: Alter the style sheet and script and paste in head --> <!-- Step2: Use this as your body tag - <body onLoad="setTimeout('AutoCycle()',3000)"> --> <!-- Step3: Alter the table dimensions for your pics and paste into the body, for precise placement etc, put it into another table --> <style type="text/css"> <!-- .text{font-family:Verdana;font-size:18px;color:#fffff0} #x a:link{font-family:Verdana;font-size:18px;color:#fffff0;text-decoration:none} #y a:visited{font-family:Verdana;font-size:18px;color:#fffff0;text-decoration:none} #z a:hover{font-family:Verdana;font-size:18px;color:#00ff00;text-decoration:none} //--> </style> <script language="JavaScript"> intro=new Image(); intro.src='ntro.gif'; //The initial image here, shown once only! pics=new Array('ap.gif','bp.gif','cp.gif') //Put your images below - as many as needed! speed=2000; //Slideshow speed - 1000 = 1 second etc! //nothing needs altering below here. load=new Array(); for(i=0; i < pics.length; i++) { load[i]=new Image(); load[i].src=pics[i]; } ns=(document.layers); n6=(document.getElementById&&!document.all); ie=(document.all); count=-1; move=1; chck=null; timer=null; vvv='0'; function Picnum(){ var d=(ns||ie)?'document.':'document.getElementById("'; var a=(ns||n6)?'':'all.'; var n6r=(n6)?'")':''; var p=eval(d+a+'Nums'+n6r); if (ie||n6) p.innerHTML='Picture '+count; if (ns){ p.document.write("<div style='position:absolute;top:0px;left:0px;font-family:Verdana;font-size:18px;color:#fffff0;text-align:center'>Picture "+count+"</div>"); p.document.close(); } } function ManualForward(){ if (chck==1){ count+=move if (count >= pics.length) count=0; document.images.slides.src=pics[count]; Picnum(); } } function ManualReverse(){ if (chck==1){ count-=move if (count < 0) count=pics.length-1; document.images.slides.src=pics[count]; Picnum(); } } function Pause(){ chck=1; count=count; clearTimeout(timer) Picnum(); } function AutoCycle(){ count+=move if (count >= pics.length) count=0; document.images.slides.src=pics[count]; Picnum(); timer=setTimeout('AutoCycle()',speed) } function Cycle(){ if (chck==1) AutoCycle(); chck=null; } //--> </script> <!-- The table - Keep all images the same size to stop movement! --> <center> <table width="250" border="0" cellpadding="0" cellspacing="4"> <tr> <td valign="middle" align="center" bgcolor="#c0c0c0"> <span class="text" style="position:relative">Slide Show</span> <br> <span id="Nums" class="text" style="position:relative"> </span> </td> </tr> <tr> <td height="250" valign="middle" align="center"> <img src="intro.gif" name="slides"> </td> </tr> <tr> <td height="40" valign="middle" align="center" bgcolor="#c0c0c0"> <span id="x"><span id="y"><span id="z"> <a href="javascript:ManualReverse()"> << </a> <a href="javascript:Pause()">Pause</a> <a href="javascript:ManualForward()"> >> </a> <a href="javascript:Cycle()">Auto</a> </span></span></span> </td> </tr> </table> </center> PHP:
1. Copy the coding into the BODY of your HTML document <body background="pic.gif"> <script language="JavaScript"> <!-- Begin var backgroundOffset = 0; var bgObject = eval('document.body'); function scrollBG(maxSize) { backgroundOffset = backgroundOffset + 1; if (backgroundOffset > maxSize) backgroundOffset = 0; bgObject.style.backgroundPosition = "0 " + backgroundOffset; } var ScrollTimer = window.setInterval("scrollBG(307)", 64); // End --> </script> PHP: