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 7553561
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T11:05:39+00:00 2026-05-30T11:05:39+00:00

Possible Duplicate: Undefined Index when using post I’m a beginner php developer and I’m

  • 0

Possible Duplicate:
Undefined Index when using post

I’m a beginner php developer and I’m just playing around with some stuff. I’m trying to create a simple registration form:

registration.php

<?php

include('Auth.php');

$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$email= $_POST['email'];
$password = $_POST['password'];

$auth = new Auth();
$auth->register($first_name, $last_name, $email, $password);

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Registration</title>
</head>
<body>
    <form action="registration.php" method="POST">

        <p> First Name: <input type="text" size="20" name="first_name" id="first_name" value="" /> </p>
        <p> Last Name: <input type="text" size="40" name="last_name" id="last_name" value="" /></p>
        <p> Email: <input type="text" size="60" name="email" id="email" value="" /></p> 
        <p> Password: <input type="password" size="16" name="password" id="password" value="" /></p>

        <input type="submit" value="submit" id="submit"/>
    </form>
</body>
</html>

I get these errors:

Notice: Undefined index: first_name in C:\xampp\htdocs\Store\Store\Controller\Registration.php on line 6

Notice: Undefined index: last_name in C:\xampp\htdocs\Store\Store\Controller\Registration.php on line 7

Notice: Undefined index: email in C:\xampp\htdocs\Store\Controller\Registration.php on line 8

Notice: Undefined index: password in C:\xampp\htdocs\Store\Store\Controller\Registration.php on line 9

I’m guessing it’s because the POST variable has nothing inside it yet because nothing has been submitted. I’ve seen around on the internet where the php processing form and the html form is in the same file as opposed to two separate files like what I’m trying to do. Where the html form refers back to itself. How can I go around this? Is this even good practice when it comes to separation of content and data processing?

I

  • 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-05-30T11:05:40+00:00Added an answer on May 30, 2026 at 11:05 am

    Note that these are just notices, which you should have then enabled in development environment but disabled when your site goes live. If you don’t have access to the php.in file you can do that by using this line of code:

    ini_set( "display_errors", 0);
    

    To your problem now, it is indeed the fact that your variables are empty. You can set a name element into your submit button let’s say
    <input type="submit" value="submit" name="submit" id="submit"/>

    and then:

    if (isset($_POST['submit']))
    {
    
    include('Auth.php');
    
    $first_name = $_POST['first_name'];
    $last_name = $_POST['last_name'];
    $email= $_POST['email'];
    $password = $_POST['password'];
    
    $auth = new Auth();
    $auth->register($first_name, $last_name, $email, $password);
    
    }
    

    That way, you will make sure that this fraction of code will execute only when your specific form is submitted.

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

Sidebar

Related Questions

Possible Duplicate: PHP: Notice: Undefined variable and Notice: Undefined index I am just learning
Possible Duplicate: “Undefined reference to” template class constructor I've just started using templates, and
Possible Duplicate: PHP: Notice: Undefined variable and Notice: Undefined index I am new to
Possible Duplicate: PHP: “Notice: Undefined variable” and “Notice: Undefined index” All of a sudden
Possible Duplicate: PHP: Notice: Undefined variable and Notice: Undefined index In html code: <select
Possible Duplicate: Why am I getting Undefined index from my PHP? $pattern2 = /([A-Za-z0-9\.\-\_\!\#\$\%\&\'\*\+\/\=\?\^\`\{\|\}]+)\@([A-Za-z0-9.-_]+)(\.[A-Za-z]{2,5})/;
Possible Duplicate: How to solve “call to undefined function domxml_new_doc()…” I'm using php5, when
Possible Duplicate: is i=i++ truly a undefined behavior? i just want too explain ++
Possible Duplicate: post and pre increment in c Undefined Behavior and Sequence Points here
Possible Duplicate: Could anyone explain these undefined behaviors (i = i++ + ++i ,

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.