youngdero youngdero - 4 months ago 11
HTML Question

php form submit to itself not working

i have a html form that submit to it self here is the html form

<div class="col-md-6 contact-grid">
<form name="submitted" action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>" method="POST">

<div class="styled-input wow slideInUp animated animated" data-wow-delay=".5s">
<input type="text" id="name" required />
<label>Name</label>
<span></span> </div>
<div class="styled-input wow slideInUp animated animated" data-wow-delay=".5s">
<input type="email" id="email" required />
<label>Email</label>
<span></span> </div>
<div class="styled-input wow slideInUp animated animated" data-wow-delay=".5s">
<input type="tel" id="phone" required />
<label>Phone</label>
<span></span> </div>
<div class="styled-input wide wow slideInUp animated animated" data-wow-delay=".5s">
<textarea id="message" required></textarea>
<label>Message</label>
<span></span> </div>
<div class="send wow shake animated animated" data-wow-delay=".5s">
<input name="submit" type="submit" value="Send">
</div>

</form>
</div>


and below is my php code to processes the form

<?php
session_start();
//error_reporting(0);
if(isset($_POST['submitted'])) {
$sendto = "info@davfubgroup.com";
$usermail = strip_tags($_POST['email']);
$content = nl2br($_POST['message']);
$phone = strip_tags($_POST['phone']);
$name = strip_tags($_POST['name']);

$subject = "New Feedback Message";
$headers = "From: " . strip_tags($usermail) . "\r\n";
$headers .= "Reply-To: ". strip_tags($usermail) . "\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html;charset=utf-8 \r\n";
$msg = "<html><body style='font-family:Arial,sans-serif;'>";
$msg .= "<h2 style='font-weight:bold;border-bottom:1px dotted #ccc;'>New User Feedback</h2>\r\n";
$msg .= "<p><strong>Sent by:</strong> ".$usermail."</p>\r\n";
$msg .= "<p><strong>Message:</strong> ".$content."</p>\r\n";
$msg .= "<p><strong>Name:</strong> ".$name."</p>\r\n";
$msg .= "<p><strong>Phone:</strong> ".$phone."</p>\r\n";
$msg .= "</body></html>";


if(mail($sendto, $subject, $msg, $headers)) {
$_SESSION['errormsg'] = "Mail Sent. Thank you we will contact you shortly.";
echo '<center><p style="color:green">' . $_SESSION['errormsg']. '</p></center>';

} else {
$_SESSION['errormsg'] = "Mail not Sent. Try Again.";
echo '<center><p style="color:red">' . $_SESSION['errormsg'].

'</p></center>';
}
}
?>


but my problem is when the form is submitted no message is display and no error message too any help please

Answer

just change the name of the input to

 <input name="submitted" type="submit" value="Send">

it will work

Comments