1

The HTML page

<form action="test2.php" method="post">
Name: <input type="text" name="name"><br>
<input type="submit">
</form>

and the test2.php

<?php
$firstname = $_POST['name'];
print("Name $firstname");
?>

and it shows error

Notice: Undefined index: firstname in test2.php on line 7

This is a problem when i run it on my PHPstorm. PHP i am using is v7.1.3

I don't know whats wrong.

INSERTING PICS

HTML File PHP File

This was using XAMPP and still same results

ABHINAV RANA
  • 67
  • 1
  • 10

1 Answers1

0

Check your variable defined or not in following method

if (isset($_POST['name']) && !empty($_POST['name'])) {
    $firstname = $_POST['name'];
   echo "Name ".$firstname;    
}
Karthik
  • 5,589
  • 18
  • 46
  • 78