Hi,
I’m trying to modify the code below to use. Basically, it’s a simple form a user is required to fill-out. When the form is filled and submitted a button will appear, if the form is not filled or submitted a text reading “Fill the form” will show. I need help with the button showing part I was hoping someone here could help out. My knowledge of PHP is below basic.
The HTML Form
<form action="result.php" method="post" class="niceform">
<fieldset>
<legend>Pet's Information</legend>
<dl>
<dt><label for="name">Name:</label></dt>
<dd><input type="text" name="name" id="name" size="32" maxlength="128" /></dd>
</dl>
<dl>
<dt><label for="location">Location:</label></dt>
<dd><input type="location" name="location" id="location" size="32" maxlength="32" /></dd>
</dl>
</fieldset>
<fieldset class="action">
<input type="submit" name="submit" id="submit" value="Submit" />
</fieldset>
</form>
The PHP Code
<?php
if(isset($_POST['submit']))
{
if($_POST['name'] && $_POST['location'])
{
$file = fopen("black_listed_words.txt", 'r');
if($file)
{
$blacklisted_array = explode(",",fgets($file));
$input = $_POST['name'].' '.$_POST['location'];
$input_words = explode(" ", $input);
$result = array_intersect($blacklisted_array, $input_words);
if($result)
{
echo 'you have entered a blacklisted word.';
}
else
{
fclose($file);
$file2 = fopen("input_info.txt", 'a');
$input_info = "$input\\r\
";
fwrite($file2, $input_info);
fclose($file2);
echo 'Login successful. Click here to continue <form action=""><input type="submit" value="Enter" /></form>';
}
}
else
{
echo 'No such file exists.';
}
}
else
{
echo 'Please fill in both fields before submitting the form.';
}
}
?>
When a user successfully submits the form above a button will appear here linking to an external page. On the external page are some basic text with something basic like
This is the result for <strong><?php echo $_GET["name"]; ?> located in <strong><?php echo $_GET["location"]; ?></strong>