Thursday 21 December 2017

important code

<?php
require_once "functions.php";
check_session();
$error = "";
function valid($username,$email,$password)
{
}


if (isset($_POST['submit']))
{
if (is_numeric($_POST['id']))
{
$id = $_POST['id'];
$username = mysql_real_escape_string(htmlspecialchars($_POST['first_name']));
$email = mysql_real_escape_string(htmlspecialchars($_POST['last_name']));
$password= mysql_real_escape_string(htmlspecialchars($_POST['contact_no']));
$email_address= mysql_real_escape_string(htmlspecialchars($_POST['email_address']));
$pass_word= mysql_real_escape_string(htmlspecialchars($_POST['password']));

if ($username == '' || $email == '' || $password == '' || $email_address == '' || $pass_word == '' )
{
$error = 'ERROR: Please fill in all required fields!';
valid($id, $username, $email,$password,$email_address,$pass_word);
}
else
{
mysql_query("UPDATE users SET first_name='$username', last_name='$email', contact_no='$password', email_address='$email_address', password='$pass_word' WHERE id='$id'")
or die(mysql_error());
header("Location: view user.php");
}
}
else
{
echo 'Error!';
}
}
else
{
if (isset($_GET['id']) && is_numeric($_GET['id']) && $_GET['id'] > 0)
{
$id = $_GET['id'];

$res = mysql_query("SELECT * FROM users WHERE id=$id") or die(mysql_error());

$row = mysql_fetch_array($res);
if($row)
{
$first_name = $row['first_name'];
$last_name = $row['last_name'];
$contact_no = $row['contact_no'];
$email_address = $row['email_address'];
$password = $row['password'];
        }
else
{
echo "No results!";
}
}
else
{
echo 'Error!';
}
}
?>
<!DOCTYPE html>
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.0/css/bootstrap.min.css">
<link rel = "stylesheet" type = "text/css" href="registeration.css"/>
<head>
<title>Edit Records</title>
</head>
<body>
<?php
nav_menu();
?>

<?php
if ($error != '')
{
echo $error;
}
?>
<div class="container">
        <div class="row centered-form">
        <div class="col-xs-12 col-sm-8 col-md-4 col-sm-offset-2 col-md-offset-4">
        <div class="panel panel-default">
        <div class="panel-heading">
    <h2 class="panel-title"><center>Edit User Data</center></h2>
</div>
<div class="panel-body">
    <form role="form" method="post">
<input type="hidden" name="id" id="id" value="<?php echo $id; ?>">
    <div class="row">
    <div class="col-xs-6 col-sm-6 col-md-6">
    <div class="form-group">
                <input type="text" name="first_name" id="first_name" class="form-control input-sm" placeholder="First Name" value="<?php echo $first_name; ?>">
    </div>
    </div>
    <div class="col-xs-6 col-sm-6 col-md-6">
    <div class="form-group">
    <input type="text" name="last_name" id="last_name" class="form-control input-sm" placeholder="Last Name" value="<?php echo $last_name; ?>">
   
</div>
    </div>
    </div>

    <div class="form-group">
    <input type="contact_no" name="contact_no" id="contact_no" class="form-control input-sm" placeholder="Contact No" value="<?php echo $contact_no; ?>">
    </div>
                            <div class="form-group">
    <input type="email_address" name="email_address" id="email_address" class="form-control input-sm" placeholder="email_address" value="<?php echo $email_address; ?>">
    </div>
<div class="form-group">
    <input type="password" name="password" id="password" class="form-control input-sm" placeholder="password" value="<?php echo $password; ?>">
    </div>
    <div class="row">
    </div>
   
    <input type="submit" name="submit" value="Submit" class="btn btn-info btn-block">
   
    </form>
    </div>
    </div>
    </div>
    </div>
    </div>
  </body>
</html>

Wednesday 15 November 2017

<?php
for($m=0;$m<=59;$m++)
{
    for($s=20;$s<=59;$s++)
    {
        echo $m."  ".$s."<br>";
    }
}
?>

