Jump to content

Multiple forms, different PHP documents, same page?


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!

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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