Just want to start of by saying im a total beginner at PHP. I have created a php mail form on one website and the same form on a different folder in the same shared account (shared GoDaddy cPanel).
The form looks like:
<form id="1-form" name="1-form" method="post" action="mail-form.php">
<div class="form-group">
<label for="1-name"> Name </label>
<input type="text" id="1-name" name="1-name" class="form-control name-field" required="required">
</div>
<div class="form-group">
<label for="1-email"> Email </label>
<input type="email" id="1-email" name="1-email" class="form-control name-field" required="required">
</div>
<div class="form-group">
<button id="quote-submit" type="submit" class="btn btn-primary">Send</button>
</div>
</form>
And the mail-form.php file looks like:
<?
$name=$_POST['1-name'];
$Email=$_POST['1-email'];
$body .= "Name: " . $name . "\n";
$body .= "Email: " . $Email . "\n";
mail("example@email.com","New email",$body);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script>alert("Your message has been sent successfully. We will contact you shortly.");</script>
<meta HTTP-EQUIV="REFRESH" content="0; url=../index.php">
</head>
I duplicated these files in two different folders and one of them works fine and the other for some reason shows empty values. In my email it would show up like:
name: email:
I cant pinpoint whats wrong. All help is appreciated. - Thanks