Whenever I enter text into the textbox, it is not properly transferring to PHP. PHP reads the input as null, when in reality, there is text in there.
PHP code.
//Two Email Lines
$email_to = "contact#mywebsite.com";
$email_subject = "AUTO: REQUEST";
//Set equal to email form textbox
$email_form = $_POST['email_text'];
$email_message = "Email: " . $email_form . "";
//Create email headers
#mail($email_to, $email_subject,$email_message,$headers);
HTML code for the form
<div id="form">
<form method="post" action="Email_Form_Script.php" enctype="text/plain" onsubmit="window.open('FormPopUp.html','popup','width=500,height=500,scrollbars=no,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0');" >
<div>
<input type="text" class="text" name="e3text" id="emailForm" value="Enter your e-mail address" onfocus="if(this.value=='Enter your e-mail address') { this.value = '' }" onblur="if(this.value=='') { this.value = 'Enter your e-mail address' }" />
<input type="hidden" value="" name="email2"/>
<input type="hidden" name="loc" value="en_US"/>
<input type="submit" class="submit" value=""/></div>
</form>
</div>
Really confused as to why it is not working. I keep getting empty emails that just say " Email: " (No text after Email).
The line:
$email_form = $_POST['email_text'];
needs to match the name of the text in the form which in your case is name="e3text" so you should use:
$email_form = $_POST['e3text'];
Its because your form doesn't actually contain an input element named email_text which is referenced in your PHP code. You need to structure your HTML form code to at least look like this or change your PHP code to require $_POST['e3text'].
<div id="form">
<form method="post" action="Email_Form_Script.php" enctype="text/plain" onsubmit="window.open('FormPopUp.html','popup','width=500,height=500,scrollbars=no,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0');" >
<div>
<input type="text" class="text" name="email_text" id="emailForm" value="Enter your e-mail address" onfocus="if(this.value=='Enter your e-mail address') { this.value = '' }" onblur="if(this.value=='') { this.value = 'Enter your e-mail address' }" />
<input type="hidden" value="" name="email2"/>
<input type="hidden" name="loc" value="en_US"/><input type="submit" class="submit" value="" />
</div>
</form>
</div>
try this in your php code
$email_form = $_POST['e3text'];
"e3text" is the name of your text box so in php use this name
When you hit the submit button of your form, values are passed as:
name of the input field = value of the input field
Your field is name e3text - please refer to such field in your script, i.e. $_POST['e3text'].
Related
So I've had some issues trying to get my php code to work. I found a form php handler which I want to send the email on the back end for the users.
<?php
if(isset($_POST['submit'])){
ob_start();
$from = $_POST['email']; // this is the sender's Email address
$first_name = $_POST['first_name'];//Sender first name//
$last_name = $_POST['last_name'];//sender last name//
$subject = "Contact Request.";
$message = $first_name . " " . $last_name . " wrote the following:" . "\n\n" . $_POST['message'];
$to = "-myemail#outlook.com-"; // this is your Email address
$headers = "From:" . $from;
mail($to,$subject,$message,$headers);
header('Location: http://-mysite-/thankyou.html');
exit();
}
?>
Here is the HTML form info:
<form action="php/email.php" method="post" name = "email form" enctype="multipart/form-data" class="container" align="center">
<label for="firstname"></label>
<strong>*</strong><input type="text" placeholder="Enter First Name" name="first_name" required>
<br>
<label for="lastname"></label>
<strong>*</strong><input type="text" placeholder="Enter Last Name" name="last_name" required>
<br>
<label for="email"></label>
<strong>*</strong><input type="text" placeholder="Enter Email" name="email" required>
<br>
<label for="phoneno"></label>
<input type="phoneno" placeholder="Enter Phone Number" name="phone_number">
<br>
<label for="interested"></label>
<t> Brief description of project:</t><br>
<textarea style="width:100% height:60%" align="center" name="message">
</textarea><br>
<button type="submit" class="btn" value="Send Form"><strong>Submit</strong></button>
</form>
I can't figure out why the page on submit does redirect to the email.php but doesn't do anything from there. Do I need to contact the site support team to restart my php services? I've been smacking my head against the keyboard for the last 2 days as to why this isn't working.
Because you haven't field in your form with name="submit" and trying to get its value in PHP: if(isset($_POST['submit'])).
Bonus tip: don't use name submit for any field of the form, cause some browsers getting fooled with this. Instead use formsubmit, submitted or anything else.
just add this field in your form
<input type="hidden" name="submitted" value="1">
andchange condition in PHP to
if(isset($_POST['submitted']) && intval($_POST['submitted']) == 1)...
Im in need to create to separate e-mail forms based on AJAX and JQuery.
I need one form to be Standart and other VIP, when getting email from website - i need to indicate from which form customer has send inquiry.
I have sample form for Standard, and need to create VIP form. Imagine it is needed to create forms ID and insert it to JQuery.
Please help
Here is sample form code:
<form id="vip" class="pop_form" action="mail-vip.php">
<h4>ОPlease leave your contacs, we will come back soon!</h4>
<input type="text" name="name" placeholder="Name" required />
<input type="text" name="phone" placeholder="Telephone" required />
<input type="text" name="email" placeholder="E-mail" required />
<input type="text" name="time" placeholder="Callback time" />
<div align="center"><button type="submit">Send</button></div>
</form>
Jquery:
$("form").submit(function() {
$.ajax({
type: "GET",
url: "mail.php",
data: $("form").serialize()
}).done(function() {
alert("Спасибо за заявку!");
setTimeout(function() {
$.fancybox.close();
}, 1000);
});
return false;
});
PHP:
<?php
$recepient = "email;
$sitename = "Website";
$name = trim($_GET["name"]);
$phone = trim($_GET["phone"]);
$email = trim($_GET["email"]);
$email = trim($_GET["time"]);
$pagetitle = "New inquiry for \"$sitename\"";
$message = "Имя: $name \nTelephone: $phone \nE-mail: $email \nTime: $time";
mail($recepient, $pagetitle, $message, "Content-type: text/plain; charset=\"utf-8\"\n From: $recepient");
?>
Thanks!!!
There are various way you can do that.
One of the way could be (minimal change to your code)
Add an hidden field in your form which will be automatically sent to your php and extract it to see it's type.
e.g. <input type="hidden" name="type" value="vip">
So it should look like,
<form id="vip" class="pop_form" action="mail-vip.php">
<h4>ОPlease leave your contacs, we will come back soon!</h4>
<input type="text" name="name" placeholder="Name" required />
<input type="text" name="phone" placeholder="Telephone" required />
<input type="text" name="email" placeholder="E-mail" required />
<input type="text" name="time" placeholder="Callback time" />
<input type="hidden" name="type" value="vip">
<div align="center"><button type="submit">Send</button></div>
</form>
form id is vip i think you need write $("#vip").submit
In the other word,the button where the type "submit " will also submit your form data ,so you don't need write the Ajax
query
When I am filling out the contact form on the website that I am making, the e-mail will be sent, but I am not receiving it in the inbox of my computer.
The code looks like this:
HTML:
<div id="form">
<form action="mailto:psteintj#xs4all.nl" id="contactForm" method="post">
<span></span>
<input type="text" name="name" class="name" placeholder="Enter your name" tabindex=1 />
<span></span>
<input type="text" name="email" class="email" placeholder="Enter your email" tabindex=2 />
<span id="captcha"></span>
<input type="text" name="captcha" class="captcha" maxlength="4" size="4" placeholder="Enter captcha code" tabindex=3 />
<span></span>
<textarea class="message" placeholder="Enter your message" tabindex=4></textarea>
<input type="submit" name="submit" value="Send e-mail" class="submit" tabindex=5>
</form>
</div>
JS:
if ((captchaVal == captchaCode) && (emailFilter.test(emailText)) && (nameFilter.test(nameText)) && (messageText > 50)) {
$.post("mail.php", {
name: $(".name").val(),
email: $(".email").val(),
message:$(".message").val()
});
$("#contactForm").css("display", "none");
$("#form").append("<h2>Message sent!</h2>");
return false;
}
and PHP:
<?php
$name = $POST['name'];
$email = $_POST['email'];
$message = $POST['message'];
Could someone tell me where I am going wrong?
Well, you are not sending any emails (or at least you haven't posted any code about it), so of course you are not receiving any emails. You should configure the mailing, and use the mail function.
The function needs a working SMTP server to actually send out the e-mail.
Your PHP has no mail() call or similar? I'm probably missing something here.
I currently have this page I am working on:
http://www.webauthorsgroup.com/new/template/index3.html
In the lower right corner is a form (php), but I can't "echo" a text message after it has been submitted (for whatever reason).
My form is:
<form id="contact" method="post" action="">
<fieldset>
<label for="name">Name</label>
<input type="text" name="name" placeholder="Full Name" title="Enter your name" class="required">
<label for="email">E-mail</label>
<input name="hidden" class="required email" onblur="if(value=='<?php echo htmlentities($_POST['email']); ?>') value = 'Your Email'" onfocus="if(value=='Your Email') value = ''" type="email" value="Your Email" placeholder="yourname#domain.com">
<label for="phone">Phone</label>
<input name="phone" onblur="if(value=='<?php echo htmlentities($_POST['phone']); ?>') value = 'phone'" onfocus="if(value=='phone') value = ''" type="tel" value="phone" placeholder="ex. (555) 555-5555">
<input type="hidden" name="phone" placeholder="ex. (555) 555-5555">
<label for="message">Question/Comment</label>
<textarea name="message" onblur="if(value=='<?php echo htmlentities($_POST['message']); ?>') value = 'message'" onfocus="if(value=='message') value = ''" value="message" placeholder="Message"></textarea>
<input type="submit" name="submit" class="button" id="submit" value="Send Message" />
</fieldset>
</form>
=========================================================
the process.php is:
<?php
if(isset($_POST['submit']))
{
// Get Data
$name = strip_tags($_POST['name']);
$email = strip_tags($_POST['email']);
$phone = strip_tags($_POST['phone']);
$url = strip_tags($_POST['url']);
$message = strip_tags($_POST['message']);
echo "Thank You!";
}
// Send Message
mail( "bruce#webauthorsgroup.com", "Inquiry From WebAuthorsGroup",
"Name: $name\nEmail: $email\nPhone: $phone\nWebsite: $url\nMessage: $message\n",
"From: Forms <forms#example.net>" );
?>
=================================================
I need the "message sent" text echoed in the same div after submitting the form and I don't want to convert my index page to index.php
Any help would be great!
The PHP code on the page index3.html is not being parsed or executed by the PHP interpreter on your server because the file extension is .html. Go ahead and view source on that page in the browser. Note that you can see the PHP code. You should not be able to see PHP code in the HTML source. You should see only the HTML rendered by the PHP. Please change the file extension to .php so your server can execute it instead of outputting it as text.
<input type="button" class="button" />
<form action="" method="">
<input type="text" name="name" />
<input type="text" email="email" />
<input type="text" phone="phone" />
<textarea name="message"></textarea>
<input type="submit" class="submit"/>
</form>
1,click the button, then popup the form, after the user fills out all the information in the form than click the submit button, send all the form information to my eamil box.
how to write the action part. and which method should i use? should i use mail function to send the email or other ways?
i may use jquery to pop up the form window, but i don't know how to collect the form information,then send it my email box.
It is a very broad question, but in a nutshell this is how it is done:
Post the form to a php file that will handle it and use PHP mail() function to send it:
<form action="process.php" method="POST">
process.php:
<?php
if (isset($_POST)):
foreach ($_POST as $key=>$value):
$message = "$key : $value \n";
endforeach;
mail('mymail#example.com', 'My Subject', $message);
endif;
You need to post it then send the email. Also, <input type="text" email="email" /> needs to be <input type="text" name="email" /> need to use the name attribute.
Try this:
<?php
if (!empty($_POST)){
$send_message = 'Name: ' . $_POST[name] . ' Email: ' . $_POST[email] . ' Phone: ' . $_POST[phone] . ' Message: ' . $_POST[message];
mail('youremail#email.com', 'Subject', $send_message);
}
?>
<form action="" method="post">
<input type="text" name="name" />
<input type="text" name="email" />
<input type="text" name="phone" />
<textarea name="message"></textarea>
<input type="submit" class="submit"/>
</form>