Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9080665
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T20:07:32+00:00 2026-06-16T20:07:32+00:00

Here’s my problem: I have two forms on the same page. The first form

  • 0

Here’s my problem:
I have two forms on the same page.
The first form works fine.
But whenever I click the submit button on the second form, I get two notices.
The first says “undefined index: email” which is referring to “$email = $_POST[“email”];” in my coding.
The second says “undefined index: password” which is referring to “$password = $_POST[“password”];” in my coding.
I do not want my 2nd form to be affected by all the “if statements” I created for the first form. And I’m going to be creating more “if statements” for the 2nd form soon.
For example, when I hit the submit button on the second form, it’s echoing “You need to enter an email and password” which is an error I only wanted applied to the first form.

So MY QUESTION IS: How can I get the forms to only be affected by a specific group of “if statements”? Like in css coding you apply ids, but what would i do to the forms or “if statements” so the “if statements” only affect specific forms?

Here’s the coding:

<form action="login.php" method="post">
        <ul id="login">
            //login information
            <li id="loginn">
                <input type="submit" value="Log in">
            </li>
        </ul>
</form>

 <form action="" method="post"> 
        <ul id="register">
                     //register info list items
                             <li>
                <input type="submit" value="Sign up">
            </li>
        </ul>
</form>

<?php

if (empty($_POST) === false) {
$email = $_POST["email"];
$password = $_POST["password"];

if (empty($email) === true || empty($password) === true) {
    $errors[] = "You need to enter an email and password.";
} else if (user_exists($email) === false) {
    $errors[] = "The email you entered is not in our records. Have you registered?";
} else if (user_active($email) === false) {
    $errors[] = "Go to your email, open the email we sent you,and activate your account.";
} else {$login = login($email, $password);
    if ($login === false) {
        $errors[] = "That email/password combination is incorrect.";
    } else {
        $_SESSION['users_id'] = $login;
        header('Location: homepage.php');
        exit();
    }
}

} 

if (empty($errors) === false) {

?>

<?php
echo output_errors($errors);
}
?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T20:07:33+00:00Added an answer on June 16, 2026 at 8:07 pm

    You could add a <hidden> form field with the form’s name:

      <input type="hidden" name="formname" value="form1">
    

    Then, in the PHP, use that to discern the forms:

      if ($_POST['formname'] == "form1") {
          // ifs for first form
      }
    

    (Note there is no error checking whatsoever in this code!)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here's the code I have. It works. The only problem is that the first
Here is my problem.. I have the option to create(add) two new input fields,
Here's the problem....I have three components...A Page that contains a User Control and a
Here is my problem: I have a chatapplication and the messages are displayed in
Here's my problem I have this javascript if (exchRate != ) { function roundthecon()
Here's the setup - I have a view that lists products. On that same
Here is my scenario. I have a website running under AppPool1 and that works
Here the scenario is I have many .aspx pages if any page gives error,
Here is the field declaration in a form: max_number = forms.ChoiceField(widget = forms.Select(), choices
Here is the code in a function I'm trying to revise. This example works

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.