<?
if(isset($_POST[b1]))
{
    $m= new myclass();
    $x=$m -> validlogin($_POST[t1],$_POST[t2])
#   if ($x== true) #
    {
        $_SESSION[username]=$_POST[t1];
        ?>
        <? include ("menu.php");?>
         <script type="text/javascript">

        window.location = "cpanel.php";
        </script>
     <?

     }

     else {
     echo "invaild login";

     }
}

?>

        }
    }
?>
Member Avatar
LastMitch

Parse error: syntax error, unexpected T_IF in E:\AppServ\www\society\myadmi

Which line? You have to explain what error you are having.

if ($x== true) in line 6

I tried to find fault but I can not
I'm new in php

Member Avatar
LastMitch
if ($x== true) in line 6

Why did you put a # on that line? Take out the #.

I tried to find fault but I can not I'm new in php

Why did you click solve so soon?

Was that the only error you have or you have others?

Are you connected to the database?

It's not good to write the code like this:

<?php
if(isset($_POST[b1])){
$m= new myclass();
$x=$m -> validlogin($_POST[t1],$_POST[t2])
if ($x == true){
$_SESSION[username]=$_POST[t1];
?>

<?php include ("menu.php");?>

<script type="text/javascript"> 
window.location = "cpanel.php";
</script>
<?php }else {
echo "invaild login";
}}?>
}}
?>

Try this:

<?php
include ("menu.php");

if(isset($_POST[b1])){
$m= new myclass();
$x=$m -> validlogin($_POST[t1],$_POST[t2]);

if ($x == true){
$_SESSION[username]=$_POST[t1];

echo '<script type="text/javascript"> 
window.location = "cpanel.php";
</script>';

}else {
echo "invaild login";
}}
?>

I got no idea what other errors you got.