<?php
$a=array(10,16,72,15,20);
$max=0;
for($p=0;$p<=4;$p=$p+1)
{
    echo $a[$p]."<br>";
    if($a[$p]>$max)
    {
        $max=$a[$p];
    }
}
?>          
<?php
$a=array(20,15,30,13,16,28,19,62,33,62);
for($p=0;$p<=9;$p=$p+1)
{
    print $a[$p]."   ".$p."<br>";
}
?>
<?php
$a=array(10,20,30,40,50);
print $a[4];
?>
<?php
$a=array(10,20,30,40,50);
print $a[3];
?>
<?php
$a=12345;
$b=number_format($a);
echo $a."<br>";
echo $b;
?>
<?php
$a=12345;
$b=number_format($a);
echo $a."<br>";
echo $b;
?>
<?php
class abc
{private $a="master";

 public function display()
 {echo ( $this->$a);
 // echo $this->$a."<br>";
 }
 }
 $obj=new abc;
 $x=$obj->display();
 echo $x;
?>
<!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=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<?php
$a=10;
$b=20;
$c=$a+$b;
echo $c;
?>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C/DTD XHTML 1.0 Strict//EN"
  "http://www.w3.org/TR/xhtml1-strict.dtd">
  <html xmlns="http://www.w3.org/1999/xhtml"  xml:lang="en" lang="en">
  <head>
     <title>Hit counter</title>
     <link rel="stylesheet" type="text/css" href="common.css"/>
     </head>
     <body>
   
       <h1>A simple hit counter</h1>
     
<?php

$counterFile="./count.dat";

if(!file_exists($counterFile)) {
    if( !( $handle = fopen($counterFile, "w"))) {
      die("Cannot create the counter file.");
    } else {
        fwrite($handle, 0);
        fclose($handle);
      
    }
}
if(!($handle= fopen($counterFile, "r"))) {
    die("Cannot read the counter file.");
}
$counter= (int) fread($handle, 20);
fclose($handle);

$counter++;
echo "<p>You're visitor No. $counter.</p>";  

if( !($handle = fopen($counterFile, "w"))){
    die("Cannot open the counter file for writing.");
}
fwrite($handle, $counter);
fclose($handle);
?>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
    <title>Listing the contents of a directory</title>
    <link rel="stylesheet" type="text/css" href="common.css"/>
   </head>
   <body>
     <h1>Listing the contents of a directory</h1>
   
    <?php
   
    $dirPath= "F:\Course Material\documents\Documents";
    function traverseDir($dir) {
     echo "<h2>Listing $dir...</h2>";
     if( !($handle = opendir($dirPath))) die("Cannot open the directory.");
   
     $files= array();
     while ($file = readdir($handle)) {
         if($file != "." && $file != "..") {
         if(is_dir($dir ."/". $file)) $file.="/";
         $files[] = $file;
         }
     }
      sort($files);
      echo "<ul>";
      foreach($files as $file) echo "<li>$file</li>";
      echo "</ul>";
     
      foreach($files as $file) {
          if(substr($file, -1) == "/") traverseDir("$dir/" . substr($file, 0, -1));
      }
      closedir($handle);
       }
      traverseDir($dirPath);
      ?>
      </body>
      </html>
<?php
$a="Mridul Sharma";
$b=substr($a,8,2);
echo $a."<br>";
echo $b;
?>
<?php
$a=1;
while($a<=5)
{
    echo $a;
    echo " Raman Kumar"."<br>";
    echo " House No.403"."<br>";
    echo " Sector 06"."<br>";
    echo " Panchkula"."<br>";
    $a=$a+1;
}
  echo "End of Job";
?>
<!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=utf-8" />
<title>Php Revision</title>
</head>
<body>
<?php
$abc=50;
while($abc<=100)
{
    echo $abc."  ";
    $abc=$abc+5;
}

?>
</body>
</html>                                                                                             
for($a=5; $a>=1; $a--)
{
for($b=1; $b<=$a; $b=$b+1)
{ print $b."      ";
}
print "<br>";
}

for($a=1; $a<=5; $a=$a+1)
{
for($b=1; $b<=$a; $b=$b+1)
{
    echo $a."       ";
}
echo "<br>";
}


Tuesday 31 October 2017

