Hey i have a basic contact form which is submitting but nothing is being received.
I have set the form to load a template if successful, which it does.
The code below is my form code
<form name="form1" method="post" action="send_contact.php">
<input name="name" placeholder="Name" type="text" id="name" >
<input name="customer_mail" placeholder="Email" type="text" id="customer_mail">
<textarea name="detail" placeholder="Message" id="detail"></textarea>
<input type="submit" class="button" name="Submit" value="Submit">
<input type="reset" class="button" name="Submit2" value="Reset">
</form>
and this page is my submission page
<?php
//Include the common file
require_once('common.php');
// Details
$message="$detail";
// Mail of sender
$mail_from="$customer_mail";
// From
$header="from: $name <$mail_from>";
// Enter your email address
$to ='EMAIL ADDRESS REMOVED';
$send_contact=mail($to,$subject,$message,$header);
// If message sent..
if($send_contact){
//Display the template
$tpl->display('send-contact');
}
else {
echo "ERROR";
}
?>
I have tried sending it to and from two different email addresses and check for any filters on the email addresses themselves but i'm still unable to send my contact form.
Can anyone shed any light on this?
Thanks
Related
Where does my send to email go on this form?
<!--Start Contact form -->
<form action="email/" method="post" name="enq" target="_blank" onsubmit="return validation();">
<fieldset>
<input type="text" name="name" id="name" value="" class="input-block-level" placeholder="Name" />
<input type="text" name="email" id="email" value="" class="input-block-level" placeholder="Email" />
<textarea rows="11" name="message" id="message" class="input-block-level" placeholder="Comments"></textarea>
<div class="actions">
<input type="submit" value="Send Your Message" name="submit" id="submitButton" class="btn btn-info pull-right" title="Click here to submit your message!" />
</div>
</fieldset>
</form>
<!--End Contact form -->
You can use the PHP built-in mail() function for sending emails to one or more recipients dynamically from your PHP app either in a plain-text form or formatted HTML.
The basic syntax of the mail() function is as follows;
mail(to, subject, message, headers, parameters)
Easiest way to send emails from php
<?php
$to = 'xyz#somedomain.com';
$subject = 'This is subject';
$message = 'This is email message';
$from = 'sendermailadd#email.com';
// Sending email
if(mail($to, $subject, $message)){
echo 'Your mail has been sent successfully.';
} else{
echo 'Unable to send email. Please try again.';
}
?>
for further explained details please refer tutorialspoint.com
Please note that the PHP mail() function is a part of the PHP core but you need to set up a mail server on your machine to make it really work.
How to configure XAMPP to send mails from localhost Read From here
The code below acts strange when I click the button on my website.
First it opens a new page where the form is again displayed but without any css or js. Then when I refill all the info and click send, it says its submitted but it wont actually sent the email.
I have tried to modify the code I am still new to php.
Code below displays and functions the contact form.
<?php
$action=$_REQUEST['action'];
if ($action=="")
{
?>
<form action="" method="POST" enctype="multipart/form-data">
<input type="hidden" name="action" value="submit">
Your name:<br>
<input name="name" type="text" value="" size="30"/><br>
Your email:<br>
<input name="email" type="text" value="" size="30"/><br>
Your message:<br>
<textarea name="message" rows="7" cols="30"></textarea><br>
<input type="submit" value="Send email"/>
</form>
<?php
}
else /* send the submitted data */
{
$name=$_REQUEST['name'];
$email=$_REQUEST['email'];
$message=$_REQUEST['message'];
if (($name=="")||($email=="")||($message==""))
{
echo "All fields are required, please fill the form again.";
}
else{
$from="From: $name<$email>\r\nReturn-path: $email";
$subject="Personal Plate inquiry from website";
mail("mymail#hotmail.com", $subject, $message, $from);
echo "Email sent!";
}
}
?>
There are some mistakes on your code: use $_POST instead of $_REQUEST. You can try this way:
<?php
if(isset($_POST['submit'])){
$name=$_POST['name'];
$email=$_POST['email'];
$message=$_POST['message'];
if (($name =="")||($email=="")||($message==""))
{
echo "All fields are required, please fill the form again.";
}
else{
$from="From: $name<$email>\r\nReturn-path: $email";
$subject="Personal Plate inquiry from website";
mail("mymail#hotmail.com", $subject, $message, $from);
echo "Email sent!";
}
}
?>
<form action="" method="POST" enctype="multipart/form-data">
<input type="hidden" name="action" value="submit">
Your name:<br>
<input name="name" type="text" value="" size="30"/><br>
Your email:<br>
<input name="email" type="text" value="" size="30"/><br>
Your message:<br>
<textarea name="message" rows="7" cols="30"></textarea><br>
<input type="submit" name="submit" value="Send email"/>
</form>
I am working on a website for a real estate agency. There is one page called the details.php page, here customers can see all the characteristics of a house that they are looking for. I have a contact form on this page for a customer to fill in when he/she is interested.
If I go to www.mywebsite.com/details.php, this contact form works as it should work, I receive the email with all the contact information.
Now when a real customer uses the webpage he/she will never go to the www.mywebsite.com/details.php instead it will look like: www.mywebsite.com/properties/house-for-sale-in-London/6227.php (just an example of a property)
Here is where the contact form breaks, it shows in the URL bar all the information that was filled in like this:
www.mywebsite.com/properties/house-for-sale-in-London/6227.php?action=submit&name=TEST&telefono=TEST%40test.com&email=test%40test.com&message=Etoy+interesado+en+ver+este+inmueble.+Por+favor+contáctame.&subnewtide=Submit
but it doesn´t send, neither does it echo the thank you message.
What did I do wrong?
This is the code:
<h3>¿Quieres más información?</h3>
<form role="form" class="form-b">
<?php
$action=$_REQUEST['action'];
if ($action=="") /* display the contact form */
{
?>
<div class="contact-form">
<form action="" id="form-anchor" method="POST" enctype="multipart/form-data">
<input type="hidden" name="action" value="submit"> Mi nombre:
<br>
<input name="name" type="text" value="" size="30" />
<br> Mi numero:
<br>
<input name="telefono" type="text" value="" size="30" />
<br> Mi correo:
<br>
<input name="email" type="text" value="" size="30" />
<br> Mensaje:
<br>
<textarea name="message" rows="3" cols="30">Estoy interesado en ver este inmueble. Por favor contáctame.</textarea>
<br>
<div class="enviar-button">
<input type="submit" class="btn btn-block btn-primary" name="subnewtide" id="subnewtide" value="Submit" />
</div>
</form>
</div>
<?php
}
else /* send the submitted data */
{
$name=$_REQUEST['name'];
$email=$_REQUEST['email'];
$telefono=$_REQUEST['telefono'];
$message=$_REQUEST['message'];
$info= "Nombre: .$name. \r\n";
$info.= "Email: $email \r\n";
$info.= "telefono: $telefono \r\n";
$info.= "Codigo: $codigo \r\n";
if (($name=="")||($email=="")||($message=="")||($telefono==""))
{
echo "All fields are required, please fill the form again.";
}
else{
$from="From: $name<$email>\r\nReturn-path: $email";
$subject="Message sent using your contact form";
mail("opcomercial#rentarpereira.com", $subject, $info, $message);
echo '<div class="gracias">Gracias por contactarnos, pronto un asesor atenderá tu solicitud.</div>';
}
}
?>
</form>
First of all if you're using POST method in the form parameters shouldn't be sent through the url. Now one of the issues might be the fact that you have a form nested in the form so it might take the first form element as the valid one and GET is the default method. So see if that might be the problem.
I am trying to write some PHP which will submit my "contact form" and send the input to a given email.
On the internet, I found the following code that does this:
<?php
$action=$_REQUEST['action'];
if ($action=="") /* display the contact form */
{
?>
<form action="" method="POST" enctype="multipart/form-data">
<input type="hidden" name="action" value="submit">
Your name:<br>
<input name="name" type="text" value="" size="30"/><br>
Your email:<br>
<input name="email" type="text" value="" size="30"/><br>
Your message:<br>
<textarea name="message" rows="7" cols="30"></textarea><br>
<input type="submit" value="Send email"/>
</form>
<?php
}
else /* send the submitted data */
{
$name=$_REQUEST['name'];
$email=$_REQUEST['email'];
$message=$_REQUEST['message'];
if (($name=="")||($email=="")||($message==""))
{
echo "All fields are required, please fill the form again.";
}
else{
$from="From: $name<$email>\r\nReturn-path: $email";
$subject="Message sent using your contact form";
mail("vik.srk#hotmail.com", $subject, $message, $from);
echo "Email sent!";
}
}
?>
When I click submit, nothing is being sent to my inbox!
I updated your code to actually test if the mail was sent... I suspect you haven't configured an SMTP Email server, which means PHP has no way to send an email.
Your code now checks if mail() was successful.
<?php
$action=$_REQUEST['action'];
if ($action=="") /* display the contact form */
{
?>
<form action="" method="POST" enctype="multipart/form-data">
<input type="hidden" name="action" value="submit">
Your name:<br>
<input name="name" type="text" value="" size="30"/><br>
Your email:<br>
<input name="email" type="text" value="" size="30"/><br>
Your message:<br>
<textarea name="message" rows="7" cols="30"></textarea><br>
<input type="submit" value="Send email"/>
</form>
<?php
}
else /* send the submitted data */
{
$name=$_REQUEST['name'];
$email=$_REQUEST['email'];
$message=$_REQUEST['message'];
if (($name=="")||($email=="")||($message==""))
{
echo "All fields are required, please fill the form again.";
}
else{
$from="From: $name<$email>\r\nReturn-path: $email";
$subject="Message sent using your contact form";
$MailSent = mail("vik.srk#hotmail.com", $subject, $message, $from);
if($MailSent == true) {
echo 'Mail Sent';
} else {
echo 'Mail failed';
}
}
?>
If it fails, then you know there's a problem with the mail function. You can also put error_reporting(-1) at the top to turn on errors, in case you have any syntax errors. Like I said before, I'm guessing you haven't configured a mail server which is why you aren't getting any emails.
I am trying to create a simple PHP email form that I can embed into my website. I have two problems, the syntax appears to be wrong past href=\"\"> and I am not sure why. The rest of the text appears in the browser past that href=\"\"> section. If I use this form, won't it be easier to keep users from seeing my email in this PHP form? Be advised, I am new to PHP
<?php
$action=$_REQUEST['action'];
if ($action=="") /* display the contact form */
{
?>
<form action="" method="POST" enctype="multipart/form-data">
<input type="hidden" name="action" value="submit">
Your email:<br>
<input name="email" type="text" value="" size="30"/><br>
Your message:<br>
<textarea name="message" rows="7" cols="30"></textarea><br>
<input type="submit" value="Send email"/>
</form>
<?php
}
else /* send the submitted data */
{
$email=$_REQUEST['email'];
$message=$_REQUEST['message'];
if (($name=="")||($email=="")||($message==""))
{
echo "All fields are required, please fill the form again.";
}
else{
$from="From: $name<$email>\r\nReturn-path: $email";
$subject="Message sent using your contact form";
mail("me#email.org", $subject, $message, $from);
echo "Email sent!";
}
}
?>
See anything wrong?
You are checking for $name and it doesn't exist. This will get you working but you should check if the $_REQUEST exists before you define it. Always write code with error reporting on.
<?php
$action=$_REQUEST['action'];
if ($action=="") /* display the contact form */
{
?>
<form action="" method="POST" enctype="multipart/form-data">
<input type="hidden" name="action" value="submit">
Your email:<br>
<input name="email" type="text" value="" size="30"/><br>
Your message:<br>
<textarea name="message" rows="7" cols="30"></textarea><br>
<input type="submit" value="Send email"/>
</form>
<?php
}
else /* send the submitted data */
{
$email=$_REQUEST['email'];
$message=$_REQUEST['message'];
if (($email=="")||($message==""))
{
echo "All fields are required, please fill the form again.";
}
else{
$from="From: $name<$email>\r\nReturn-path: $email";
$subject="Message sent using your contact form";
mail("me#email.org", $subject, $message, $from);
echo "Email sent!";
}
}
?>