My form submission not working [duplicate] - php

This question already has answers here:
PHP mail function doesn't complete sending of e-mail
(31 answers)
Closed 5 years ago.
HTML Codes
<h3>online consultation</h3>
<h5>We have provided contact information down below. You can contact us either by mobile, via email or via contact form. We will at once contact you to discuss your problems! If you have special requirments a consultation can be decided.</h5>
</div>
<div class="col-md-7 col-lg-offset-3 contact-grid-right">
<form method="post" action="mail.php">
<input type="text" placeholder="Your Name" name="name" id="name" required="required">
<input type="text" placeholder="Email" name="Email" id="Email" required="required">
<input type="text" placeholder="Contact No" name="contact" id="contact" required="required">
<input type="text" placeholder="Subject" name="subject" id="subject" required="required">
<textarea rows="2" cols="70" type="text" placeholder="MESSAGE" name="message" id="message" required="required">
</textarea>
<button type="submit" class="slide-btn"> Send your message <i class="fa fa-paper-plane" aria-hidden="true"></i> <br></button>
</form>
</div>
PHP Script
<?php
$n=$_POST['name'];
$mail=$_POST['email'];
$ph=$_POST['contact'];
$ln=$_POST['subject'];
$msg=$_POST['message'];
$to="email#yahoo.com";
$sub="message";
$body="
<html>
<body>
<p><b></b></p><h4></h4>
<table border='0'>
<tr>
<b>Name : </b> $n <br><br>
<b>Email : </b> $mail <br><br>
<b>Contact :</b> $ph <br><br>
<b>Subject :</b> $ln <br><br>
<hr>
<b>Contact Form Message:</b> <br><br>$msg
</tr>
</table>
</body>
</html>";
$headers = "MIME-Version: 1.0". "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8". "\r\n";
$headers .= 'From:'.$mail . "\r\n";
//$headers .= 'Cc: email#yahoo.com.au'; "\r\n";
//$headers .= 'Bcc: '; "\r\n";
mail($to,$sub,$body,$headers);
//echo "<script>alert('Message Send Sucessfully')</script>";
echo "<script>window.location.href='index.html'</script>";
?>

here the solution change the $mail=$_POST['email']; in your php script to $mail=$_POST['Email'];

For keeping your code standard replace the email html input for:
<input type="text" placeholder="Email" name="email" id="email" required="required">

Related

I have a PHP script to send emails with this code-

I have this PHP code to send emails.
<?php
if (isset($_POST['ajax'])) {
$to = $_POST['to'];
$subject = $_POST['sub'];
$msg = $_POST['msg'];
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
$headers .= "From: ".$_POST['name']."<".$_POST['from'].">";
$send = mail($to,$subject,$msg,$headers);
if ($send) {
echo "<p id='success'>✔️ $to</p>";
}else{
echo "<p id='error'>❌ $to</p>";
}
exit();
}
?>
I want to integrate it with the following form.
<form>
<input id="input-1" type="text" placeholder="John Doe" required autofocus />
<label for="input-1">
<span class="label-text">Full Name</span>
<span class="nav-dot"></span>
<div class="signup-button-trigger">Sign Up</div>
</label>
<input id="input-2" type="text" placeholder="john" required />
<label for="input-2">
<span class="label-text">Username</span>
<span class="nav-dot"></span>
</label>
<input id="input-3" type="email" placeholder="email#address.com" required />
<label for="input-3">
<span class="label-text">Email</span>
<span class="nav-dot"></span>
</label>
<input id="input-4" type="text" placeholder="●●●●●●" required />
<label for="input-4">
<span class="label-text">Password</span>
<span class="nav-dot"></span>
</label>
<input id="input-5" type="text" placeholder="●●●●●●" required />
<label for="input-5">
<span class="label-text">Confirm Password</span>
<span class="nav-dot"></span>
</label>
<button type="submit">Create Your Account</button>
<p class="tip">Press Tab</p>
<div class="signup-button">Sign Up</div>
</form>
Is there a way to make it work. I want to use the PHP GET method. Is this possible? How would I get around doing that?
I want to send a PHP GET request, which would then send the email. Do I have to change anything in the form? In the PHP?

HTML form to PHP mail not working properly [duplicate]

