I am having a problem with a form posting correctly to a .php file consistently. I am running a test server on Windows XP, SP3 - I have Apache 2.2 - PHP 5.3.3 & MySQL 5.1.51 and running Firefox 3.6.3
I have a html file has the following code:
test.html
<form method="post" action="testvariable.php">
<p>First Name: <input type="text" name="firstname" id="firstname"/></>
<p>Last Name: <input type="text" name="lastname" id="lastname/></p>
<input type="submit" value="Submit"/>
This post to a php file, testvariable.php The code I have for this page is:
<?php
$firstname = $_POST['firstname'];
$lastname = $_POST['lastname'];
echo 'Welcome to our website, .
htmlspecialchars($firstname, ENT_QUOTES, 'UTF-8') .
htmlspecialchars($lastname, ENT_QUOTES, 'UTF-8') . '!';
?>
My problem is that it will work sometimes and other times it will not. The output page basically takes the input and outputs “Welcome to our website, firstname lastname!”
When it doesn’t work it sometimes will send firefox into offline mode and not load the php page. I put in back into online mode and refresh and it will bring up the page.
Sometimes the php page will say their is an “undefined index” for the firstname and lastname variables.
Finally, the form page seems to retain all entries made into firstname and lastname. How do I have it clear any previous entries and not show them in a drop down box?
Thx.