Hello i have a contact form PHP from a theme i purchased. I've been trying to make a customized form with it but with no luck. Tried changing the variables around to work for the one i made myself but it is not being sent to the email i want the information to go to.
This is what i have in my HTML
<form id="" action="application/application.php" method="post" class="validateform" name="send-contact">
<div id="sendmessage">
Your message has been sent. Thank you!
</div>
Youtube Channel Name <br> <input type="text" name="youtubename" placeholder="* Enter Your YouTube Name">
<div class="validation"></div>
First Name <br> <input type="text" name="firstname" placeholder="* Enter Your First Name">
<div class="validation"></div>
Last Name <br> <input type="text" name="lastname" placeholder="* Enter Your Last Name">
<div class="validation"></div>
Your Paypal Email Address <br> <input type="text" name="paypal" placeholder="* Enter Your Paypal Email">
<div class="validation"></div>
Your YouTube Email Address <br> <input type="text" name="youtubeemail" placeholder="* Enter Your YouTube Email">
<div class="validation"></div>
Skype <br> <input type="text" name="skype" ``placeholder="* Enter Your Skype Name">
<div class="validation"></div>
<button class="btn btn-theme margintop10 pull-left" type="submit">Submit Application</button>
</form>
And for my PHP i have the following;
<?php
include 'config.php';
error_reporting (E_ALL ^ E_NOTICE);
$post = (!empty($_POST)) ? true : false;
if($post)
{
$youtubename = stripslashes($_POST['youtubename']);
$firstname = stripslashes($_POST['firstname']);
$lastname = stripslashes($_POST['lastname']);
$paypal = stripslashes($_POST['paypal']);
$youtubeemail = trim($_POST['youtubeemail']);
$skype = stripslashes($_POST['skype']);
$error = '';
if(!$error)
{
$mail = mail(WEBMASTER_EMAIL, $subject, $message
"From: ".$firstname." <".$youtubename.">\r\n"
."Reply-To: ".$youtubeemail."\r\n"
."X-Mailer: PHP/" . phpversion());
if($mail)
{
echo 'OK';
}
}
}
?>
And in my config.php i have
<?php
// To
define("WEBMASTER_EMAIL", 'Support#XvinityNetwork.com');
?>
I'm not very savvy with HTML and i have a member of my staff that does this however has had an emergency issue to attend to this and i need to get this contact form up and running. I do have the default form that came with the theme and it works perfectly so im guessing i've done something wrong here. Would appreciate the help!
A notable error is you are missing a comma between $message and headers:
$mail = mail(WEBMASTER_EMAIL, $subject, $message, // Here
"From: ".$firstname." <".$youtubename.">\r\n"
."Reply-To: ".$youtubeemail."\r\n"
."X-Mailer: PHP/" . phpversion());
You have few syntax errors. A good redactor was solving your problem in a minute.
First of all the "skype" input - it has two quotes in it. Remove it. Second, in the mail function, you adding undefined $message, with no operator (such as dot) to random text. if $message containing something, place "." after it, and if not, just delete it. And if you meant to add headers, just add comma after the $message.
Related
So I wanted to make a contact form for a website that can actually send emails, but ended up with this error :
Here's my html code:
<div class="contact-fast">
<div class="contact-form">
<form id="contact-form" method="POST" action="contact-form-handler.php">
<input name="name" type="text" class="form-control" placeholder="Your Name" required> <br>
<input name="email" type="email" class="form-control" placeholder="Your Email" required> <br>
<textarea name="message" class="form-control" placeholder="Message" rows="8" required></textarea> <br>
<input type="submit" class="form-control submit" value="SEND MESSAGE">
</form>
</div>
</div>
And here's my PHP code:
<?php
$name = $_POST['name'];
$visitor_email = $_POST['email'];
$message = $_POST['message'];
$email_from = 'skeremobiel#gmail.com';
$email_subject = 'New Mail From Website';
$email_body = "Username: $name.\n".
"User Email: $visitor_email.\n".
"User Message: $message.\n";
$to = "said444b#gmail.com";
$headers = "From: $email_from \r\n";
$headers .= "Reply-To: $visitor_email \r\n";
if ($visitor_email!=NULL) {
mail($to,$email_subject,$email_body,$headers);
}
header("Location: http://127.0.0.1:5500/social.html");
die()
?>
Here's how my page looks like before and after submitting the form:
I think the problem is that when i click on the submit button i get directed to 127.0.0.1:5500/contact-form-handler.php (as you can see in the last image in my question). It doesn't execute the php file, but it just opens it.
Any help would be appreciated!
Many things can go wrong.
Make shure php error reporting is on. Google for that.
Try to find where the error code is coming from by reducing your problem.
For instance, comment out mail() and see if it works.
Or replace your php code by a simple text to see if the code runs, if the text appears on your browser screen.
Or Google for error 405. You will learn it is an http error, something in the data exchange between your browser and the server.
Do you have characters before <?php because if you have, the server will not be able to output the HTTP header any more.
Is your php file located at the webserver root and called contact-form-handler.php?
I've searched through the forums and found a lot of threads on this topic but can't seem to find the correct answer or solution for my problem.
I've got a contact form which I can't seem to get working.
HTML:
<form action="php/index.php" id="contact-form" method="post" name="form">
<div>
<label>
<span>Naam: (verplicht)</span>
<input name="vname" placeholder="Uw naam" type="text" tabindex="1" required>
</label>
</div>
<div>
<label>
<span>Email: (verplicht)</span>
<input name="vemail" placeholder="Uw e-mail adres" type="email" tabindex="2" required>
</label>
</div>
<div>
<label>
<span>Telefoon:</span>
<input name="vphone" placeholder="Telefoon nummer" type="tel" tabindex="3">
</label>
</div>
<div>
<label>
<span>Bericht: (verplicht)</span>
<textarea name="msg" placeholder="Uw vraag of opmerking" tabindex="4" required></textarea>
</label>
</div>
<div>
<input id="send" name="submit" type="submit" value="VERZENDEN">
</div>
</form>
<!-- /Form -->
And here is the PHP code, I replaced my e-mail adress in the form with MY EMAIL for obvious reasons.
<?php
if(isset($_POST['submit'])) {
$name = $_POST['vname'];
$remark = $_POST['msg'];
$from_add = $_POST['vemail'];
$to_add = "MY EMAIL";
$subject = "Your Subject Name";
$phone = $_POST['vphone'];
$headers = 'From: $from_add';
if ($phone != null){
$message = "Naam:$name \n Opmerking: $remark \n mijn telefoon nummer is $phone";
mail($to_add,$subject,$message,$headers);
}else{
$message = "Naam:$name \n Opmerking: $remark";
mail($to_add,$subject,$message,$headers);
}
}
?>
Ow I am using XAMPP to run a localhost, perhaps that could be the problem but I'm not sure.
using the php mail driver aint good for several reasons ,
u can instead try something call phpmailer http://phpmailer.worxware.com which will teach u a better way of doing things like that without frustration ,also incase later u wanted to use a php framework u will feel right at home because they will mostly be using the same syntax.
note that sending mails at first may take some time ,maybe even hours b4 u get anything ,for that u can use something like a fakesmtp https://nilhcem.github.io/FakeSMTP/ to catch the emails.
I had that same problem with a horrible server which doesn't send emails.
So I used a code that connects to a gmail account and sends the email from there.
try this tutorial:
http://coded-words.tumblr.com/post/6936532107/configure-gmail-as-smtp-in-xampp-to-send-mail
Edit 23.12.2014:
Do you have something like this in your code?
<?php
$message = "The mail message was sent with the following mail";
$headers = "From: youremail#gmail.com";
mail("youremail#gmail.com", "Testing", $message, $headers);
?>
(source: http://jiansenlu.blogspot.co.il/2014/10/php-mail-function-using-gmail-account.html)
If you do have this code:
Try submitting a different email address than the one you used in your code.
Sometimes it goes to the "Sent mail" in your Gmail account without actually showing you that you received a new email. (So you can check your "Sent mail" to see if there is anything over there).
UPDATE: non of any php files is running. Is there a way to solve the problem ?
I have html a page that takes the email details:
<form method="POST" sourceindex="44" action="semail.php" name="form1" onSubmit="return validate_form ( );">
<p>
<label>Your name:<br>
<input sourceindex="47" name="mail_name" class="text_field" type="text">
</label>
</p>
<p>
<label>Your e-mail:<br>
<input sourceindex="51" name="mail_email"
class="text_field" type="text">
</label>
</p>
<p>
<label>Message:<br>
<textarea sourceindex="55" name="mail_msg" cols="45"
rows="5" class="text_area"></textarea>
</label>
</p>
<input name="B1" type="submit" class="form_button" value="" />
</form>
and here is the php code (this is all in semail.php):
<?php
$mail_to ="someEmail#hotmail.com";
$mail_subject = "Message From a Customer";
$mail_body ="Name of the Coustomer: ".$_POST['mail_name']."\n";
$mail_body .= "E-Mail Of the Coustomer: ".$_POST['mail_email']."\n";
$mail_body .= "The Message: ".$_POST['mail_msg']."\n";
if(mail($mail_to, $mail_subject, $mail_body))
echo "Thanks for your Message";
else
echo "Failed to send the e-mail"
?>
Whenever I click send the semail.php page shows me this error: No input file specified
Can someone help me please in figuring out where is the problem ?
To first check and verify that PHP is running and available with the present Web hosting company, create a file called check_server.php and insert the following code:
<?php
// Show all information, defaults to INFO_ALL
phpinfo();
// Show just the module information.
// phpinfo(8) yields identical results.
phpinfo(INFO_MODULES);
?>
If successful, you will see your server information and configurations. It will also show the path to mail.
Regarding your form code:
My answer may or may not solve a probable Hosting company issue, however there were a few errors in your code which would result as unsuccessful.
Please read the following:
In using the following form, had success in sending and receiving the message.
<form method="POST" sourceindex="44" action="semail.php" name="form1">
<p>
<label>Your name:<br>
<input sourceindex="47" name="mail_name" class="text_field" type="text">
</label>
</p>
<p>
<label>Your e-mail:<br>
<input sourceindex="51" name="mail_email"
class="text_field" type="text">
</label>
</p>
<p>
<label>Message:<br>
<textarea sourceindex="55" name="mail_msg" cols="45"
rows="5" class="text_area"></textarea>
</label>
</p>
<input name="B1" type="submit" class="form_button" value="Submit" />
</form>
N.B.: I do need to point out that your PHP mail handler did not contain a few required elements.
For example the From: element/variable which was not present in your handler.
$mail_email= $_POST['mail_email'];
Also headers were not present. Mail requires 4 variables to send/receive Email.
For example you have if(mail($mail_to, $mail_subject, $mail_body))
Which should read as if(mail($mail_to, $mail_subject, $mail_body, $headers))
Omitting the headers would result in a message marked as SPAM because of the missing Email from and would show as unknown sender
In conjunction with the form above, am including a working copy of the PHP mail handler:
<?php
$mail_to ="someEmail#hotmail.com";
$mail_email= $_POST['mail_email'];
$mail_subject = "Message From a Customer";
$mail_body ="Name of the Customer: ".$_POST['mail_name']."\n";
$mail_body .= "E-Mail Of the Coustomer: ".$_POST['mail_email']."\n";
$mail_body .= "The Message: ".$_POST['mail_msg']."\n";
$headers = "From: $mail_email \r\n";
$headers .= "Reply-To: $mail_email \r\n";
if(mail($mail_to, $mail_subject, $mail_body, $headers))
echo "Thanks for your Message";
else
echo "Failed to send the e-mail";
?>
Read up on the mail( ) function on PHP.net: http://php.net/manual/en/function.mail.php
I need make this form send me a email like a contact form:
Script code:
<script type="text/javascript">
$(document).ready(function(){
$("#contactLink").click(function(){
if ($("#contactForm").is(":hidden")){
$("#contactForm").slideDown("slow");
}
else{
$("#contactForm").slideUp("slow");
}
});
});
function closeForm(){
$("#messageSent").show("slow");
setTimeout('$("#messageSent").hide();$("#contactForm").slideUp("slow")', 2000);
}
</script>
HTML CODE:
<div class="box">
<div id="contactFormContainer">
<div id="contactForm">
<fieldset>
<label for="Name">Nome: </label>
<input id="name" type="text" />
<label for="Telefone">Telefone Fixo: </label>
<input type="text" id="phone" maxlength="15" onkeypress="Mascara(this);" />
<label for="Message">Assunto:</label>
<textarea id="Message" rows="3" cols="20"></textarea>
<input id="sendMail" type="submit" name="submit" onclick="closeForm()" />
<span id="messageSent">Sua solicitação foi enviada com sucesso, por favor, aguarde...</span>
</fieldset>
</div>
<div id="contactLink"></div>
</div>
When click and close the form i need send me a email with the content of form, how to?
Some idea? thanks!
Firstly i can't see the form tags in your code. According to me you're doing this wrong and i'm sure many of our friends on stack will agree too.
Your question suggests that you basically want to receive an email with the data submitted through the form. Why don't you try the below method.
HTML
<form action="mail.php" method="POST">
<input type="text" name="fname"></input>
<input type="text" name="lname"></input>
<button>SUBMIT</button>
</form>
PHP
<?php
$firstname = $_POST['fname'];
$lastname = $_POST['lname'];
$to = "someone#example.com";
$subject = "Hello World";
$message = "Firstname: $firstname \n\n Lastname: $lastname";
$from = "sender#example.com";
$headers = "From:" . $from;
mail($to,$subject,$message,$headers);
echo "Mail Sent.";
?>
The above example is the most simplest method of sending an email. You can go advance by adding more header information and graphically formatting the email.
Go through these tutorials if you get confused.
http://www.w3schools.com/php/php_mail.asp
http://www.phpeasystep.com/phptu/8.html
And since you mentioned that you want to perform the task via javascript you can try submitting the form via ajax, refer the below tutorials
http://teachingyou.net/php/simple-php-contact-form-using-ajax/
http://www.sitepoint.com/forums/showthread.php?1055068-Send-PHP-email-using-jQuery-AJAX
Since you've tagged the question php, have a look at php's mail function. http://php.net/manual/en/function.mail.php
$to = 'you#domain.com';
$subject = 'Contact Form';
$message = '...' //concatenate the $_POST (or $_GET) variables to create this message
mail($to, $subject, wordwrap($message, 70, "\r\n");
This function requires that your server has a properly configured to send mail - see the php documentation for requirements: http://www.php.net/manual/en/mail.requirements.php
I am trying to make a email send in a pop up on my site that you can see with the link below:
http://www.madaxedesign.co.uk
However it redirects perfectly to the thank you message however after it has redirected it does not implement the PHP. Below I have shown the PHP, HTML and Jquery used for this contact form.
HTML:
<form id="submit_message" class="hide_900" action="/send.php" method="post">
<div id="NameEmail">
<div>
<label for="name">Name*</label>
<input type="text" title="Enter your name" name="name"/>
</div>
<div>
<label for="email">Email*</label>
<input type="text" title="Enter your email address" name="email"/>
</div>
</div>
<div id="MessageSubmit">
<div>
<textarea maxlength="1200" title="Enter your message" name="message"></textarea>
<label for="message">Message</label>
</div>
<div class="submit">
<input type="submit" value="Submit"/>
</div>
</div>
</form>
PHP:
<?php
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$formcontent="From: $name \n Message: $message";
$recipient = "maxlynn12#gmail.com";
$subject = "Email From Madaxe";
$mailheader = "From: $email \r\n";
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
header('Location: /thanks.html');
exit();
?>
Jquery:
$('form#submit_message').live('submit', function() {
$('#popup').load('/thanks.html');
return false;
});
I was wondering if anyone could quickly look and see if I am missing anything obvious that I can quickly fix or even point me in the right direction.
Thanks
Your jQuery is interfering.
I think this might help, using AJAX to post your form: jQuery Ajax POST example with PHP
You do not need to your jquery code. actually it prevents your default action form action=send.php. and it does not pass your inputs to send.php
$.live() is deprecated in jQuery 1.9 and that's what you appear to be using. Please either downgrade or use an alternative function like .submit().
$('#submit_message').submit(function (e) {
e.preventDefault();
$('#popup').load('/thanks.html');
}
Also, it is crucial that you sanitise your $_POST inputs before using them for your e-mail headers, otherwise a hacker can inject bad things into your headers.
if you are trying to send mail through localhost you need to change some setting in php.ini file. Refer below link to do this.
http://blog.techwheels.net/send-email-from-localhost-wamp-server-using-sendmail/