如何在PHP文件中触发PHP文件的执行

So I have an HTML file that is a basic form. Say

<form method="POST" action="test1.php">
        Name: <input type="text" name="name" id="name" />
        <input type="submit" value="Submit" />
    </form>

Now I have that execute my test1.php file which goes as follows:

<?php
$name = $_POST['name'];
?>

So all it is doing is getting the value from the HTML form. Now I have a second PHP file test2.php that needs to get the value from the first test1.php file $name and output it via an echo statement.

I'm new to PHP and am fine with using one PHP file to output values from an HTML form, but I don't know how to approach a second one.

I'm aware that you can use the include statement to carry over the variables and their values, but it didn't seem to work in my instance. I'm almost positive the issue is that I don't have test2.php actually being executed. And I don't know how to approach that. Any help is appreciated.

EDIT: This is all I want test2.php to do. $name has to be the same value as retrieved from the HTML form in test1.php

    <?php
    echo $name;
    ?>

Just use include your file test2.php inside test1.php:

<?php
    $name = $_POST['name'];
    include('test2.php');
?>

Whenever you include a file using either include() or require(), the file always gets "executed", so maybe there's something else wrong in you code.

EDIT

test1.php:

<?php
    $name = $_POST['name'];
    include('test2.php');
?>

test2.php:

<?php
    echo $name;
?>

I would suggest starting a session in test1, assign the var $name to the session and then picking the session up on test2.

 test1.php
  session_start();
  $name = filter_var($_POST['name'],FILTER_SANITIZE_STRING);
  $_SESSION['test1']['name'] = $name;


 test2.php
  session_start();
  $name = $_SESSION['test1']['name'];

Try that.

@bloodyKnuckles, Your assignment was left open ended because there are a number of ways you can accomplish what you're looking to do.

 include('test2.php');

Is one option. Another would be

 header("Location: test2.php");
 exit();

Using the header option, $_SESSION variable would work. If test1.php had any HTML output, you could consider an AJAX call or urlencode() your string.

 test1.php
 echo '<a href="test2.php?name=', urlencode($name), '">Click Me</a>';

 test2.php
 $name = $_GET['name'];

I'm guessing your assignment task was designed to demonstrate various ways to pass values from script to script. Good Luck