wesley Posted October 23, 2015 Share Posted October 23, 2015 Hello, I have make a php oop script. The meaning is that when you submit the form that it count. my question is: I must somethig add, but what that the form count? can someone help me? thanks in advance. my code is: class:<?phpclass Teller{ public $counter=1; public function ophogen() { $this->counter++; }}?>index.php:<?phpsession_start();require_once ("class.php");if(!isset($_SESSION['counter'])) { $_SESSION['counter'] = 0; }if(isset($_POST['button'])) { ++$_SESSION['counter']; } ?><!DOCTYPE HTML><html lang="en"><head> <title></title> </head><body><form method="POST"> <input type="hidden" name="counter" value="<?php echo $_SESSION['counter']; ?>" /> <input type="submit" name="button" value="count" /> <br/><?php echo $_SESSION['counter']; ?></form></body></html> Link to comment Share on other sites More sharing options...
justsomeguy Posted October 23, 2015 Share Posted October 23, 2015 What's the point of using a class for that? It only takes a few lines of code to keep a count in the session like you're already doing. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now