Home

Friday, January 27, 2012

Holding the mouse over this marquee stops it from scrolling.

<marquee title="Holding your cursor over this stops the marquee."
            ONMOUSEOVER="this.stop();"
            ONMOUSEOUT="this.start();">
         <H3>Test Marquee</H3>
         <P>Holding the mouse over this marquee stops it from scrolling.</P>
</MARQUEE>

Monday, January 23, 2012

Delete Records with using jQuery and Ajax.

Index.php
<ol class="update">
<?php
$sql="select * from updates order by msg_id desc";
$result = mysql_query($sql);
while($row=mysql_fetch_array($result))
{
$message=stripslashes($row["message"]);
$msg_id=$row["msg_id"]; 
?>
<li>
<?php echo $message; ?>
<a href="#" id="<?php echo $msg_id; ?>" class="delete_button">X</a>
</li>
<?php
}
?>
</ol>
 
jQuery code
 
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$(function() {
$(".delete_button").click(function() {
var id = $(this).attr("id");
var dataString = 'id='+ id ;
var parent = $(this).parent();

$.ajax({
type: "POST",
url: "deleteajax.php",
data: dataString,
cache: false,

success: function()
{
if(id % 2)
{
parent.fadeOut('slow', function() {$(this).remove();});
}
else
{
parent.slideUp('slow', function() {$(this).remove();});
}
}
});

return false;
});
});
</script>
 
deleteajax.php
<?php
if($_POST['id'])
{
$id=$_POST['id'];
$id = mysql_escape_String($id);
$sql = "delete from updates where msg_id='$id'";
mysql_query( $sql);
}
?>
 
 

Delete Records with Effect using jQuery and Ajax in php

Index.php
<ol class="update">
<?php
$sql="select * from updates order by msg_id desc";
$result = mysql_query($sql);
while($row=mysql_fetch_array($result))
{
$message=stripslashes($row["message"]);
$msg_id=$row["msg_id"]; 
?>
<li>
<?php echo $message; ?>
<a href="#" id="<?php echo $msg_id; ?>" class="delete_button">X</a>
</li>
<?php
}
?>
</ol>
jQuery code
<script type="text/javascript" src="http://ajax.googleapis.com/
ajax/libs/jquery/1.4.2/jquery.min.js
"></script>
<script type="text/javascript" src="jquery.color.js"></script>
<script type="text/javascript">
$(function() {
$(".delete_button").click(function() {
var id = $(this).attr("id");
var dataString = 'id='+ id ;
var parent = $(this).parent();

$.ajax({
type: "POST",
url: "deleteajax.php",
data: dataString,
cache: false,
beforeSend: function()
{
parent.animate({'backgroundColor':'#fb6c6c'},300).animate({ opacity: 0.35 }, "slow");;
},
success: function()
{
parent.slideUp('slow', function() {$(this).remove();});
}
});

return false;
});
});
</script>
deleteajax.php
<?php
if($_POST['id'])
{
$id=$_POST['id'];
$id = mysql_escape_String($id);
$sql = "delete from updates where msg_id='$id'";
mysql_query( $sql);
}
?>
 

Saturday, January 21, 2012

Example of a SQL Injection Attack.

The easiest way for the login.php to work is by building a database query that looks like this:

SELECT id
FROM logins
WHERE username = '$username'
AND password = '$password’



If the variables $username and $password are requested directly from the user's input, this can easily be compromised. Suppose that we gave "Joe" as a username and that the following string was provided as a password: anything' OR 'x'='x


SELECT id
FROM logins
WHERE username = 'Joe'
AND password = 'anything' OR 'x'='x'



As the inputs of the web application are not properly sanitised, the use of the single quotes has turned the WHERE SQL command into a two-component clause.

The 'x'='x' part guarantees to be true regardless of what the first part contains.

This will allow the attacker to bypass the login form without actually knowing a valid username / password combination!

To stop this kind of attack, you MUST use some inbuilt PHP functions. The one to use for this kind of attack is:
mysql_real_escape_string( );

$username = mysql_real_escape_string($username);
$password = mysql_real_escape_string($password);

Tuesday, January 17, 2012

How to convert time according to timezone in php

///Your time zone mention here
$myDateTime = new DateTime('2012-01-12 11:23', new DateTimeZone('Asia/Kolkata'));

///Want to desire time
$myDateTime->setTimezone(new DateTimeZone('Australia/Sydney'));

