Showing posts with label PHP. Show all posts
Showing posts with label PHP. Show all posts

Monday, 27 July 2015

Authentication System by using PHP

// Created by PhpStorm.
 // User: Tanzila Islam
 // Date: 7/7/15
 // Time: 4:07 AM

<?php
session_start();

$userinfo = array(
                'Mohita'=>'mohita',
                'Kitty'=>'kitty'
                );



if(isset($_POST['username'])) {
    if($userinfo[$_POST['username']] == $_POST['password']) {
        $_SESSION['username'] = $_POST['username'];
    }else {
        //Invalid Login
    }
}
?>
<form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">

Name:<input type="text" name="username"> Password:<input type="password" name="password">
<input type="submit" name="submit" value="Log in"onclick="javascript: form.action='test1.php';" />

</form>

OUTPUT





Friday, 26 June 2015

Sum of the Squares of the first N Natural Numbers

//Tanzila Islam

//Southeast University

//mail : tanzilamohita@gmail.com


<?PHP

  if($_SERVER['REQUEST_METHOD']=="POST")

  {

   $n = $_POST['num'];

 

    $sum = ($n * ($n + 1) * (2 * $n + 1 )) / 6;


    printf("Sum of the series : ");


    for($i =1;$i<=$n;$i++)

 {

         if ($i != $n)

             printf("%d^2 + ",$i);

         else

             printf("%d^2 = %d ",$i,$sum);

    }


   

}

?>


<form method="post" action="">

Give some input  : <input type="text" name="num" /><br />

<input type="submit" value="Submit" />

</form>





 

Sum of N negative numbers

//Tanzila Islam

//Southeast University

//mail : tanzilamohita@gmail.com


<?PHP

  if($_SERVER['REQUEST_METHOD']=="POST")

  {

   $series = $_POST['num'];

 

 for($i=1;$i<=$series;$i++)

{

printf("- %d",$i);


$total+=$i;

}

printf("= - %d ",$total);


}


 

 

?>


<form method="post" action="">

Give some input  : <input type="text" name="num" /><br />

<input type="submit" value="Submit" />

</form>

Sum of N odd numbers

//Tanzila Islam

//Southeast University

//mail : tanzilamohita@gmail.com


<?PHP

  if($_SERVER['REQUEST_METHOD']=="POST")

  {

   $n = $_POST['num'];

 

    $sum = ($n * ($n + 1)) / 2;


    print("Sum of the series: ");


    for($i =1;$i <= $n;$i++)

 {

         if ($i!=$n)

             printf("%d + ",$i);

         else

             printf("%d = %d ",$i,$sum);

         }

  }

?>


<form method="post" action="">

Give some input  : <input type="text" name="num" /><br />

<input type="submit" value="Submit" />

</form>

Sum of the series for N numbers

//Tanzila Islam

//Southeast University

//mail : tanzilamohita@gmail.com


<?PHP

  if($_SERVER['REQUEST_METHOD']=="POST")

  {

   $n = $_POST['num'];

 

    $sum = ($n * ($n + 1)) / 2;


    print("Sum of the series: ");


    for($i =1;$i <= $n;$i++)

 {

         if ($i!=$n)

             printf("%d + ",$i);

         else

             printf("%d = %d ",$i,$sum);

         }

  }

?>


<form method="post" action="">

Give some input  : <input type="text" name="num" /><br />

<input type="submit" value="Submit" />

</form>