FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » classes in PHP
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: classes in PHP [message #180274 is a reply to message #180271] Sun, 03 February 2013 17:49 Go to previous messageGo to previous message
Rita Ferreira is currently offline  Rita Ferreira
Messages: 4
Registered: February 2013
Karma:
Junior Member
Hi,
thanks for reply.
The error I'm obtained is:

Fatal error: Class 'config' not found in /Applications/MAMP/htdocs/admin_classes/UserController.php on line 10

UserController.php

<?php

error_reporting(E_ALL);
ini_set('display_errors', '1');

class UserController
{

private $obj;

function __construct( ){}

public function login()
{
if($_SERVER["REQUEST_METHOD"] == "POST")
{
$obj=new config();
$obj->conectar();
}
(..)
}
}

config.php

<?php

private $url_db;
private $login_db;
private $pass_db;
private $db;

class config
{

function __construct( )
{
session_start();
$url_db="localhost";
$login_db="root";
$pass_db="root";
$db="colmeia";
}

private function conectar()
{
mysql_connect($this->$url_db, $this->$login_db, $this->$pass_db);
mysql_select_db($this->$db);
}
(..)
}

config.php is the file where I have all my queries/operations in DB.

Can you help me?
thanks

Domingo, 3 de Fevereiro de 2013 17:04:14 UTC, Rita Ferreira escreveu:
> Hi,
>
> I'm new working with classes in PHP.
>
>
>
> I'm trying to make login, and I have a form in html which the action I would like to go to the login function located in a class file called UserControler.php.
>
> My form is in a php file but is not inside a class. I can't call the login function, it always give me error, so I tried to call a file called process.php file where there I call the login function, but it gives me error:
>
>
>
> It's something like this:
>
>
>
> form.php
>
>
>
> <form action="../process.php" method="post">
>
> (..)
>
>
>
> process.php
>
>
>
> <?php
>
> require("UserController.php");
>
>
>
> $a=new UserController;
>
> $a->login();
>
> ?>
>
>
>
>
>
> UserController.php
>
> <?php
>
>
>
> public class UserController
>
> {
>
>
>
> private $obj;
>
>
>
> function __construct( ){ }
>
>
>
> public function login()
>
> {}
>
> (..)
>
> }
>
>
>
>
>
> Does anybody can tell me why my code only works until the "$a->login();" in process.php? Is anything wrong?
>
>
>
> thanks for help!
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: change a string where have number after a word
Next Topic: Problem with readdir and ssh2
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Fri Nov 22 17:36:39 GMT 2024

Total time taken to generate the page: 0.04270 seconds