-1
<html>
<head>
</head>
<body>
<form action="TakeTwo.php" method="post">
   <input type="text" name="trail" placeholder="Enter Test Here">
   <input type="submit" name="Submit">
</form>
<?php
if (isset($_POST['Submit'])) {

   $k = $_POST['trial'];

   echo $k;
}
?>
</body>
</html>

for some reason it gives me a error that says this:

Notice: Undefined index: trial in C:\xampp\htdocs\KyleLongrich.com\TakeTwo.php on line 18

Any help would be awesome. Also line 18 is referring to to echo $k;

Ali Zia
  • 3,825
  • 5
  • 29
  • 77

4 Answers4

2

Spelling mistake (Trail instead of trial). Check this.

<html>  
<form action="TakeTwo.php" method="post">
    <input type="text" name="trail" placeholder="Enter Test Here">
    <input type="submit" name="Submit">


<?php

if(isset($_POST['Submit']))
{

$k = $_POST['trail'];

echo $k;

}

?>
Maha Dev
  • 3,915
  • 2
  • 31
  • 50
1

You have spell mistake for trial in your form.

Replace this :

<input type="text" name="trail" placeholder="Enter Test Here">

With this :

<input type="text" name="trial" placeholder="Enter Test Here">
Mr. Engineer
  • 3,522
  • 4
  • 17
  • 34
0

1.

  action = "TakeTwo.php" change to <?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>

2.

  if(isset($_POST['Submit'])) to 
  if (!empty($_POST))

This will work well.

li bing zhao
  • 1,388
  • 13
  • 12
0

There is a spelling error.

Replace this

<input type="text" name="trail" placeholder="Enter Test Here">

By this

<input type="text" name="trial" placeholder="Enter Test Here">
Ali Zia
  • 3,825
  • 5
  • 29
  • 77