This question already has answers here:
PHP mail function doesn't complete sending of e-mail
(31 answers)
Closed 5 years ago.
I am absolutely bad at PHP programming. I have no experience with it, but I wanted a form on my website with a mail script. So like almost every other person with no experience on a language, I googled up one and customized it.
mail_send.php
<?php
if(isset($_POST['submit'])){
$to = "my#mailadress.com"; // I just did this for privacy
$from = $_POST['email'];
$name = $_POST['name'];
$subject = "Form submission";
$message = $name . " " . $from . " wrote the following:" . "\n\n" .
$_POST['message'];
$headers = "From:" . $from;
mail($to,$subject,$message,$headers);
echo "Mail Sent. Thank you " . $name . ", we will contact you shortly.";
}
?>
and here the HTML code: index.html
<form role="form" id="feedbackForm" class="text-center" action="mail_send.php" method="post">
<div class="form-group">
<label for="name">Naam</label>
<input type="text" class="form-control" id="name" name="name" placeholder="Name">
<span class="help-block" style="display: none;">Voer uw naam in..</span></div>
<div class="form-group">
<label for="email">E-Mail</label>
<input type="email" class="form-control" id="email" name="email" placeholder="Email Address">
<span class="help-block" style="display: none;">Voer een geldig e-mailadres in.</span></div>
<div class="form-group">
<label for="message">Bericht</label>
<textarea rows="10" cols="100" class="form-control" id="message" name="message" placeholder="Message"></textarea>
<span class="help-block" style="display: none;">Voer een bericht in.</span></div>
<button type="submit" id="feedbackSubmit" class="btn btn-primary btn-lg" style=" margin-top: 10px;"> Verstuur</button>
</form>
So I have uploaded both files to my Website Server so I've tested it online, but still without success. Any smart guys being able to help me?
Thanks in advance :)
Please modify button tag
<button type="submit" name="submit" id="feedbackSubmit" class="btn btn-primary btn-lg" style=" margin-top: 10px;"> Verstuur</button>
I suggest to do not use mail function directly. Better use something like https://github.com/PHPMailer/PHPMailer and use it through SMTP of a real e-mail account of yours.
You are checking in your IF clause $_POST['submit'] - But I don't see where did you set this name="submit" in your html code... you need to add name="submit" to your button
Use name = submit in button tag.
<button type="submit" name="submit" id="feedbackSubmit" class="btn btn-primary btn-lg" style=" margin-top: 10px;"> Verstuur</button>
After that also check your spam folder. Sometime you don't get messages in inbox.
Modify as per your requirement and I hope this code will send you message to inbox directly rather than span
<?php
if(isset($_POST['submit'])){
$to = "Email Address Here"; // I just did this for privacy
$from = $_POST['email'];
$name = $_POST['name'];
$subject = "Form submission";
$message = $name." ".$from." wrote the following:". "\n\n". $_POST['message'];
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
$headers .= 'From: <info#example.com>' . "\r\n";
mail($to,$subject,$message,$headers);
echo "Mail Sent. Thank you " . $name . ", we will contact you shortly.";
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Mail Example</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<form role="form" id="feedbackForm" class="text-center" action="" method="post">
<div class="form-group">
<label for="name">Naam</label>
<input type="text" class="form-control" id="name" name="name" placeholder="Name">
<span class="help-block" style="display: none;">Voer uw naam in..</span></div>
<div class="form-group">
<label for="email">E-Mail</label>
<input type="email" class="form-control" id="email" name="email" placeholder="Email Address">
<span class="help-block" style="display: none;">Voer een geldig e-mailadres in.</span></div>
<div class="form-group">
<label for="message">Bericht</label>
<textarea rows="10" cols="100" class="form-control" id="message" name="message" placeholder="Message"></textarea>
<span class="help-block" style="display: none;">Voer een bericht in.</span></div>
<button type="submit" name="submit" id="feedbackSubmit" class="btn btn-primary btn-lg" style=" margin-top: 10px;"> Verstuur</button>
</form>
</body>
</html>

Email PHP form doesn't work [duplicate]

This question already has answers here:
PHP mail function doesn't complete sending of e-mail
(31 answers)
Closed 5 years ago.
I haven't written code in years, so I am going off old code from a project that is over 5 years old, so I am not surprised that it doesn't work; I would like some pointers on how to make it work, please.
Here is what I have in my HTML email form --
<form action="fydcontact.php" method="post">
<div class="form-group">
<!--<label for="contact_name">Name:</label>-->
<input type="text" id="contact_name" class="form-control" placeholder="Name" />
</div>
<div class="form-group">
<!--<label for="contact_email">Email:</label>-->
<input type="text" id="contact_email" class="form-control" placeholder="Email Address" />
</div>
<div class="form-group">
<!--<label for="contact_message">Message:</label>-->
<textarea id="contact_message" class="form-control" rows="9" placeholder="Write a message"></textarea>
</div>
<button type="submit" class="btn btn-primary">Send</button>
</form>
and here is what my PHP looks like --
<?php
if(isset($_POST['send'])) {
// Prepare the email
$to = ''foryourdayformals#gmail.com ';
$name = $_POST['contact_name'];
$mail_from = $_POST['contact_email'];
$subject = 'Message sent from website';
$message = $_POST['contact_message'];
$header = "From: $name <$mail_from>";
// Send it
$sent = mail($to, $subject, $message, $header);
if($sent) {
echo 'Your message has been sent successfully! Return to For Your Day, LLC Website';
} else {
echo 'Sorry, your message could not send. Please use direct email link on Contact Us page (below the map). Return to For Your Day, LLC Website';
}
}
?>
Any help is GREATLY appreciated! Thanks!
update
$to = ''foryourdayformals#gmail.com ';
to
$to = 'foryourdayformals#gmail.com';
and need to add name attribute for form . This update your form
<form action="fydcontact.php" method="post">
<div class="form-group">
<!--<label for="contact_name">Name:</label>-->
<input type="text" id="contact_name" name="contact_name" class="form-control" placeholder="Name" />
</div>
<div class="form-group">
<!--<label for="contact_email">Email:</label>-->
<input type="text" id="contact_email" name="contact_email" class="form-control" placeholder="Email Address" />
</div>
<div class="form-group">
<!--<label for="contact_message">Message:</label>-->
<textarea id="contact_message" name="contact_message" class="form-control" rows="9" placeholder="Write a message"></textarea>
</div>
<button type="submit" class="btn btn-primary" name ="send">Send</button>
</form>

How to popup instead of echo

I have created a contact form using HTML and PHP.
Right now when a user submit the contact form he redirect to a new page with the echo message, instead, I want this message to appears in a small popup window.
HTML Code:
<form action="/assets/bootstrap/php/emailscript.php" method="post">
<input type="text" placeholder="Name" name="Name" oninvalid="setCustomValidity('Please enter your name')"
onchange="try{setCustomValidity('')}catch(e){}" required >
<input type="text" placeholder="Company" name="Company" oninvalid="setCustomValidity('Please enter your Company name')"
onchange="try{setCustomValidity('')}catch(e){}" required >
<input type="text" placeholder="Email" name="Email" required pattern="[a-z0-9._%+-]+#[a-z0-9.-]+\.[a-z]{2,3}$" oninvalid="setCustomValidity('Please enter a valid e-mail address')"
onchange="try{setCustomValidity('')}catch(e){}" >
<input type="text" placeholder="Subject" name="Subject" oninvalid="setCustomValidity('Please enter a Subject')"
onchange="try{setCustomValidity('')}catch(e){}" required >
<textarea rows="5" placeholder="Message" name="Message" oninvalid="setCustomValidity('Please Write your Message')"
onchange="try{setCustomValidity('')}catch(e){}" required ></textarea>
<button type="submit" class="btn btn-primary"><i class="fa fa-paper-plane"></i> Send</button>
</form>
</div>
</div>
</div>
PHP Code:
<?php
if(isset($_POST['Name']))
{
$name=$_POST['Name'] ;
$company=$_POST['Company'] ;
$from=$_POST['Email'] ;
$message=$_POST['Message'] ;
$to="contact#website.com" ;
$subject="Website contact form";
$headers .= 'From: '.$name.' | '.$company.' | '.$from.' ' . "\r\n";
mail ($to, $subject, $message, $headers ) ;
echo "Your Email has bean sent.";
}
?>
Thanks

Php mail not sending

I'm trying to send an email using php but it's not working..
This is my code:
<form method="post" name="contact" action="#contact">
<div class="left">
<label for="author">Name:</label> <input name="nom" type="text" class="input_field" id="author" maxlength="40" />
</div>
<div class="right">
<label for="email">Email:</label> <input name="email" type="text" class="input_field" id="email" maxlength="40" />
</div>
<div class="clear"></div>
<label for="text">Message:</label> <textarea id="text" name="text" rows="0" cols="0"></textarea>
<input type="submit" class="submit_btn float_l" name="submit" id="submit" value="Send" />
</form>
<?php
$name= ($_POST["nom"]);
$mail= ($_POST["email"]);
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From:<nelson-book#outlook.fr>' . "\r\n";
$suject="Book";
$message = "Nom: <br/>" .$name. "email:<br/> " .$email. "message: " .$_POST["text"];
if (isset($_POST['submit'])) {
mail("nelson-book#outlook.fr", $suject, $message, $headers);
echo" teste";
}
?>
I already used a code SUPER similar to this ant it totally worked.. Can the problem be from the server?
thanks in advance.
check out your SMTP server restriction when you send email, with another hosting domain like, "outlook.fr", somethime this is't allowed.

Categories