Advertisement
Guest User

Untitled

a guest
May 2nd, 2016
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.09 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <!--
  3. To change this license header, choose License Headers in Project Properties.
  4. To change this template file, choose Tools | Templates
  5. and open the template in the editor.
  6. -->
  7. <html>
  8. <head>
  9. <meta charset="UTF-8">
  10. <title></title>
  11. </head>
  12. <body>
  13. <h2> Objektorientert Post data </h2>
  14. <form action="" method="post">
  15. <label>Navn</label><input type="text" name="navn"/> <br/>
  16. <label>Epost</label><input type="text" name="epost"/><br/>
  17. <input type="submit" name="reg" value="Submit"/>
  18. </form>
  19. <?php
  20.  
  21.  
  22. class person {
  23.  
  24. private $navn;
  25. private $epost;
  26.  
  27. //Constructor
  28. public function __construct($navn,$epost){
  29. $this->navn = $navn;
  30. $this->epost = $epost;
  31. }
  32.  
  33. //GET SET
  34. /*
  35. public function setNavn($navn){
  36. $this->navn=$navn;
  37. }
  38. public function getNavn(){
  39. return $this->navn;
  40. }
  41. public function setEpost($epost){
  42. $this->epost=$epost;
  43. }
  44. public function getEpost(){
  45. return $this->epost;
  46. }
  47. */
  48.  
  49.  
  50.  
  51. }
  52.  
  53. if(isset($_POST['reg'])){
  54.  
  55. echo "<h2> Data ut </h2>";
  56.  
  57. // Constructor not working.... ?
  58.  
  59. $person=new person($_POST['navn'], $_POST['epost']);
  60. echo $person->navn."<br/>";
  61. echo $person->epost."<br/>";
  62.  
  63. //Get Set (works)
  64. /*
  65. $person=new person();
  66. $person->setNavn( $_POST['navn'] );
  67. $person->setEpost($_POST['epost']);
  68. echo $person->getNavn() ."<br/>";
  69. echo $person->getEpost()."<br/>";
  70. */
  71. }
  72.  
  73.  
  74.  
  75.  
  76. ?>
  77. </body>
  78. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement