I am looking for help about a basic problem. I would like to write a .php script, what generates a HTML form, and when the form is submited, then the same .php script gets the form paramter, do the operation.
This is code I have so far, but it is not working:
<?php
echo "<html>";
echo "<head>";
echo "<title>This is a test</title>";
echo "</head>";
echo "<body>";
echo "<form name='input' action='phptest1.php' method='get'>";
echo "Type the folder name: <input type='text' name='foldername[]'>";
echo "<input type='submit' value='OK'>";
echo "</form>";
echo "</form>";
echo "</body>";
$folder_var = $_POST['foldername'];
if(empty($folder_var))
{
echo("No folder name was specified.");
exit();
}
echo "Folder name is : " . $folder_var[0];
?>
My goal is put a separate html file and a php file together, where the php file is generating the html form, and the same php script interpreters it.
a1.html:
<html>
<head>
<title>This is a test</title>
</head>
<body>
<form name="input" action="a2.php" method="post">
Type the folder name: <input type="text" name="foldername">
<input type="submit" value="OK">
</form>
</body>
a2.php
<?php
$folder_var = $_POST['foldername'];
if(empty($folder_var))
{
echo("No folder name was specified.");
exit();
}
echo "Folder name is : " . $folder_var;
?>
For a start Change
to