Below code i wrote for login and logout functions...but functions are in same class so how can i call those function on submit...help me
<?php
class payment {
function __construct(){
}
public function login_page() { ?>
<html>
<body>
<table width="320px" border="0" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
<tr><td><h3>Welcome To PayPal Site</h3></td><td><img src="paypal2.gif"></img></td></tr>
</table>
<table width="320px" height="50%" border="0" cellpadding="0" cellspacing="1" bgcolor="#555555">
<tr>
<form name="form1" method="post" action="chk_login()">
<td>
<table width="100%" height="50%" border="0" cellpadding="3" cellspacing="1" bgcolor="#666666">
<tr>
<td colspan="3"><strong>Member Login </strong></td>
</tr>
<tr>
<td width="78">Username</td>
<td width="6">:</td>
<td width="294"><input name="myusername" type="text" id="myusername"></td>
</tr>
<tr>
<td>Password</td>
<td>:</td>
<td><input name="mypassword" type="text" id="mypassword"></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td><input type="submit" name="Submit" value="Login"></td>
</tr>
</table>
</td>
</form>
</tr>
</table>
<table width="320px" border="0" align="left" bgcolor="#CCCCCC">
<tr>
<td><img src="paypal1.gif"></img></td>
<td><img src="paypal.gif"></img></td>
<td><img src="paypal3.gif"></img></td>
</tr>
</table>
</body>
</html>
<?php }
public function chk_login() {
ob_start();
$host="localhost"; // Host name
$username="root"; // Mysql username
$password=""; // Mysql password
$db_name="test"; // Database name
$tbl_name="member_info"; // Table name
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
$myusername=$_POST['myusername'];
$mypassword=$_POST['mypassword'];
$sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'";
$result=mysql_query($sql);
$row=mysql_fetch_array($result);
session_start();
$_SESSION['name']=$row['username'];
$_SESSION['email']=$row['email'];
$count=mysql_num_rows($result);
$myusername = stripslashes($_SESSION['name']);
$mypassword = stripslashes($mypassword);
$myusername = mysql_real_escape_string($myusername);
$mypassword = mysql_real_escape_string($mypassword);
if($count==1){
session_register("myusername");
session_register("mypassword");
header("location:login_success();");
} else {
echo "Wrong Username or Password";
header("location:paypal.php");
}
ob_end_flush();
}
public function logout() {
session_start();
session_destroy();
header("location:payment_PayPal.php");
}
public function login_succes() {
session_start();
if(!session_is_registered(myusername)){
header("location:payment_PayPal.php");
} ?>
<html>
<body>
<?php session_start(); ?>
<table width="320px" border="0" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
<tr><td><h3>Welcome <?php echo strtoupper($_SESSION['name']); ?></h3></td></tr>
</table>
<table width="320px" height="50%" border="0" cellpadding="0" cellspacing="1" bgcolor="#555555">
<tr>
<form name="form1" method="post" action="logout();">
<td>
<table width="100%" height="50%" border="0" cellpadding="3" cellspacing="1" bgcolor="#666666">
<tr>
<td colspan="3"><strong>Account Information</strong></td>
</tr>
<tr>
<td width="78">Amount</td>
<td width="6">:</td>
<td width="100">$1000</td>
</tr>
<tr>
<td>Credit Card Number</td>
<td>:</td>
<td>xxxxxxxxxxxx23</td>
</tr>
<tr>
<td>Email Id</td>
<td>:</td>
<td><?php echo $_SESSION['email']; ?></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td><input type="submit" name="Submit" value="Logout"></td>
</tr>
</table>
</td>
</form>
</tr>
</table>
<table width="320px" border="0" align="left" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
<tr>
<td><img src="paypal1.gif"></img></td>
<td><img src="paypal.gif"></img></td>
<td><img src="paypal3.gif"></img></td>
</tr>
</table>
</body>
</html>
<?php }
}
$minit=new payment;
$minit->login_page();