/* Like another Example */
//$myDateTime->setTimezone(new DateTimeZone('Asia/Baku'));
//$myDateTime->setTimezone(new DateTimeZone('Europe/London'));


echo $myDateTime->format('Y-m-d h:i');?>


Monday, January 16, 2012

Create a CSV file from MySQL with PHP

mysql_connect($server, $login, $password);
mysql_select_db($db);

$fp = fopen("test.csv", "w");

$res = mysql_query("SELECT * FROM $table");

// fetch a row and write the column names out to the file
$row = mysql_fetch_assoc($res);
$line = "";
$comma = "";
foreach($row as $name => $value) {
    $line .= $comma . '"' . str_replace('"', '""', $name) . '"';
    $comma = ",";
}
$line .= "\n";
fputs($fp, $line);

// remove the result pointer back to the start
mysql_data_seek($res, 0);

// and loop through the actual data
while($row = mysql_fetch_assoc($res)) {
   
    $line = "";
    $comma = "";
    foreach($row as $value) {
        $line .= $comma . '"' . str_replace('"', '""', $value) . '"';
        $comma = ",";
    }
    $line .= "\n";
    fputs($fp, $line);
   
}

fclose($fp);

Friday, January 13, 2012

How i get the current system time using php?

<?php
$time_now=mktime(date('h')+5,date('i')+30,date('s'));
print "<br>".date('h:i:s',$time_now);
?>

Tuesday, January 10, 2012

How to show and hide div tag using css

<style type="text/css" media="screen">
  
  #slideout {
   position: fixed;
   top: 40px;
   left: 0;
   width: 35px;
   padding: 12px 0;
   text-align: center;
   background: #6DAD53;
   -webkit-transition-duration: 0.3s;
   -moz-transition-duration: 0.3s;
   -o-transition-duration: 0.3s;
   transition-duration: 0.3s;
   -webkit-border-radius: 0 5px 5px 0;
   -moz-border-radius: 0 5px 5px 0;
   border-radius: 0 5px 5px 0;
  }
  #slideout_inner {
   position: fixed;
   top: 40px;
   left: -250px;
   background: #6DAD53;
   width: 200px;
   padding: 25px;
   height: 130px;
   -webkit-transition-duration: 0.3s;
   -moz-transition-duration: 0.3s;
   -o-transition-duration: 0.3s;
   transition-duration: 0.3s;
   text-align: left;
   -webkit-border-radius: 0 0 5px 0;
   -moz-border-radius: 0 0 5px 0;
   border-radius: 0 0 5px 0;
  }
  #slideout_inner textarea {
   width: 190px;
   height: 100px;
   margin-bottom: 6px;
  }
  #slideout:hover {
   left: 250px;
  }
  #slideout:hover #slideout_inner {
   left: 0;
  }
  
 </style>
 
<div id="slideout">
  <img src="image.jpg" alt="Feedback" />
  <div id="slideout_inner">
   <form>
    <textarea></textarea>
    <input type="submit" value="Post feedback"></input>
   </form>
  </div>
 </div> 

How to show and hide div tag using Jquery

<script type="text/javascript">//<![CDATA[
$(window).load(function(){
//$('#song_click').mouseover(function()
$('#song_click').click(function()
{
    $("#song_panel").animate({width:'toggle'},500);      
});
});//]]>
</script>
<div style="display: none;" id="song_panel">
   Test
</div>
<div id="song_click"></div>

Friday, January 6, 2012

Audio Flash Player script With PHP and Mysql

<?php
mysql_connect("localhost","root","");
mysql_select_db("songs");

$sql = "SELECT * FROM play";
$rs = mysql_query($sql) or die(mysql_error());

?>

<table width="50%" border="1" align="center"><?
while($row = mysql_fetch_assoc($rs))
{   
    ?>
        <tr>
            <td><?=$row['name'];?></td>
            <td>
            <object type="application/x-shockwave-flash" data="audio/player.swf" id="audioplayer1" height="50" width="290">
            <param name="movie" value="audio/player.swf">
            <param name="FlashVars" value="playerID=audioplayer1&soundFile=files/<?=$row['name'];?>">
            <param name="quality" value="high">
            <param name="menu" value="true">
            <param name="wmode" value="transparent">
            </object>
            </td>
           
        </tr>
    <?
   
}
?>
</table>
rathoddhirendra.blogspot.com-Google pagerank and Worth