Translate

Wednesday 24 April 2013

Coding For Download a File as PDF


Download:pdf converter



index.php:                   

</html>
<body>
<fieldset style="background-color:#000;color:#FFF;height:250px;padding:20px;
letter-spacing:3px;width:800px;text-align:center;border:1px solid red;margin:50px 50px 0 150px;">
<center><form method="post" action="pdf6.php"> 
<p>Here we have to see how to convert (or) current webpage as pdf file We alreadydiscuss the thing about conversion of webpage as MS-Word document file.Similar tothis we have to convert current webpage as pdf  on current  webpage itself.Most of the websites willing to provide their document as pdf instead MS-Word because in pdf the data can't be changed by user.From this information from pdf is unique.Somost of website add a link to download as pdf.Let see how it can developed in php.For designing and import content of webpages  we have include the coding of pdf toolkit here.Download the pdf creator html2fpdf add extractthe files and  add fewfiles in the html2fpdf folder.The download link for pdf creator toolkit is html2fpdf</p>
<input type="submit" name="submit" value="Download As PDF" />
</form>
</center>
</fieldset>
</body>
</html>

Coding:

Output (header("Content-Disposition: attachment; Filename=pdff.pdf;Content-type: application/pdf;"));

           
           
            

                            

Monday 22 April 2013

Image Upload using Ajax&Jquery


index.php:

<?php
include('db.php');
session_start();
$session_id='1'; //$session id
?>
<html>
<head>
<title>Ajax Image Upload </title>
</head>

<script type="text/javascript" src="scripts/jquery.min.js"></script>
<script type="text/javascript" src="scripts/jquery.form.js"></script>

<script type="text/javascript" >
 $(document).ready(function() 
            { 
        $('#photoimg').live('change', function()       
             { 
       $("#preview").html('');
       $("#preview").html('<img src="loader.gif" alt="Uploading...."/>');
       $("#imageform").ajaxForm({
       target: '#preview'
        }).submit();
        
            });
        }); 
</script>
<body>
<div style="width:600px">
<form id="imageform" method="post" enctype="multipart/form-data" 
action='ajaximage.php'>
Upload your image <input type="file" name="photoimg" id="photoimg" />
</form>
<div id='preview'>
</div>
</div>
</body>
</html>

ajax.php:

<?php
include('db.php');
session_start();
$session_id='1'; //$session id
$path = "uploads/";

    $valid_formats = array("jpg", "png", "gif", "bmp");
    if(isset($_POST) and $_SERVER['REQUEST_METHOD'] == "POST")
        {
            $name = $_FILES['photoimg']['name'];
            $size = $_FILES['photoimg']['size'];
            
            if(strlen($name))
                {
                    list($txt, $ext) = explode(".", $name);
                    if(in_array($ext,$valid_formats))
                    {
                    if($size<(1024*1024))
                        {
   $actual_image_name = time().substr(str_replace(" ", "_", $txt), 5).".".$ext;
          $tmp = $_FILES['photoimg']['tmp_name'];

           if(move_uploaded_file($tmp, $path.$actual_image_name))
                                {
                   mysql_query("UPDATE upload_tbl SET image='$actual_image_name' WHERE id='$session_id'"echo "<img src='uploads/".$actual_image_name."'class='preview'>";
                                }
                            else
                                echo "failed";
                        }
                        else
                        echo "Image file size max 1 MB";                    
                        }
                        else
                        echo "Invalid file format..";   
                }
                
            else
                echo "Please select image..!";
                
 exit;
 }
?>

db.php:

<?php
$mysql_hostname = "localhost";
$mysql_user = "root";
$mysql_password = "";
$mysql_database = "upload_image";
$prefix = "";
$bd = mysql_connect($mysql_hostname, $mysql_user, $mysql_password) or die("Opps some thing went wrong");
mysql_select_db($mysql_database, $bd) or die("Opps some thing went wrong");

?>

Download:javascripts                

Saturday 20 April 2013

Quiz Concept using PHP in Static

Download:Quiz

index.php:
    
        
        <form action="grade.php" method="post" id="quiz">
        
            <ol>
            
                <li>
                
                    <h3>Who developed JAVA?</h3>
                    
                    <div>
                        <input type="radio" name="question-1-answers" id="question-1-answers-A" value="A" />
                        <label for="question-1-answers-A">A)    Cambridge </label>
                    </div>
                    
                    <div>
                        <input type="radio" name="question-1-answers" id="question-1-answers-B" value="B" />
                        <label for="question-1-answers-B">B)    Dennis Ritchie</label>
                    </div>
                    
                    <div>
                        <input type="radio" name="question-1-answers" id="question-1-answers-C" value="C" />
                        <label for="question-1-answers-C">C)    Ken Thompson</label>
                    </div>
                    
                    <div>
                        <input type="radio" name="question-1-answers" id="question-1-answers-D" value="D" />
                        <label for="question-1-answers-D">D)    James gosling</label>
                    </div>
                
                </li>
                

