JustStatic JustStatic - 6 months ago 10
PHP Question

PHP form not working in Internet Explorer

I created this contact form, it works perfectly in firefox and chrome but in internet explorer it wont allow you to input text (clicking on the form fields does nothing) the submit button works but only sends a blank message because no text can be entered. Also when you press submit it tries to open mail.php in a firefox page, i am only testing locally on my pc could this be the issue?

PHP is this :

<?php
$name = $_POST['name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$message = $_POST['message'];
$formcontent="This message has been generated from the Contact page \n Name: $name \n Phone: $phone \n Email: $email \n Message: $message";
$recipient = "myemail@myemail.co.uk";
$subject = "Enquiry From contact page";
$mailheader = "From: $email \r\n";
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
header('Location: ../contact2.html');
?>


HTML is:

<form id="form1" action="PHP/mail.php" method="post">
<label>Name <span class="small">Add your name</span></label>
<input type="text" name="name"><br>
<label>Email <span class="small">Enter a Valid Email</span></label>
<input type="text" name="email"><br>
<label>Phone <span class="small">Add a Phone Number</span></label>
<input type="text" name="phone"><br>

<br>
<br>

<label>Message <span class="small">Type Your Message</span></label>
<textarea name="message" rows="6" cols="25">
</textarea><br>
<button type="submit" value="Send" style="margin-top:15px;">Submit</button>
<div class="spacer"></div>
</form>

Answer

Based on purely on the form you have I was able to enter text in the form in Chrome, FireFox and IE8.

Take your html form code and place it in an independent file HTML file and test in IE to see if you get the same behavior.

Testing an HTML file will narrow the problem down to just checking the browser removing other variables like your PHP server or javascript.

-If you get the same issue: it is a IE issue independent to that PC.

-If you do not get the same issue: it may be a problem with your php configuration or javascript.

            <form id="form1" action="PHP/mail.php" method="post">
                <label>Name <span class="small">Add your name</span></label> <input type="text" name="name" /><br />
                <label>Email <span class="small">Enter a Valid Email</span></label> <input type="text" name="email" /><br />
                <label>Phone <span class="small">Add a Phone Number</span></label> <input type="text" name="phone" /><br />
                <br>
                <br>
                <label>Message <span class="small">Type Your Message</span></label> 
                <textarea name="message" rows="6" cols="25">
                </textarea><br>
                <button type="submit" value="Send" style="margin-top:15px;">Submit</button>
                <div class="spacer"></div>
            </form>