0

I have a registration form on my website that i can fill out then it shoots over to another.php file. i can echo all of the data except for the first name, last name, and phone number. it gives me an error that says:

Notice: Undefined index: Phone Number in C:\xampp\htdocs\Week 1\sql data.php on line 15

Image of output php file.

Here is the code im using for the form

<!DOCTYPE HTML>
<html>  
<body>



</ul>

</nav>

<div class="container">

<h1 style="color:blue;font-size:40px;">Registration</h1>  

<p style="color:green;font-size:18px;">Please fill in this form to create an account for the Employee Web Portal.</p>  



<form action="sql data.php" method="post">
Id: <input type="text" placeholder="Enter Employee Id" name="Id" required><br>

Email: <input type="text" placeholder="Enter Email" name="Email" required><br>

Password: <input type="text" placeholder="Enter Password" name="Password" required><br>

First Name: <input type="text" placeholder="Enter First Name" name="First Name" required><br>

Last Name: <input type="text" placeholder="Enter Last Name" name="Last Name" required><br>

Address: <input type="text" placeholder="Enter Full Address" name="Address" required><br>

Phone Number: <input type="text" placeholder="Enter Phone Number" name="Phone Number" required><br>

Salary: <input type="text" placeholder="Enter Salary" name="Salary" required><br>

SSN: <input type="text" placeholder="Enter SSN" name="SSN" required><br>

<input type="submit">
</form>

</body>
</html>

Then it goes over to another file called sql data.php and that code is:

<html>
<body>




Your Employee Id is: <?php echo $_POST["Id"]; ?><br>
Your Email is:<?php echo $_POST["Email"]; ?><br>
Your Password is:<?php echo $_POST["Password"]; ?><br>
Your First Name is:<?php echo $_POST["First Name"]; ?><br>


Your Last Name is:<?php echo $_POST["Last Name"]; ?><br>
Your Address is:<?php echo $_POST["Address"]; ?><br>
Your Phone Number is:<?php echo $_POST["Phone Number"]; ?><br>
Your Salary is: <?php echo $_POST["Salary"]; ?><br>
Your SSN is: <?php echo $_POST["SSN"]; ?><br>

</body>
</html>

I am not sure why its saying that the name field is undefined? there is data input in every field and all the other fields come over just fine

user3783243
  • 5,368
  • 5
  • 22
  • 41
  • What does `var_dump($_POST)` show? – Barmar Jun 23 '22 at 19:52
  • `echo $_POST["Id"]` is open to XSS injections. Not sure real planned usage of this but hopefully not like that, and using parameterized queries at minimum. With PII data should be encrypting. – user3783243 Jun 23 '22 at 20:00
  • this is for a school project im working on, its nothing serious or being used by everyday people. However Var_dump($_POST) does nothing. i have removed spaces in between first name anfd last name to be firstname,lastname. I also made sure i have no special charactes in name field and just A-Z – Bray-Dun Abbey Jun 23 '22 at 20:43
  • Do you end up on `sql data.php`? You really should not have these spaces in any attributes, that's likely to cause issues everywhere. If you open developer console does it show a POST request being sent? – user3783243 Jun 23 '22 at 22:07

1 Answers1

1

Just remove the spaces,

First Name: <input type="text" placeholder="Enter First Name" name="FirstName" required><be>

Your First Name is:<?php echo $_POST["FirstName"]; ?><be>

etcetera