Wednesday, May 8, 2013

Floating Division ( Table ) Php Script

 Floating Menu script


Simply insert the below code to the END of your document, right above the </BODY> tag.


<script>
if (!document.layers)
document.write('<div id="divStayTopLeft" style="position:absolute">')
</script>

<layer id="divStayTopLeft">

<!--EDIT BELOW CODE TO YOUR OWN MENU-->
<table border="1" width="130" cellspacing="0" cellpadding="0">
  <tr>
    <td width="100%" bgcolor="#FFFFCC">
      <p align="center"><b><font size="4">Menu</font></b></td>
  </tr>
  <tr>
    <td width="100%" bgcolor="#FFFFFF">
      <p align="left"> <a href="http://www.dinamalar.com"> Dinamalar </a><br>
       <a href="http://www.google.co.in">Google</a><br>
       <a href="http://www.yahoo.com">Yahoo </a><br>
       <a href="#">FAQs</a><br>
       <a href="#">More Zone</a></td>
  </tr>
</table>
<!--END OF EDIT-->

</layer>


<script type="text/javascript">


//Enter "frombottom" or "fromtop"
var verticalpos="frombottom"

if (!document.layers)
document.write('</div>')

function JSFX_FloatTopDiv()
{
    var startX = 3,
    startY = 150;
    var ns = (navigator.appName.indexOf("Netscape") != -1);
    var d = document;
    function ml(id)
    {
        var el=d.getElementById?d.getElementById(id):d.all?d.all[id]:d.layers[id];
        if(d.layers)el.style=el;
        el.sP=function(x,y){this.style.left=x;this.style.top=y;};
        el.x = startX;
        if (verticalpos=="fromtop")
        el.y = startY;
        else{
        el.y = ns ? pageYOffset + innerHeight : document.body.scrollTop + document.body.clientHeight;
        el.y -= startY;
        }
        return el;
    }
    window.stayTopLeft=function()
    {
        if (verticalpos=="fromtop"){
        var pY = ns ? pageYOffset : document.body.scrollTop;
        ftlObj.y += (pY + startY - ftlObj.y)/8;
        }
        else{
        var pY = ns ? pageYOffset + innerHeight : document.body.scrollTop + document.body.clientHeight;
        ftlObj.y += (pY - startY - ftlObj.y)/8;
        }
        ftlObj.sP(ftlObj.x, ftlObj.y);
        setTimeout("stayTopLeft()", 10);
    }
    ftlObj = ml("divStayTopLeft");
    stayTopLeft();
}
JSFX_FloatTopDiv();
</script>

Wednesday, April 24, 2013

PHP mail Function

The PHP mail() Function

The PHP mail() function is used to send emails from inside a script.
Syntax
mail(to,subject,message,headers,parameters)

Parameter Description
to Required. Specifies the receiver / receivers of the email
subject Required. Specifies the subject of the email. Note: This parameter cannot contain any newline characters
message Required. Defines the message to be sent. Each line should be separated with a LF (\n). Lines should not exceed 70 characters
headers Optional. Specifies additional headers, like From, Cc, and Bcc. The additional headers should be separated with a CRLF (\r\n)
parameters Optional. Specifies an additional parameter to the sendmail program
Note: For the mail functions to be available, PHP requires an installed and working email system. The program to be used is defined by the configuration settings in the php.ini file. Read more in our PHP Mail reference.

PHP Simple E-Mail

The simplest way to send an email with PHP is to send a text email.
In the example below we first declare the variables ($to, $subject, $message, $from, $headers), then we use the variables in the mail() function to send an e-mail:
<?php
$to = "someone@example.com";
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = "someonelse@example.com";
$headers = "From:" . $from;
mail($to,$subject,$message,$headers);
echo "Mail Sent.";
?>


PHP Mail Form

With PHP, you can create a feedback-form on your website. The example below sends a text message to a specified e-mail address:
<html>
<body>

<?php
if (isset($_REQUEST['email']))
//if "email" is filled out, send email
  {
  //send email
  $email = $_REQUEST['email'] ;
  $subject = $_REQUEST['subject'] ;
  $message = $_REQUEST['message'] ;
  mail("someone@example.com", $subject,
  $message, "From:" . $email);
  echo "Thank you for using our mail form";
  }
else
//if "email" is not filled out, display the form
  {
  echo "<form method='post' action='mailform.php'>
  Email: <input name='email' type='text'><br>
  Subject: <input name='subject' type='text'><br>
  Message:<br>
  <textarea name='message' rows='15' cols='40'>
  </textarea><br>
  <input type='submit'>
  </form>";
  }
