Question

I have a page calledemp.php in which i have the following code

 <form action="emp-action" method="post" enctype="multipart/form-data">
          include("conn.php");                 

 $sud=$_SESSION['login_user'];

            $sqlc=mysql_query("SELECT * FROM emp where un='".$sud."' ");

            $countc=mysql_num_rows($sqlc);
            if($countc<99)
            {

         include("inc-profile.php");
            }
            else
            {
            echo "SORRY !!!!you have posted more than 100 jobs"; 

            } 

</form>

now this is working properly and navigates to inc-profile page according to condition

in inc-profile.php page I have

<form action="include-action" method="post" enctype="multipart/form-data">

//some codes

 </form>

But form action is not nvigating toinclude-action.php page but navigating emp-action.phppage ..What might be the error PLZ NOT I HAVE REMOVED .PHP WITH HELP OF .HTACCES

Était-ce utile?

La solution

You have one form inside another form.

This is forbidden by the HTML specification and causes undesirable results.

Don't nest forms.

Autres conseils

as per your code you have 2 forms like this

<form action="emp-action" method="post" enctype="multipart/form-data">
      <form action="include-action" method="post" enctype="multipart/form-data">
      </form>
</form>

so when you submit the the first Form action will be initiated. please do like below

<form action="emp-action" method="post" enctype="multipart/form-data">


</form>
  include("conn.php");                 

 $sud=$_SESSION['login_user'];

            $sqlc=mysql_query("SELECT * FROM emp where un='".$sud."' ");

            $countc=mysql_num_rows($sqlc);
            if($countc<99)
            {

         include("inc-profile.php");
            }
            else
            {
            echo "SORRY !!!!you have posted more than 100 jobs"; 

            } 

There are more than one problems in your code. As D.Kasipovic said you have to use session_start().

But you have also to differentiate html from php for example with php tag <?php ?>

like this

 <form action="emp-action" method="post" enctype="multipart/form-data">
<?php
       include("conn.php");                 

        $sud=$_SESSION['login_user'];

        $sqlc=mysql_query("SELECT * FROM emp where un='".$sud."' ");

        $countc=mysql_num_rows($sqlc);
        if($countc<99)
        {

     include("inc-profile.php");
        }
        else
        {
        echo "SORRY !!!!you have posted more than 100 jobs"; 

        } ?>
</form>
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top