|
|
|
|
|
|
| |
My friend was going cookies over using cookies, so I thought I'll make him this little calculator that uses cookies for saving the results... Sure you'll find so basic.
| <?php
include("xmlvalido.php");
if(isset($_COOKIE["ACUMULADO"])&&(!isset($_POST["CE"]))){
$valor = $_COOKIE["ACUMULADO"];
if($_POST["op"]=="1"){
$valor_nuevo=$valor+$_POST["dat"];
}
if($_POST["op"]=="2"){
$valor_nuevo=$valor-$_POST["dat"];
}
if($_POST["op"]=="3"){
$valor_nuevo=$valor*$_POST["dat"];
}
if($_POST["op"]=="4"){
$valor_nuevo=$valor/$_POST["dat"];
}
setcookie("ACUMULADO",$valor_nuevo);
echo abre_web("Mi calculadora");
}else{
setcookie("ACUMULADO",0);
$valor_nuevo=0;
$valor=0;
echo abre_web("Mi calculadora");
}
?>
<br>
<p> Valor calculado hasta ahora: <?php echo $valor_nuevo;?></p>
<form action="calculadora.php" method="POST">
<p><input type="radio" name="op" value="1">Sumar</p>
<p><input type="radio" name="op" value="2">Restar</p>
<p><input type="radio" name="op" value="3">Multiplicar</p>
<p><input type="radio" name="op" value="4">Dividir</p>
<p>Valor: <input type="text" name="dat"></p>
<input type="submit" value="Calcular" name="Calcular">
<input type="submit" value="CE" name="CE">
</form><?php
echo cierra_web();
?> | |
Note I've created a file called "funciones.php" that provides my php all the headers for making valid xhtml webs! Here I'm posting it...
...xmlvalido.php
| <?php
function abre_web($titulo)
{
$salida=<<<TXT
< ?xml version="1.0" encoding="UTF-8"? >
<!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="sp" lang="sp">
<head>
<title>$titulo</title>
</head>
<body>
<p>
TXT;
return $salida;
}
function cierra_web(){
$salida=<<<TXT
</p>
</body>
</html>
TXT;
echo $salida;
}
function enlace($texto, $url){
$salida=<<<TXT
<a href="$url">$texto</a>
TXT;
return $salida;
}
?> | |
-themightyindian |
|
| PHP4 MYSQL Authentication Script with cookie. Short & Sweet
Categories : Authentication, Apache, Cookies, PHP, MySQL | | | A very simple PHP single password cookie based login without usernames. Categories : PHP, Cookies, Security, Beginner Guides | | | Authentication script to authenticate users in Active Directory through LDAP. Categories : LDAP, Authentication, Cookies, PHP | | | cookie Categories : Cookies, PHP | | | Example voting script. Lets people enter suggestions and vote for existing ones. Categories : MySQL, PHP, Cookies, Complete Programs, Databases | | | Function that allows a Javascript cookie to be set after HTML has been outputted to the page.
Categories : PHP, Java Script, Cookies, HTML and PHP | | | The Best Authorize Categories : PHP, MySQL, Cookies | | | Secure Login Categories : PHP, MySQL, Cookies, Security | | | Simple Cookie example Categories : PHP, Beginner Guides, Cookies | | | With this class you can use cookies with chips Categories : PHP, Cookies | | | Query2Report : Generating Html, Pdf and Csv Reports from SQL Query Categories : PHP, PHP, HTML, PDF, Excel | | | How to make sure a that $foo is from a cookie and not from the URI. Categories : PHP, Variables, Global Variables, Cookies | | | Function that does language negotiation based on the Accept-Language header, a cookie or host name Categories : HTTP, PHP, Cookies | | | Cross Browser Session Starter Categories : PHP, Sessions, Cookies | | | Store, retrieve and delete cookies using JavaScript. Categories : Java Script, Cookies, Beginner Guides, Cookies | |
|
|
|