pythonic pythonic - 1 year ago 44
HTML Question

PHP complains that variables are undefined

So, I have the following code. When I execute it, the start_exp.php page complains that variables YourEMail and InputFile are undefined. Apparently, the code seems right. Any idea what mistake am I doing here?


<meta charset="utf-8">
<title>Start page</title>

<link href="styles/style.css" rel="stylesheet" type="text/css">

<body style="height: 100vh; width: 100vw">
<h1>Start page</h1>
<form action="start_exp.php" method=post>
Your e-mail: <br> <input type="text" name="YourEMail">
<br /> Input file name: <br /> <input type="text" name="InputFile">
<input type="submit" name="submit" value="Start experiment">



<title>Start experiment</title>

// Capture the values posted to this php program from the text fields
// which were named 'YourEMail' and 'InputFile' respectively
$YourName = $_REQUEST['YourEMail'] ;
$FavoriteWord = $_REQUEST['InputFile'] ;

<body bgcolor="#FFFFFF" text="#000000">
<p> Hi <?php print $YourEMail; ?>
<p> <b> <?php print $InputFile; ?></b>
<p>The experiment has been started. You'll receive an e-mail when it is finished.


Answer Source

You should echo the variable names not Input field names.

<p> Hi <?php print $YourName; ?> 
<p> <b> <?php print $FavoriteWord; ?></b>