CSci 1101: Input to a php program via extended URL.

Passing input to a php program


<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<!--
Examples of PHP variables and their use
Author: Elena Machkasova elenam@morris.umn.edu
Last modified: 2/18/08
-->

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<title>
Examples of PHP variables and their use
</title>
<?php 
$n = $_GET["input1"];
$m = $_GET["input2"];
?>

</head>
<body>

<h2>This page tests PHP variables</h2>

<p>
<?php
// integers and what you can do with them
$sum = $n + $m;

// variables are a part of the string that gets printed
print "$n + $m = $sum<br/>\n";

$prod = $n * $m;
$div = $n / $m;
$remainder = $n % $m;
print "$n * $m = $prod<br/>\n $n / $m = $div<br/>\n $n % $m = $remainder<br/>\n";

// changing $n:
$n = $m + 1;
// using \ to print $
print "\$n = $n<br/>\n";
?>

</p>
</body>

</html>

http://csci1101sp10.morris.umn.edu/~elenam/1101_spring10/first/input.php?input1=5&input2=3
http://csci1101sp10.morris.umn.edu/~elenam/1101_spring10/first/input.php?input1=-1&input2=5


CSci 1101 course web site.