Wednesday 17 April 2013

Flames Concept

index.php:


<body>
<form action="" method="post">
   <table width="30%" height="204" border="1" 
   align="center" cellpadding="0" cellspacing="0">
    <tr><td colspan="2" align="center" style="color:#F00" ><?php
      $value1 = $_POST['value1'];
      $value2 = $_POST['value2'];
      
      if(isset($value1) && isset($value2)) {
        if($value1 == $value2){
            echo "Both are same names";exit;
          } 
          else {
              $flames = array(f,l,a,m,e,s);
              for($i = 0; $i < strlen($value1); $i++) {
                  for($j = 0; $j < strlen($value2); $j++)
                      if($value1[$i] == $value2[$j]){
                          $value1[$i] = $value2[$j] = '/';
                          break;
                      }
              }
          $value1 = str_replace("/", "", $value1); 
          $value2 = str_replace("/", "", $value2); 
          $count = strlen($value1) + strlen($value2);
          $flame = "flames";
      
          while(strlen($flame)!= 1) {
              $diff = $count%strlen($flame);
              if($diff == 0){
              $diff=strlen($flame)-1;
              }    else {
              $diff--;
              }
              $flame[$diff] = "@"; 
              list($f1,$f2)= preg_split("/@/",$flame);
              $flame=$f2.$f1;
          }
          switch($flame){
              case f:
                  echo "You are now Friends";
                  break;
          case l:
                  echo "You are now Lovers";
                  break;
              case a:
                  echo "You are now Affection";
                  break;
            case m:
                  echo "You are now Married";
                  break;
              case e:
                  echo "You are now Enemy";
                  break;
            case s:
                  echo "You are now Sister";
                  break;
          }
              }
          }
      ?>
      </td></tr>
                <tr>
                  <th scope="col" colspan="2" bgcolor="#999999">Flames</th>
                </tr>
                
                <tr align="center">
                  <th scope="row">Enter Name 1</th>
                  <td><input type="text" name="value1"></td>
                </tr>
                <tr align="center">
                  <th scope="row">Enter Name 2</th>
                  <td><input type="text" name="value2"></td>
                </tr>
                <tr>
                    <td colspan="2" align="center">
                   <input type="submit" name="submit" value="submit"></td>
                  </tr>
              </table>
          
            </form>
            </body>
</html>
            
               

Convert PHP/HTML Form Coding to MS-Word & Excel

HTML/PHP Form to MS-Word:


header("Content-type: application/vnd.ms-word");
header("Content-Disposition: attachment; Filename=saveasword.doc");

      
HTML/PHP Form to MS-Excel:


header("Content-type: application/vnd.ms-excel");
header("Content-Disposition: attachment; Filename=saveasexcel.xsl");

form.php: 
<body>
<form name="form" action="12.php" method="get">
<table border="1" width="300" cellpadding="10" cellspacing="0" align="center" id="tbl">
<tr>
    <td colspan="2" align="center">Application form</td>
    </tr>
<tr>
     <td>Name</td>
     <td>
     <input type="text" name="name" />
     </td>
</tr>
<tr>
     <td>Father name</td>
     <td><input type="text" name="fname" />
     </td></tr>
<tr>
     <td>Occuption</td>
     <td><input type="text" name="occupation"/>
     </td></tr>
<tr>
     <td>Gender</td>
     <td><input name="gender" type="radio" value="male" checked="checked" />Male<input name="gender" type="radio" value="Female"/>Female</td>
     </tr>
