This is my setup.
I have a html registration form, when a user has typed in an username, email etc. The information is sent like this:
var processFile = "../inc/ajax.inc.php";
$("#register").change(function(){
var postdata = $("#register").serialize();
$.ajax({
type: "POST",
url: processFile,
data: "action=reg_validation&" + postdata ,
success: function(data){
}
});
console.log("action=reg_validation&" + postdata);
});
This prints for example:
action=reg_validation&u=user&p=123&p2=&e=&r=
My ajax.inc.php file:
/*
* Create a lookup array for form actions
*/
$actions = array(
'reg_validation' => array(
'object' => 'Intro',
'method' => 'check_reg_form'
)
);
if ( isset($actions[$_POST['action']]) )
{
$use_array = $actions[$_POST['action']];
$obj = new $use_array['object'];
echo $obj->$use_array['method'];
}
function __autoload($class_name)
{
$filename = '../../sys/class/class.'
. strtolower($class_name) . '.inc.php';
if ( file_exists($filename) )
{
include_once $filename;
}
}
This code is supposed to call a class called Intro
and a function called check_reg_form
in class.intro.inc.php
. This works almost.
If I start my class.intro.inc.php
with:
echo "test 1";
exit();
I get test 1
in response, but this does not work:
class Intro
{
public function check_reg_form()
{
echo "test 2";
}
}
Not sure why this doesn't work... I get a blank response when I should get test 2
..