<?php
$b=5;
$c=20;
$a1=add($b, $c);
echo "a1=".$a1."<br>";
$a2=add(100,200);
print "a2=".$a2."<br>";
$a3=add($b,40);
print "a3=".$a3."<br>";
$a4=add(30,$c);
print "a4=".$a4;
function add($b, $c)
{
   $d=$b+$c;
echo "value of b=".$b."<br>";
echo "value of a=".$c."<br>";
return($d);
}
?>
<?php
$b=5;
$c=20;
$a1=add($b, $c);
echo "a1=".$a1."<br>";
$a2=add(100,200);
echo "a2=".$a2."<br>";
$a3=add($b,40);
print "a3=".$a3."<br>";
$a4=add(30,$c);
print "a4=".$a4;
function add($b, $c)
{
$d=$b+$c;
echo "Value of b=".$b."<br>";
echo "Value of c=".$c."<br>";
return($d);
}
<?php
class student{
public $rollno;
public $name;
}
$s1=new student( );
$s1->Roll no=123;
$s1->Name="Mridul";

echo s1. Rollno;
echo s1. Name;
?>
<?php
class student{
public $rollno;
public $name;
}
$s1=new student( );
$s1->Rollno=123;
$s1->Name="Mridul";

echo s1.Rollno;
echo s1.Name;
?>
<?php
class student{
public $rollno;
public $name;
}
$s1=new student( );
$s1->Rollno=123;
$s1->Name="Mridul";

echo s1.Rollno;
echo s1.Name;

Sunday 29 October 2017

<?php
$a=array(10,20,30,40,50);
print $a[3];
?>
<?php
$a=array(10,20,30,40,50);
print $a[3];
?>
<?php
$a=array(10,20,30,40,50);
print $a[3];
?>
<?php
$a=array(20,15,30,13,16,28,19,62,33,62);
for($p=0; $p<=9; $p=$p+1)
{
print $a[$p]."        ".$p."<br>";
}
?>
<?php
$a=array(20,15,30,13,16,28,19,62,33,62);
for($p=0; $p<=9; $p=$p+1)
{
print $a[$p]."          ".$p."<br>";
}
?>
<?php
$a=array(20,15,30,13,16,28,19,62,33,62);
for($p=0;$p<=9; $p=$p+1)
{
print $a[$p]."           ".$p."<br>";
}
?>
<?php
$a=array(10,16,72,15,20);
$max=0;
for($p=0; $p<=4; $p=$p+1)
{
 echo $a[$p]."<br>";
if($a [$p] >$max)
{
$max=$a[$p];
}
}
echo "maximum value in the list=".$max;
?>
<?php
$a=array(10,16,72,15,20);
$max=0;
for($p=0; $p<=4; $p=$p+1)
{
  echo $a[$p]."<br>";
if($a[$p]>$max)
{
$max=$a[$p];
}
}
echo "maximum value in the list=".$max;
?>
<?php
$a=array(10,16,72,15,20);
$max=0;
for($p=0; $p<=4; $p=$p+1)
{
   echo $a[$p]."<br>";
  if($a[$p]>$max)
{
$max=$a[$p];
}
}
echo "maximum value in the list=".$max;
?>
<?php
$a=array(10,16,50,12,20);
$min=$a{0};
for($i=0; $i<=4; $i++)
{
    if($a[i]< $min)
{
  ($min= $a[$i]);
}
}
print "minimum value=".$min;
?>
<?php
$a=array(10,16,50,12,20);
$min=$a{0};
for($i=0; $i<=4; $i++)
{
   if($a[i]< $min)
{
   ($min=$a[$i]);
}
}
print "minimum value=".$min;
?>
<?php
$a=array(10,16,50,12,20);
$min=$a{0};
for($i=0; $i<=4; $i++)
{
   if($a[i]< $min)
{
    ($min=$a[$i]);
}
}
print "minimum value=".$min;
?>
<?php
$a=array(10, 20, 15, 12, 6);
$sum=0;
for($b=0; $b<=4; $b=$b+1)
{
   ($sum=$sum+$a[$b]);
}
echo "Total value=".$sum;
?>
<?php
$a=array(10,20,15,12,6);
$sum=0;
for($b=0; $b<=4; $b=$b+1)
{
   ($sum=$sum+$a[$b]);
}
echo "Total value=".$sum;
?>
<?php
$a=array(10,20,15,12,6);
$sum=0;
for($b=0; $b<=4; $b=$b+1)
{
   ($sum=$sum+$a[$b]);
}
echo "Total value=".$sum;
?>



