Reputation: 9
I am trying to fetch "Registered user information" on my mail id through the "mail()" function.the mail() function worked fine and is able to send the mail on the mail id, but it can't fetch the user details. Here is my HTML code:
<form action="registration.php" id="reg_form">
<div class="form-msg alert with-icon alert-warning">
<i class="fa fa-info-circle"></i>
<span id="text-login-msg">
Put your valid Emai id and we will mail you the login details on your register id.
</span>
</div>
<div class="row">
<div class="form-group col-md-12">
<label>
Name<span class="red">*</span>
</label>
<input type="text" class="form-control" name="name" required>
</div>
</div>
<div class="row">
<div class="form-group col-md-12">
<label>
Email<span class="red">*</span>
</label>
<input type="email" class="form-control" name="email" required>
</div>
</div>
<div class="clearfix"></div>
<div class="button-group">
<input type="submit" class="btn btn-lg main-bg btn-block" value="Submit">
</div>
</form>
Here is my PhP Code:
$headers = "From: [email protected]";
$to = "[email protected]";
$Email = $_POST['email'];
$Name = $_POST['name'];
$subject = "Registration";
$email_message = "Form details below. \r\n";
$email_message .= "Name: ".$Name. "\r\n";
$email_message .= "Email: ".$Email. "\r\n";
mail ($to, $subject, $email_message, $headers);
header("Location: thank-you.html");
Thanks In Advance.
Upvotes: 0
Views: 79
Reputation: 724
add in your first line method="post"
:
<form action="registration.php" id="reg_form" method="post">
Upvotes: 0
Reputation: 8249
method
is missing in your form. You need to add that. Method defines whether you are sending values as GET or POST.
<form action="registration.php" id="reg_form" method='post'>
Upvotes: 0
Reputation: 6826
You need to specify method="POST"
to your form
, like:
<form action="registration.php" id="reg_form" method="POST">
The default value is "GET". In this case, you can read those inputs as $_GET['name']
and $_GET['email']
.
See this link https://www.w3schools.com/tags/att_form_method.asp
Upvotes: 1