?>

</body>
</html>

This is how the example above works:
  • First, check if the email input field is filled out
  • If it is not set (like when the page is first visited); output the HTML form
  • If it is set (after the form is filled out); send the email from the form
  • When submit is pressed after the form is filled out, the page reloads, sees that the email input is set, and sends the email
Note: This is the simplest way to send e-mail, but it is not secure. In the next chapter of this tutorial you can read more about vulnerabilities in e-mail scripts, and how to validate user input to make it more secure.

Thursday, April 11, 2013

PHP script for SMS sending

<?
/*
 Simple and easy for modification, PHP script for SMS sending through HTTP with you own Sender ID and delivery reports.
 You just have to type your account information on www.2-waysms.com and upload file on server.
*/
?>


<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>SMSER</title>
<style type="text/css">
body{
    font-family:"Lucida Grande", "Lucida Sans Unicode", Verdana, Arial, Helvetica, sans-serif;
    font-size:12px;
}
p, h1, form, button{border:0; margin:0; padding:0;}
.spacer{clear:both; height:1px;}
/* ----------- My Form ----------- */
.myform{
    margin:0 auto;
    width:300px;
    padding:14px;
}
/* ----------- stylized ----------- */
    #stylized{
        border:solid 2px #b7ddf2;
        background:#ebf4fb;
    }
    #stylized h1 {
        font-size:14px;
        font-weight:bold;
        margin-bottom:8px;
    }
    #stylized p{
        font-size:11px;
        color:#666666;
        margin-bottom:20px;
        border-bottom:solid 1px #b7ddf2;
        padding-bottom:10px;
   
}
    </style>
</head>

<body>

<?

    switch ($option) {

    case sendsms:
        if ($text == "") { echo "Error!<br>Text not entered<br><a href=\"javascript:history.back(-1)\">Go Back</a>"; die; } else { }
        if ($to == "") { echo "Error!<br>Number not entered<br><a href=\"javascript:history.back(-1)\">Go Back</a>"; die; } else { }

        $url = "http://www.2-waysms.com/sms.php";
        $postfields = array ("text" => "$text", // do not need to change
        "to" => "$to", // do not need to change
        "id" => "*****", // you ID in www.2-waysms.com accout
        "sec" => "****************************"); // your secret code in www.2-waysms.com account
        if (!$curld = curl_init()) {
        echo "Could not initialize cURL session.";
        exit;
        }
        curl_setopt($curld, CURLOPT_POST, true);
        curl_setopt($curld, CURLOPT_POSTFIELDS, $postfields);
        curl_setopt($curld, CURLOPT_URL, $url);
        curl_setopt($curld, CURLOPT_RETURNTRANSFER, true);
        $output = curl_exec($curld);
        curl_close ($curld);
        $out = explode('|',$output);

        echo "Message Status: $out[1]";

        //Header("Location: $PHP_SELF");
    break;

    default:

    echo "<div id=\"stylized\" class=\"myform\">"
       ."<h1>Send Sms</h1>"
       ."<form method=post action=\"$PHP_SELF?option=sendsms\">"
       ."<table border=\"0\">"
       ."<tr>"
         ."<td>Number</td>"
         ."<td><input type=\"text\" name=\"to\"></td>"
       ."</tr>"
       ."<tr>"
         ."<td>Message</td>"
         ."<td><textarea rows=\"4\" cols=\"25\" name=\"text\"></textarea></td>"
       ."</tr>"
       ."<tr>"
         ."<td>&nbsp;</td>"
         ."<td><input type=submit name=submit value=Send>"
         ."<div class=\"spacer\"></div></td>"
       ."</tr>"
       ."</table>"
       ."</form>"
    ."</div>";


    }

?>

</body>
</html>

Thursday, April 4, 2013

Calculate No Of Days Excluding Weekends

   Calculate No Of Days Excluding Weekends  

Count the number of days between two dates that exclude weekends as non work days


Count the no.Of Days between to days Excluding Sunday



$start = strtotime('2013-04-01');
$end = strtotime('2013-04-7');

while ($start <= $end) {
    if (date('N', $start) <= 6) {
     $days++;    }
    
    $start += 86400;
}
echo $days;



Count the no.Of Days between to days Excluding Sunday and Saturday


$start = strtotime('2013-04-01');
$end = strtotime('2013-04-7');

while ($start <= $end) {
    if (date('N', $start) <= 5) {
     $days++;    }
    
    $start += 86400;
}
echo $days;



Saturday, March 30, 2013

Php Cookies

How to Create a Cookie?

Syntax

setcookie(name, value, expire, path, domain); 

