WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDESPHP CLASSESCODE SEARCHARTICLES SEARCHPHP FORUMSPHP MANUALPHP FUNCTIONS LISTWEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Join us on FaceBook
Submit a code Example / Snippet Submit Your Code
Poker Tournaments Poker Tournaments
Poker Guide for Developers Poker Guide for Developers
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Resources
Web Development Content
Internet Security Software
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
פרייסז - הכח לקנות עובר לידיים שלך
Texas Holdem Poker Evangelists

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : A cookie based calculator that uses cookies for saving the results.
Categories : PHP, Cookies Click here to Update Your Picture
lalith nayak
Date : Feb 28th 2006
Grade : 1 of 5 (graded 3 times)
Viewed : 3457
File : No file for this code example.
Images : No Images for this code example.
Search : More code by lalith nayak
Action : Grade This Code Example
Tools : My Examples List

Submit your own code examples  Submit your own code examples 
 

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



Smart Counter - This little script is a plain and simple hit counter that uses cookies to determine whether or not the visitor has already been counted.
Categories : Cookies, HTML and PHP, PHP
PHP Cookies - Simple cookie write/read methods that allow basic encryption
Categories : PHP, Cookies, Security, Encryption
Multilingual php webpage
Categories : PHP, Languages, Cookies
This functions makes it easy to use session-variables known from ASP. With one Cookie the array "session" will save and restore from a db-record. In this version MySQL is used but it's should very easy to change
Categories : PHP, Arrays, Cookies, MySQL, Databases
Query2Report : Generating Html, Pdf and Csv Reports from SQL Query
Categories : PHP, PHP, HTML, PDF, Excel
Store, retrieve and delete cookies using JavaScript.
Categories : Java Script, Cookies, Beginner Guides, Cookies
Authentication script to authenticate users in Active Directory through LDAP.
Categories : LDAP, Authentication, Cookies, PHP
Simple PHP cookie counter
Categories : PHP, Cookies, Beginner Guides
How to make sure a that $foo is from a cookie and not from the URI.
Categories : PHP, Variables, Global Variables, Cookies
Make old style (PHP3) scripts using GET, POST, COOKIE and File uploads (POST) compatible with PHP 4.2.0
Categories : PHP, HTML and PHP, Global Variables, Cookies, Variables
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
Complete, simple working example of login screen and check on a unique page using php functions, cookies and mysql database.
Categories : PHP, Cookies, MySQL, HTML and PHP, Authentication
Secure Login
Categories : PHP, MySQL, Cookies, Security
Simple Cookie example
Categories : PHP, Beginner Guides, Cookies