Webbserverprogrammering 1

Show sourcecode

The following files exists in this folder. Click to view.

webb_srv1/exercises/

aside.php
form-quiz-3/
formular7.php
funktioner.php
grunder.php
string4.php
string_form4.php

formular7.php

72 lines UTF-8 Windows (CRLF)
<html lang="sv">
<head>
 <meta charset="utf-8">
 <title>Formulär 7</title>
 
  <style type="text/css">
  ul {
   list-style: none;
   margin: 0;
   padding: 0;
  }
  label {
   display: inline-block;
   width: 100px;
  }
  button {
   margin: 1em 0;
  }
  h4 {
   margin: 1em 0 0.5em 0;
  }
  </style>
</head>

<body>

<h3>Formulär 7</h3>

<form action="" method="post">
<ul>
    <li><label>Tal 1:</label> <input name="nr1" type="text" value="0" /></li>
    <li><label>Tal 2:</label> <input name="nr2" type="text" value="0" /></li>
    <li><label>Tal 3:</label> <input name="nr3" type="text" value="0" /></li>
    <li><button type="submit">Beräkna</button></li>
</ul>
</form>

<?php
if(isset($_POST['nr1']) && $_POST['nr1'] != "") {
 
$nr1 $_POST['nr1'];
} else {
 
$nr1 0;
}

if(isset(
$_POST['nr2']) && $_POST['nr2'] != "") {
 
$nr2 $_POST['nr2'];
} else {
 
$nr2 0;
}

if(isset(
$_POST['nr3']) && $_POST['nr3'] != "") {
 
$nr3 $_POST['nr3'];
} else {
 
$nr3 0;
}

$medel medel($nr1$nr2$nr3);

echo 
"<p>De tre talen: $nr1$nr2$nr3<br/>";
echo 
"Medelvärdet: $medel</p>";

// -----------------------------------------------------------------------
// Calculate mean-value from 3 arguments
// -----------------------------------------------------------------------
function medel($nr1$nr2$nr3) {
 
$sum $nr1 $nr2 $nr3;
 return 
$sum 3;
}
?>

</body>
</html>