Jump to content

Multiple forms, different PHP documents, same page?


woolyg

Recommended Posts

Hi all,

 

In a PHP file 'main.php' I have

 

<?php
include 'header.php';
include 'login.php';
include 'body.php';
include 'footer.php';
?>

 

Login.php has a form on it to allow the user to log in to the site.

 

Body.php has a form on it to allow a user to post a message.

 

What I'm finding is that the 'submit' button on 'body.php' actually calls the form from 'login.php'. Does PHP have issues when there are 2 separate forms doing 2 saperate things displayed on the same page - is there anything I need to look out for?

 

Any observations appreciated.

- woolyg.

<?php
include "header.php";

$act = $_GET['act'];

switch($act){
   case login:
   include "login.php";
   break;

   case body:
   include "body.php";
   break;

   default:
   include "no_action.php";
}

include "footer.php";
?>

Um, your submit button needs a different " name="..." ".

 

You can use a hidden html form field to check if that form was the one submitted!

 

As a recommendation, the login script should use the name for the submit button as "login" or something. It will mess up your future php coding!

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.