<?php
$a=12345;
$b=number_format($a);
echo $a."<br>";
echo $b;
?>
<?php
$a=12345;
$b=number_format($a);
echo $a."<br>";
echo $b;
?>
<?php
$a=12345;
$b=number_format($a);
echo $a."<br>";
echo $b;
?>

$a="Raman Kumar";
$b=strpos($a,"r");
echo $a."<br>";
echo $b;

$a="Raman Kumar";
$b=strpos($a, "r");
echo $a."<br>";
echo $b;

$a="Raman Kumar";
$b=strpos($a, "r");
echo $a."<br>";
echo $b;

$a="Mridul";
$x=strlen($a);
for($i=0; $i<=$x; $i=$i+3)
{
     echo $a[$i]."<br>";
}

$a="Mridul";
$x=strlen($a);
for($i=0; $i<=$x; $i=$i+3)
{
    echo $a[$i]."<br>";
}

$a="Mridul Sharma";
$b=($a[0]);
echo $b."       ";
$c=($a[7]);
echo $c."        ";

$a="Mridul Sharma";
$b=($a[0]);
echo $b."       ";
$c=($a[7]);
echo $c."       ";

$a="Mridul Sharma";
$b=substr($a,8,2);
echo $a."<br>";
echo $b;

$a="Mridul Sharma";
$b=substr($a,8,2);
echo $a."<br>";
echo $b;

$a="Mridul Sharma";
$b=substr($a,8,2);
echo $a."<br>";
echo $b;

$a="Mridul Sharma";
$b=susbstr($a,8,2);
echo $a."<br>";
echo $b;

$a="Bombay";
$b=substr($a,2,3);
echo $a."<br>";
echo $b;

$a="Bombay";
$b=substr($a,2,3);
echo $a."<br>";
echo $b;

$a="Bombay";
$b=substr($a,2,3);
echo $a."<br>";
echo $b;

<?php
$a="Computer";
$b=str_replace("Computer", "software", $a);
echo $b;
?>
<?php
$a="Computer";
$b=str_replace("Computer","software",$a);
echo $b;
?>
<?php
$a="Computer";
$b=str_replace("Computer", "software",$a);
echo $b;
?>
<?php
$a="Computer";
$b=strtolower($a);
echo $a."        ".$b;
?>
<?php
$a="Computer";
$b=strtolower($a);
echo $a."      ".$b;
?>
<?php
$a="Computer";
$b=strtolower($a);
echo $a."        ".$b;
?>
<?php
$a="chandigarh";
$b=strtoupper($a);
echo $b."        ";
echo $a;
?>
<?php
$a="chandigarh";
$b=strtoupper($a);
echo $b."        ";
echo $a;
?>
<?php
$a="chandigarh";
$b=strtoupper($a);
echo $b."      ";
echo $a;
?>
<?php
$a="Chandigarh";
$b=substr($a,0,1);
$c=substr($a,1);
$d=strtoupper($b);
$e=strtolower($c);
echo $d. $e;
?>
$a="Chandigarh";
$b=substr($a,0,1);
$c=substr($a,1);
$d=strtoupper($b);
$e=strtolower($c);
echo $d, $e;
?>
$a="Chandigarh";
$b=substr($a,0,1);
$c=substr($a,1)
$d=strtoupper($b);
$e=strtolower($c);
echo $d, $e;
?>
<?php
$a="        I love India";
$b= ltrim($a);
echo $a."<br>";
echo $b;
?>
<?php
$a="      I love India";
$b=ltrim($a);
echo $a."<br>";
echo $b;
?>
<?php
$a="      I love India";
$b=ltrim($a);
echo $a."<br>";
echo $b;
?>


important code

<?php require_once "functions.php"; check_session(); $error = ""; function valid($username,$email,$password) { ...