first steps in OOP

General discussions related to php

Moderators: macek, egami, gesf

New php-forum User
New php-forum User
Posts: 3
Joined: Wed Oct 03, 2012 7:07 am

first steps in OOP

Postby Iago » Sat Nov 03, 2012 2:07 pm

Hello, I've just begun with OOP in PHP and things are of course not easier than before!
So I'am about to write a class for an encryption application with mcrypt().
So my first method is just about the validation of the submitted values from a HTML-Formular of my index.php-page.
The funny thing is that when I call the method fetch_data() it affects my CSS-code of the index.php-File.
Does anybody know why is this? Thanks a lot!
Here are the files:


Code: Select all

class MyCrypt{

    private $error = array();
    private $data = array();

    public function fetch_data($data,$error){


        if(!isset($_POST['txt_file']) && empty($_POST['txt_file'])) {
           $error[] = "Please enter the name of your textfile.";
        if(!empty($_POST['passwd']) && !empty($_POST['passwdvalid']) &&
            ($_POST['passwd'] != $_POST['passwdvalid']))      {
            $error[] = "The passwords do not coincide";
        elseif(!isset($_POST['passwd']) && empty($_POST['passwd'])) {
           $error[] = "Please enter a password.";

        elseif(!isset($_POST['passwdvalid']) && empty($_POST['passwdvalid'])) {
           $error[] = "Please repete the password.";


      $data[] = $_POST['txt_file'];
      $data[] = $_POST['passwd'];


      $this->error = $error;
     return $error;





Code: Select all


include "lib/crypt_lib.php";
$crt = new MyCrypt;


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="" xml:lang="de" lang="de">


    <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" />
    <meta name="description" content="" />
    <meta name="author" content="" />
    <meta name="keywords" content="" />
    <meta name="generator" content="Webocton - Scriptly (" />

   <link rel="stylesheet" href="../registrierung/css/main.css" type="text/css"/>
    <link href="favicon.ico" type="image/x-icon" rel="shortcut icon" />


 <div id="wrapper">
  <div id="left_column">
  <div id="right_column">

    <form name="" action="#" method="POST" enctype="text/html">

   <div style="margin-left:30px;"><h3>Generate Textfile:</h3> </div>

     <table cellspacing="0">

     <tr class="required">
    <th scope="row">Name of the text file:</th>
    <td> <input name="txt_file" type="text" size="15" maxlength="30"/></td>

   </table><br/><br />

   <div style="margin-left:30px;"><h3>password:</h3> </div>

     <table cellspacing="0">

     <tr class="required">
    <th scope="row">password:</th>
    <td> <input name="passwd" type="text" size="15" maxlength="30"/></td>
     <tr class="required">
    <th scope="row">Please confirm password:</th>
    <td> <input name="passwdvalid" type="text" size="15" maxlength="30"/></td>


    <div style="margin-left: 200px; margin-top: 0px;">
    <input type="submit" name="output" value="send"/></div>
    <br/><div style="font-size: 0.8em; margin-left:20px;"><b><?php foreach($crt->error as $v){
        echo $v.'br/'; }  ?></b></div>



Return to “PHP General”

Who is online

Users browsing this forum: No registered users and 2 guests