在php页面上的xss攻击

In my security course teacher gave us a challenge to do so that we can practice with xss on a dummy website. This website is composed by 2 php pages. The first is called xss.php, and this is the code

<html>
<head>
<title>Equations</title>
</head>
<body>
<center>

<?php

if (isset($_POST['result'])){
$result = $_POST['result'];

if (intval($result) == 1){
    echo "<h1>Ok, you are able to solve simple equations </h1><br>";
}

if (intval($result) == 0) {
    header("Location: error.php?error=Type numbers!");
}

if (intval($result) != 1){
    echo "<h1>Wrong result! Try again.</h1>";
}
}

else { ?>

<h1>Can you solve equations?</h1>
<h2>x^2 - 2*x + 1</h2>
<form method=POST action="xss.php"> 
    <table>
    <tr> <td>x:</td> <td><input type=text name=result></td> </tr>
    </table>
    <input type=submit value=Submit />
    </form>
 </center>
</body>
</html>

<?php }
?>

the second is error.php, and it's this:

<html>
<head>
    <title>Error</title>
</head>
<body>
   <center>
      <h1>Error: <?php echo $_GET["error"]; ?></h1>
   <center>
</body>
</html>

the request is to redirect someone to another website (I'll call it "http://whatever.com/" ). When I start the challenge I'm in xss.php and the only thing I can do is writing something in the input form (the one with name=result). What can I write?? Thank you

You can pass by "error" GET variable a javascript code to redirect the page for whatever you want. To do it,you'll access

error.php?error=<script>window.location.href="http://youpageurl.com";</script>

Then you have to be redirected to "yourpageurl.com" website

An XSS attack is one in which the page allows allows users to inject script blocks into the rendered HTML. So, first you must figure out how to do that. For instance, if the input from the user gets displayed on the page and it isn't html escaped then a user could do the following:

User enters :

<script>alert('testing');</script>

Following that, if when when viewing the page an alert is shown then the page is vulnerable to XSS.

Therefore if the user enters JavaScript as follows:

<script>window.location.href = "http://www.whatever.com";</script>

The user would be redirected.