I am just a beginner with PHP & Html. I have seen many questions on SO related to this, but somehow cannot fix a very simple looking problem at my end. So, kindly help.
The following code does not seem to be working. There is always a message "There seems to be a problem right now. Please try again after sometime" before the form when I run this code. Whether I press the submit button or not, it does not make any difference.
<h2 >Inquiry form</h2>
<?php
if (isset($_POST['submit'])){
echo "Thank You!";
}
else {
echo "There seems to be a problem right now. Please try again after sometime";
}
?>
<form name="input" method="POST" action="contact.php">
<label for="Name">Name (required):</label>
<br />
<input type="text" name="Name" />
<br />
<div class="clear"></div>
<label for="inputmail">Email(required):</label>
<br />
<input type="text" name="email" />
<br />
<div class="clear"></div>
<label for="inputtelefon">Phone:</label>
<br />
<input type="text" name="phone" />
<br />
<div class="clear"></div>
<label for="inputmessage">Message:</label>
<br/>
<textarea name="message" cols="28" rows="3" ></textarea>
<div class="clear"></div>
<div id="send">
<input type="submit" value=" Submit " />
<input type="reset" value=" Clear " />
</div>
</form>
Changed code:
<h2 >Inquiry form</h2>
<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
//if ($_SERVER['REQUEST_METHOD'] == 'POST') { This is not working as well
echo "Thank You!";
}
else {
echo "There seem to be a problem right now. Please try again after sometime";
}
?>
<form name="input" method="POST" action="contact.php">
<label for="Name">Name (required):</label>
<br />
<input type="text" name="Name" />
<br />
<div class="clear"></div>
<label for="inputmail">Email(required):</label>
<br />
<input type="text" name="email" />
<br />
<div class="clear"></div>
<label for="inputtelefon">Phone:</label>
<br />
<input type="text" name="phone" />
<br />
<div class="clear"></div>
<label for="inputmessage">Message:</label>
<br/>
<textarea name="message" cols="28" rows="3" ></textarea>
<div class="clear"></div>
</div>
<div id="send">
<input type="submit" value=" Submit " name="submit"/>
</div>
</form>
tag should not have whitespace.
– eipark Feb 25 '13 at 18:30