<tr> 
     <td colspan="3" align="center"><input name="submit" type="submit" value="Save as word"/></td>
     </tr>
     <tr>
     
     <td colspan="3" align="center"><input type="submit" name="submit1" value="Save as excel"/></td>
     
     </tr>     
</table>
</form>
</body>
</html>

12.php: 


           
         
  
                        

Facebook like Commentcount,Likecount,Sharecount for URL

 Download:
                Facebook

Coding:

 index.php:

<html><body>
<form method="post" action="">
Enter URL: <input type="text" name="url">
<input type="submit" name="submit">
</form>
</body>
</html>


like.php:

<?php
if(isset($_POST['submit']))
{
$url1=$_POST['url'];
$addr="http://api.facebook.com/restserver.php?method=links.getStats&urls=".$url1;
$page_source=file_get_contents($addr);
$page = htmlentities($page_source);
$like="<like_count>";
$like1="</like_count>";
$lik=strpos($page,htmlentities($like));
$lik1=strpos($page,htmlentities($like1));
$fullcount=strlen($page);
$a=$fullcount-$lik1;
$aaa=substr($page,$lik+18,-$a);
$aaa1=substr($page,605,610);
echo "Like Count:  ".$aaa;
}
?>

share.php:


<?php
if(isset($_POST['submit']))
{
$url1=$_POST['url'];
$addr="http://api.facebook.com/restserver.php?method=links.getStats&urls=".$url1;
$page_source=file_get_contents($addr);
$page = htmlentities($page_source);
$like="<share_count>";
$like1="</share_count>";
$lik=strpos($page,htmlentities($like));
$lik1=strpos($page,htmlentities($like1));
$fullcount=strlen($page);
$a=$fullcount-$lik1;
$aaa=substr($page,$lik+19,-$a);
$aaa1=substr($page,605,610);
echo "Share Count: ".$aaa;
}
?>

comment.php:


<?php
if(isset($_POST['submit']))
{
$url1=$_POST['url'];
$addr="http://api.facebook.com/restserver.php?method=links.getStats&urls=".$url1;
$page_source=file_get_contents($addr);
$page = htmlentities($page_source);
$like="<comment_count>";
$like1="</comment_count>";
$lik=strpos($page,htmlentities($like));
$lik1=strpos($page,htmlentities($like1));
$fullcount=strlen($page);
$a=$fullcount-$lik1;
$aaa=substr($page,$lik+21,-$a);
$aaa1=substr($page,605,610);
echo "Comment Count: ".$aaa;
}
?>

comment-box.php:


<?php
if(isset($_POST['submit']))
{
$url1=$_POST['url'];
$addr="http://api.facebook.com/restserver.php?method=links.getStats&urls=".$url1;
$page_source=file_get_contents($addr);
$page = htmlentities($page_source);
$like="<commentsbox_count>";
$like1="</commentsbox_count>";
$lik=strpos($page,htmlentities($like));
$lik1=strpos($page,htmlentities($like1));
$fullcount=strlen($page);
$a=$fullcount-$lik1;
$aaa=substr($page,$lik+25,-$a);
$aaa1=substr($page,605,610);
echo "<br />Comment Box Count: ".$aaa."<br /><br /><br /><br /><br /><br />";
}
?>

Voting in PHP USing IP Address

Voting in PHP USing IP Address


Download:
           voting
      
Output: 
                 


Coding:
           
<body>
<div align="center">
<h3>Voting With PHP</h3>
<?php
include('config.php');
$sql=mysql_query("SELECT * FROM messages  LIMIT 9");
while($row=mysql_fetch_array($sql))
{
$msg=$row['msg'];
$mes_id=$row['mes_id'];
$up=$row['up'];
$down=$row['down'];
?>

<div id="main">
<div class="box1">
<div class='up'>
<a href="up_vote.php?id=<?php echo $mes_id; ?>" class="vote" id="<?php echo $mes_id; ?>" name="up">
<?php echo $up; ?></a></div>

<div class='down'>
<a href="down_vote.php?id=<?php echo $mes_id; ?>" class="vote" id="<?php echo $mes_id; ?>" name="down">
<?php echo $down; ?></a></div>
</div>

<div class='box2' ><?php echo $msg; ?></div>

</div>
<?php } ?>
</div>
</body>
</html>