Examples

In the example below, we will create a cookie named "user" and assign the value "Alex Porter" to it. We also specify that the cookie should expire after one hour:

<?php
setcookie("user", "Alex Porter", time()+3600);
?>

<html>
.....  


You can also set the expiration time of the cookie in another way. It may be easier than using seconds.

<?php
$expire=time()+60*60*24*30;
setcookie("user", "Alex Porter", $expire);
?>

<html>
..... 


In the example above the expiration time is set to a month (60 sec * 60 min * 24 hours * 30 days).

________________________________________________________

How to Retrieve a Cookie Value?

 The PHP $_COOKIE variable is used to retrieve a cookie value.

<?php
// Print a cookie
echo $_COOKIE["user"];

// A way to view all cookies
print_r($_COOKIE);
?>  

___________________________
<html>
<body>

<?php
if (isset($_COOKIE["user"]))
  echo "Welcome " . $_COOKIE["user"] . "!<br>";
else
  echo "Welcome guest!<br>";
?>

</body>
</html> 

 ______________________________________________

How to Delete a Cookie?

 <?php
// set the expiration date to one hour ago
setcookie("user", "", time()-3600);
?> 

 

Friday, March 22, 2013

MySQL count matching words

 MySQL count matching words

Count No.Of Words in String - Mysql Syntax

If you only need to search for one term at a time, a function which does something like

select (len(field)-len(replace,find,''))/len(find)
 
 
would work in sql server, but I'm not sure about MySQL. You'd 
also need to take care of the special case len(find) = 0 

Thursday, March 21, 2013

PHP Functions

The real power of PHP comes from its functions.
In PHP, there are more than 700 built-in functions.

PHP Built-in Functions

For a complete reference and examples of the built-in functions, please visit our PHP Reference.

PHP Functions

In this chapter we will show you how to create your own functions.
To keep the script from being executed when the page loads, you can put it into a function.
A function will be executed by a call to the function.
You may call a function from anywhere within a page.

Create a PHP Function

A function will be executed by a call to the function.

Syntax

function functionName()
{
code to be executed;
}
PHP function guidelines:
  • Give the function a name that reflects what the function does
  • The function name can start with a letter or underscore (not a number)

Example

A simple function that writes my name when it is called:
<html>
<body>

<?php
function writeName()
{
echo "Kai Jim Refsnes";
}

echo "My name is ";
writeName();
?>

</body>
</html>
Output:
My name is Kai Jim Refsnes


PHP Functions - Adding parameters

To add more functionality to a function, we can add parameters. A parameter is just like a variable.
Parameters are specified after the function name, inside the parentheses.

Example 1

The following example will write different first names, but equal last name:
<html>
<body>

<?php
function writeName($fname)
{
echo $fname . " Refsnes.<br>";
}

echo "My name is ";
writeName("Kai Jim");
echo "My sister's name is ";
writeName("Hege");
echo "My brother's name is ";
writeName("Stale");
?>

</body>
</html>
Output:
My name is Kai Jim Refsnes.
My sister's name is Hege Refsnes.
My brother's name is Stale Refsnes.

Example 2

The following function has two parameters:
<html>
<body>

<?php
function writeName($fname,$punctuation)
{
echo $fname . " Refsnes" . $punctuation . "<br>";
}

echo "My name is ";
writeName("Kai Jim",".");
echo "My sister's name is ";
writeName("Hege","!");
echo "My brother's name is ";
writeName("Ståle","?");
?>

</body>
</html>
Output:
My name is Kai Jim Refsnes.
My sister's name is Hege Refsnes!
My brother's name is Ståle Refsnes?


PHP Functions - Return values

To let a function return a value, use the return statement.

Example

<html>
<body>

<?php
function add($x,$y)
{
$total=$x+$y;
return $total;
}

echo "1 + 16 = " . add(1,16);
?>

</body>
</html>
Output:
1 + 16 = 17

Labels

AJAX (1) Answers (1) Apache (1) Array (16) bug (1) C (1) C++ (1) Calendar (1) Class (1) Commands (1) Cookies (2) Database (2) Date (7) Days (1) explode (1) File Upload (1) FILES (1) firewall (1) fix (1) Functions (26) GET (1) GMT (1) JavaScript (2) localhost (1) Mail (1) Menu (1) MYSQL (13) PERL (1) PHP (36) php.ini (1) POST (1) preg_match (1) Questions (1) Script (1) SMS (2) Solution (1) String (1) Time (5) Time Zone (1) Vista (1) Wamp Server (1) windows 7 (2) XML (1)

Popular Posts

Popular Posts