index.php - PHP Online
Form of PHP Sandbox
Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php
in the places where the PHP script should be executed.
Result of php executing
Full code of index.php.php
- #Abdul Khaliq 20188856
- #Mohammed Rauf 20188398
- <html><body>
- <table witdh=100%, border= normal>
- <tr>
- <th>Input Value</th>
- <th>Output Result</th>
- </tr>
- <tr><td>
- <form method='post' name="form1" action="">
- Basic Salary <input name='basic' /><br />
- Marital Status: <br />
- <input type='radio' name='ms' value='single' checked/> Single <br />
- <input type='radio' name='ms' value='married' /> Married <br />
- Extra: <br />
- <input type='checkbox' name='extra[]' value="200>Work on Weekend" /> Work on Weekend - BD 200 <br />
- <input type='checkbox' name='extra[]' value="100>Work Night Shift" /> Work Night Shift - BD 100 <br />
- <input type='checkbox' name='extra[]' value="400>Work Abroad" /> Work Abroad - BD 400 <br /> <br/>
- <input type='submit' value='Calculate Salary' name = 'main' /> <br /> <br/>
- <input type='checkbox' name='save'/> Save these Details <br/> <br/>
- </form>
- <form method='post' action='history.php'>
- <input type = 'submit' value = 'View History' name = 'hist' />
- </form>
- </td>
- <td>
- <?php
- extract($_POST);
- if (!empty($_POST))
- {
- if($ms == "single")
- $sal = 50 + (int)$basic;
- else
- $sal = 100 + (int)$basic;
- foreach($extra as $key){
- $temp = explode(">", $key);
- $sal += $temp[0];
- }
- echo "<li>Salary Details: Total Salary is BD$sal </li>";
- echo "<li>Extras: </li>";
- $counter = 0;
- foreach($extra as $key){
- $counter++;
- $temp = explode(">", $key);
- echo "          $counter. $temp[1] <br>";
- }
- date_default_timezone_set("Asia/Bahrain");
- $details['0'] = array(
- 'total' => $sal,
- 'date' => date('d/m/Y'),
- 'time' => date("h:i:sa"),
- 'extra[]' => $extra
- );
- $cookies = $_COOKIE['history'];
- $cookies = stripslashes($cookies);
- $array = json_decode($cookies, true);
- if(!empty($array!=null))
- $result = array_merge($array,$details);
- else
- $result = $details;
- if(isset($save)){
- //setcookie('historyDetails', null, -3600);
- setcookie("historyDetails", json_encode($result), time() + 604800);
- }
- }
- ?>
- </td></tr></table></body></html>
File Description
- index.php
- PHP Code
- 21 Mar-2021
- 1.96 Kb
You can Share it:
Latest PHP Pastes