Jump to content

using function


Yohanne

Recommended Posts

i need to login but first here is my code.

 

Class_login.php 

class Class_login 
	{
		
	public function get_post()
		{
					
		$Message = array();
							
		if(empty($_POST['VAR1']))
			{
			$Message = 'Please fill-in required field';
			}
		else
			{
			$_POST['VAR1'] = mysql_real_escape_string($_POST['VAR1']);
			}
								
							
		if(sizeof($Message) > 0)
			{
			$array_lenght = count($Message);
										
				for($i = 0; $i < $array_lenght; $i++)
					{
					echo $Message[$i];
					echo "</br>";
					}
								}
							else
								{
									header('Location:saa.php');
								}
							return false
						}
			
	}

login.php

<?php
	
			function __autoload($classname) 
				{
					$filename = "./../Class/". $classname .".php";
					include_once($filename);
				}
					$newClass = new Class_login();
					
	
			public function actionLogin()
				{
					if(isset($_POST['submit']) && 'Login' == $_POST['submit'])
						{
								????#########?
						}
					else
						{
							false;
						}
				}
		

?>

now, how do i call the function "get_post" from Class_login, and i want it to use inside the login.php. 

 

Thanks

Link to comment
Share on other sites

Pretty straight forward to call the function:

 

$classLogin = new Class_login();
 
$classLogin->getpost();

 

Also make sure that you actually include the Class_login.php file, otherwise PHP won't know where Class_login is defined.

 

Denno

Link to comment
Share on other sites

If you've got an autoloader, then you'll probably need to include the namespace so that the autoloader knows which file to include?

 

That's how I've got mine set up.. An autoloader includes files depending on what use statements are at the top of file.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.