Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <!--
- To change this license header, choose License Headers in Project Properties.
- To change this template file, choose Tools | Templates
- and open the template in the editor.
- -->
- <html>
- <head>
- <meta charset="UTF-8">
- <title></title>
- </head>
- <body>
- <h2> Objektorientert Post data </h2>
- <form action="" method="post">
- <label>Navn</label><input type="text" name="navn"/> <br/>
- <label>Epost</label><input type="text" name="epost"/><br/>
- <input type="submit" name="reg" value="Submit"/>
- </form>
- <?php
- class person {
- private $navn;
- private $epost;
- //Constructor
- public function __construct($navn,$epost){
- $this->navn = $navn;
- $this->epost = $epost;
- }
- //GET SET
- /*
- public function setNavn($navn){
- $this->navn=$navn;
- }
- public function getNavn(){
- return $this->navn;
- }
- public function setEpost($epost){
- $this->epost=$epost;
- }
- public function getEpost(){
- return $this->epost;
- }
- */
- }
- if(isset($_POST['reg'])){
- echo "<h2> Data ut </h2>";
- // Constructor not working.... ?
- $person=new person($_POST['navn'], $_POST['epost']);
- echo $person->navn."<br/>";
- echo $person->epost."<br/>";
- //Get Set (works)
- /*
- $person=new person();
- $person->setNavn( $_POST['navn'] );
- $person->setEpost($_POST['epost']);
- echo $person->getNavn() ."<br/>";
- echo $person->getEpost()."<br/>";
- */
- }
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement