Trying to call my php function from a link
Posted: Sat Aug 28, 2010 9:54 pm
Hi Guys I'm trying to delete a user from sales_peepl Table in my sales Database from a html link.
I have a class called User with has the delete() function and a Output() Function which list's the users and hopefully a delete link that works but mine isn't, and i don't think I'm even close.
OK here is the class
Code: Select all
<?php
session_start();
/**
* This will handle the Users Records
* and handle the login process assigning
* the user varables to the $SESSION
*
*/
class User extends Database
{
/**
* List all the users
* note to self
* add a "where" to the query refering to the id
*
* @param unknown_type $id
*/
public function listing( $id = null )
{
$this->query( "select * from sales_peepl" );
}
/**
* Deletes the user based on the userid
*
* @param unknown_type $id
*/
public function delete( $id )
{
$this->query( "DELETE FROM sales_peepl WHERE salesid = '{$id}';" );
}
/**
* Outputs the listing
*this is where im having trouble
* @return unknown
*/
public function output()
{
return $this->name ."-". $this->user_name . '<a href="?action=delete&id=<?= $this->salesid?>">Delete User</a>';
}
/**
* Checks to see whether the user can be loged in
*
* @param string_type $user_name
* @param string_type $pass_word
* @return $_SESSION[]
*/
public function login($user_name, $pass_word)
{
$this->query( "select * from sales_peepl WHERE user_name = '{$user_name}' AND pass_word = '{$pass_word}';",true );
if($this->next())
{
$_SESSION['user_name'] = $user_name;
$_SESSION['pass_word'] = $pass_word;
$_SESSION['salesid'] = $this->_row->salesid;
$_SESSION['access'] = $this->_row->access;
$_SESSION['name'] = $this->_row->name;
return TRUE;
}
return FALSE;
}
/**
* Logs User Out
*
*/
public function logout()
{
session_destroy();
}
}
?>
And here is the page that it ouputs to
Code: Select all
<?php
include_once($_SERVER['DOCUMENT_ROOT'].'/pete_phone/includes/global.php');
$BB = new User();
$BB->connect(HOST, USERNAME, PASSWORD, DATABASE);
$BB->listing();
?>
<html>
<head></head>
<body>
<?php
while( $BB->next() )
{
echo $BB->output() . " , " ;
}
?>
</body>
</html>
So where am i going wrong?? It's driving me crazy