Translate

Wednesday 29 May 2013

Design a Ribbon in Form Using CSS3

                        
                   
index.php:
<body>
<div id="container">

<div class="bubble">
<div class="rectangle"><h2>Creater Site</h2></div>
<div class="triangle-l"></div> <!-- Left triangle -->
<div class="triangle-r"></div> <!-- Right triangle -->
<div class="info">
<h2>Creater Site is my Blog</h2>
<p>
Hi Friends Creater Site is my Blog</p>

</div>
</div>

</div>
</body> 
 
style.css: 
 
     Download CSS 

Sunday 26 May 2013

Row styling using CSS3

                        


index.php:

    <div id="container">
    <h2>Alternate row styling using CSS3</h2>
    <h3>Even</h3>
    <ul class="even">
    <li>Creatersite is my Blog</li>
    <li>Creatersite is my Blog</li>
    <li>Creatersite is my Blog</li>
    <li>Creatersite is my Blog</li>
    </ul>
    <h3>Odd</h3>
    <ul class="odd">
    <li>Creatersite is my Blog</li>
    <li>Creatersite is my Blog</li>
    <li>Creatersite is my Blog</li>
    <li>Creatersite is my Blog</li>
    </ul>
    </div> 

style.css:




    body{ background-color:#666;margin:2% auto;color:#FFF; padding:10px;}
    #container{width: 960px; margin: 50px auto;}
    h3{ padding:10px;} h3,h2{ color:#800000;}
    ul li { padding:3px;}
    ul.even li:nth-child(even){ color:#CC0;}
    ul.odd li:nth-child(odd ) { color:#FF8000;}

Friday 24 May 2013

Update Query in Ajax

form.php:

 <?php
include('conn.php');
 if(isset($_GET['id2']))
{
        $id1=$_GET['id2'];
        session_start();
        $_SESSION['id1']=$id1;

        $select2 = mysql_query("SELECT *  from member where fid='$id1' ");
            $i=1;
        while($row1 = mysql_fetch_array($select2))
         {
        $fid=$row1['fid'];
        $memberslist=$row1['memberslist'];
?>
 <p style="text-align:center; font-size:18px;">Members:
<span id="txtHint2"><?php echo $memberslist;?></span></p>

<form action="" name="form1">
                 <tr ><td >
<select name="members" onchange="showCustomer2(this.value">
                 <option value="">Select</option>
                <option value="platinum" >Platinum</option>
                <option value="gold" >Gold</option>
                <option value="diamond" >Diamond</option>
                <option value="economical" >Economical</option>
                <option value="freelisting" >Freelisting</option>
  </select></td></tr><br>

script.php:



<script type="text/javascript">
function showCustomer2(str2)
{
//  alert("hi");
var xmlhttp;    
if (str2=="")
  {
  document.getElementById("txtHint2").innerHTML="";
  return;
  }
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("txtHint2").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","member.php?q="+str2,true);
xmlhttp.send();
}
</script>

member.php:

<?php
include("conn.php");
session_start();
$id3=$_SESSION['id1'];
if(isset($_GET['q']))
{   
 $id1=$_GET['q'];
$update=mysql_query("update member set memberslist='$id1' where fid='$id3'"); 
      $select2 = mysql_query("SELECT *  from member where fid='$id3' ");
            $i=1;
        while($row1 = mysql_fetch_array($select2))
        {
      echo $row1['memberslist'];
        
    } }
?>

Wednesday 22 May 2013

Rating in PHP using IP Address

                                   
                               


rate2.php:

<?php
include("settings.php");
connect();
$ids=array(1);
?>
<html>
<head>
<script src="jquery.js" type="text/javascript"></script>
<link rel="stylesheet" href="rating.css" />
<script type="text/javascript" src="rating.js"></script>
</head>
<body>
<?php
for($i=0;$i<count($ids);$i++)
    {
        $rating_tableName     = 'ratings';
     $id=$ids[$i];
 $q="SELECT total_votes, total_value FROM $rating_tableName WHERE id=$id";
$r=mysql_query($q);
if(!$r) echo mysql_error();
while($row=mysql_fetch_array($r))
{
    $v=$row['total_votes'];
    $tv=$row['total_value'];
    $rat=$tv/$v;
    
    }
    $j=$i+1;
    $id=$ids[$i];
echo'<div class="product">
           Rate Item '.$j.'
            <div id="rating_'.$id.'" class="ratings">';
                for($k=1;$k<6;$k++){
                    if($rat+0.5>$k)$class="star_".$k."  ratings_stars ratings_vote";
                    else $class="star_".$k." ratings_stars ratings_blank";
                    echo '<div class="'.$class.'"></div>';
                    }
                echo' <div class="total_votes"><p class="voted"> Rating: <strong>'.@number_format($rat).'</strong>/5 ('.$v. '  vote(s) cast) 
            </div>
        </div></div>';}
?>
</body></html>

rate.php:

<?php
header("Cache-Control: no-cache");
header("Pragma: nocache");
include("settings.php");
$id_sent = preg_replace("/[^0-9]/","",$_REQUEST['id']);
$vote_sent = preg_replace("/[^0-9]/","",$_REQUEST['stars']);
$ip =$_SERVER['REMOTE_ADDR'] ;
connect();
$q=mysql_num_rows(mysql_query("select id from ratings where id=$id_sent"));
if(!$q)mysql_query("insert into ratings (id,date) values ($id_sent,curdate())");
if ($vote_sent > $units) die("Sorry, vote appears to be invalid."); // kill the script because normal users will never see this.


//connecting to the database to get some information
$query = mysql_query("SELECT total_votes, total_value, used_ips FROM $rating_dbname.$rating_tableName WHERE id='$id_sent' ")or die(" Error: ".mysql_error());
$numbers = mysql_fetch_assoc($query);
$checkIP = unserialize($numbers['used_ips']);
$count = $numbers['total_votes']; //how many votes total
$current_rating = $numbers['total_value']; //total number of rating added together and stored
$sum = $vote_sent+$current_rating; // add together the current vote value and the total vote value
$tense = ($count==1) ? "vote" : "votes"; //plural form votes/vote

// checking to see if the first vote has been tallied
// or increment the current number of votes
($sum==0 ? $added=0 : $added=$count+1);

// if it is an array i.e. already has entries the push in another value
((is_array($checkIP)) ? array_push($checkIP,$ip) : $checkIP=array($ip));
$insertip=serialize($checkIP);

//IP check when voting
if(!isset($_COOKIE['rating_'.$id_sent])){
$voted=mysql_num_rows(mysql_query("SELECT used_ips FROM $rating_dbname.$rating_tableName WHERE used_ips LIKE '%".$ip."%' AND id='".$id_sent."' "));
                                    }
else $voted=1;                                  
if(!$voted) {     //if the user hasn't yet voted, then vote normally...

    if (($vote_sent >= 1 && $vote_sent <= $units)) { // keep votes within range, make sure IP matches 
    
        $update = "UPDATE $rating_tableName SET total_votes='".$added."', total_value='".$sum."', used_ips='".$insertip."' WHERE id='$id_sent'";
        $result = mysql_query($update); 
        if($result) setcookie("rating_".$id_sent,1, time()+ 2592000);
    } 
} //end for the "if(!$voted)"
// these are new queries to get the new values!
$newtotals = mysql_query("SELECT total_votes, total_value, used_ips FROM $rating_tableName WHERE id='$id_sent' ")or die(" Error: ".mysql_error());
$numbers = mysql_fetch_assoc($newtotals);
$count = $numbers['total_votes'];//how many votes total
$current_rating = $numbers['total_value'];//total number of rating added together and stored
$tense = ($count==1) ? "vote" : "votes"; //plural form votes/vote

// $new_back is what gets 'drawn' on your page after a successful 'AJAX/Javascript' vote
if($voted){$sum=$current_rating; $added=$count;}
$new_back = array();
for($i=0;$i<5;$i++){
    $j=$i+1;
    if($i<@number_format($current_rating/$count,1)-0.5) $class="ratings_stars ratings_vote";
    else $class="ratings_stars";
$new_back[] .= '<div class="star_'.$j.' '.$class.'"></div>';
                      }

$new_back[] .= ' <div class="total_votes"><p class="voted"> Rating: <strong>'.@number_format($sum/$added,1).'</strong>/'.$units.' ('.$count.' '.$tense.' cast) ';
if(!$voted)$new_back[] .= '<span class="thanks">Thanks for voting!</span></p>';
else {$new_back[] .= '<span class="invalid">Already voted for this item</span></p></div>';}
$allnewback = join("\n", $new_back);

// ========================


$output = $allnewback;
echo $output;
?>

db.php:

<?php 
$rating_tableName     = 'ratings';
$rating_unitwidth     = 15;
$rating_dbname        = 'mr';
$units=5;
function connect(){
    $host="localhost";
 $uname="root";
 $pass="";
 $rating_dbname= 'mr';

$con = mysql_connect($host,$uname,$pass);

if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
mysql_select_db($rating_dbname, $con);}


Saturday 18 May 2013

Activate&Deactive by On Click


                                      

index.php:


<table  cellpadding="10" cellspacing="0" border="1px" width="30%"><thead>
 <tr> <th class="head0">S.No</th><th class="head1">Main categories</th>
<th class="head0">Activate</th>
 <td>
          <?php 
                        if($cat['verify']=='0')
                        {
                        ?>
        <a href="status.php?verify=<?php echo $cat['fid'];?>" onclick="return confirm('Really you activate the account');">
                        <img src="img/deactivate.png" id="view" width="16" height="16" alt="" /> </a>
                        <?
                        }
                        if($cat['verify']=='1')
                        {
                        ?>
       <a href="status.php?verify=<?php echo $cat['fid'];?>" onclick="return confirm('Really you De-activate the account');"> 
                        <img src="img/activate.png" width="16" id="view" height="16" alt=""  /></a>
                        <?
                        }
                        ?>
                        </td>                             
                        
status.php:


<?php
include("conn.php");
if(isset($_GET['status']))
{
    $status=$_GET['status'];
    
    $select_status=mysql_query("select * from freelisting where fid='$status'");
    
    while($row=mysql_fetch_array($select_status))
    {
        $st=$row['status'];
    
    if($st=='0')
    {
        $status2=1;
    }
    else
    {
        $status2=0;
    }
    $update=mysql_query("update freelisting set status='$status2' where fid='$status' ");
    if($update)
    {
        header("Location:free-listing.php");
    }
    else
    {
        echo mysql_error();
    }
    }
    ?>
     
    <?php
}
?>

Friday 17 May 2013

Implode&Explode in Array

Download Coding

array.php:


<form name="aform" method="post">
<table border="0px" cellpadding="10" cellspacing="0" id="tbl">
<tr><td align="center" colspan="2">Driving Form</td></tr>
<tr>
     <td>vehicle</td>
     <td>
     <select name="mul[]" multiple style="width:150px;" size="10">
     <option value="Rohini">Rohini</option>
     <option value="Rogini">Rogini</option>
     <option value="Rokini">Rokini</option>
     <option value="rubini">rubini</option> <option value="Rohini">Rohini
     </option>
     <option value="Rogini">Rogini</option>
     <option value="Rokini">Rokini</option>
     <option value="rubini">rubini</option>
      <option value="Rohini">Rohini</option>
     <option value="Rogini">Rogini</option>
     <option value="Rokini">Rokini</option>
     <option value="rubini">rubini</option>
      <option value="Rohini">Rohini</option>
     <option value="Rogini">Rogini</option>
     <option value="Rokini">Rokini</option>
     <option value="rubini">rubini</option>
     </select>
     </td></tr>
<tr>
<td colspan="2" align="center"><input type="submit" name="submit" 
value="submit" /></td></tr>
</table>
</form>

Implode.php:

<?php
$conn=mysql_connect("localhost","root","");
$select_db=mysql_select_db("each_db",$conn);

if(isset($_POST['submit']))
{
    
$val=implode(',',$_POST['mul']);

$insert=mysql_query("insert into a(val) values('$val')");

}
?>

Explode.php:

<?php
$conn=mysql_connect("localhost","root","");
$select_db=mysql_select_db("each_db",$conn);

if(isset($_POST['submit']))
{

$val=implode(',',$_POST['mul']);
$insert=mysql_query("insert into a(val) values('$val')");
$select_tbl=mysql_query("select * from a",$conn);
while($fetch=mysql_fetch_object($select_tbl))
{
    $r=$fetch->val;
        $i=explode(",",$r);
    
}}


Script:

<script type="text/javascript">
function validation()
{
    var name=document.aform.vehicle.value;
    if(name=="" || name=="null")
    {
        alert("mark ur value");
        document.aform.vehicle.focus();
        return false;
    }
    
}
</script>

Validation for username&Password

  Download Js          

index.php:


<form class="form-wrapper" method="post">
<div align="center"><p style="margin-right:186px;">Username<span style="color:red;">*</span></p><input type="text" class="search" name="username" required="required" id="username" autocomplete="off" onblur="checkUserName(this.value)"/>
<p style="margin-right:70px;"><span id="usercheck"></span></p></div>
 <p>&nbsp;</p>
<div align="center"><p style="margin-right:150px;">Create Password<span style="color:red;">*</span></p><input type="password" class="search" autocomplete="off" required pattern="(?=.*\d)(?=.*[a-z])(?=.*[A-Z])\w{6,}" name="pwd1" onchange="this.setCustomValidity(this.validity.patternMismatch ? 'Password must contain at least6 characters, including UPPER/lowercase and numbers' : '');if(this.checkValidity()) form.pwd2.pattern = this.value;
"></p></div>
<p>&nbsp;</p>
<div align="center"><p style="margin-right:150px;">Verifed Password<span style="color:red;">*</span></p> 
<input type="password" class="search" required pattern="(?=.*\d)(?=.*[a-z])(?=.*[A-Z])\w{6,}" name="pwd2" onchange="
  this.setCustomValidity(this.validity.patternMismatch ? 'Please enter the same Password as above' : '');
"></p>  </div><p align="center"> <input type="submit" class="submit" value="Sign up"  name="submit"></p>
 </form>

username.php:

<?php 
$query=mysql_connect("localhost","root","");
mysql_select_db("reg_ajax",$query);
$arr_user=array("itechroom", "trialuser");
$username=$_POST['user_name'];


if(in_array($username,$arr_user)) 
{echo '<span class="error">Username already exists.</span>';exit;}

else if(strlen($username) < 6 || strlen($username) > 15)
{
echo '<span class="error">Username must be 6 to 15 characters</span>';}
else if (preg_match("/^[a-zA-Z1-9]+$/", $username)) 
{
       echo '<span class="success">Username is available.</span>';
} 
else 
{
      echo '<span class="error">Use alphanumeric characters only.</span>';
}

?>


Script:

function checkUserName(usercheck)

{
    $('#usercheck').html('<img src="images.gif" />');
    $.post("username.php", {user_name: usercheck} , function(data)
        {           
               if (data != '' || data != undefined || data != null) 
               {                   
                  $('#usercheck').html(data);   
               }
          });
}