I am trying to configure this boostrap template: Github link
I do not have a datebase to use and on the Github page it says:
"Your must enter your database information and your email in
form-handler.php - if you don't have a database, that's fine. Edit
contact.html to direct the form to form-handler-nodb.php and emails
will be sent with no database writes."
I do not understand exactly what it means to "direct the form to form-handler-nodb.php". I have tried to change the form attributes in contact.html to be <form action="/form-handler-nodb.php" method="post" role="form"> , but that just results in form-handler-nodb.php being downloaded when I hit the submit button.
My question is then what do I need to change in contact.html to be able to submit the email that is in the form on the page?
This is driving me insane! Thank you for your help.
As Capsule mentioned in the comments I was not running a server when I was testing it locally. By uploading the contact.html to my server I started seeing this working.
As a side note, there was also a mistake in the form-handler-nodb.php file where "\nEmail: " . $email; needed to be changed to "\nEmail: " . $message to actually have the inputed email message submitted.
Thank you for the help Capsule!
Related
I have a hand-built (HTML/PHP) site that I would like to replicate on Wordpress. The site includes a form which sends the user input to a 3rd party server which returns a price quote which then gets displayed.
The structure is as follows:
<?php
if($_REQUEST['page']==''){
<form id=frm action='' method=post>
<input type=hidden name=page value=calcs>
...
<input type=submit id="submitButton" value='Get your instant quote'>
</form>
}
else
{
PACKAGE THE USER INPUT VIA XML AND SEND WITH A CURL COMMAND TO 3RD PARTY SERVER, RECEIVE REPLY IN XML.
FROM REPLY EVALUATE MINIMUM PRICE QUOTE, ECHO TO PAGE, EMAIL WEBMASTER.
}
?>
This works fine in my original HTML/PHP website, but I'm a noobie when it comes to Wordpress and I'm afraid I've bitten off more than I can chew :(((
In Wordpress I've made a page template page-form.php which resides in my theme folder. This file is very similar to the structure described above:
if($_REQUEST['page']==''){
include 'template-parts/form.inc.php';
}
else
{
PACKAGE THE USER INPUT VIA XML AND SEND WITH A CURL COMMAND TO 3RD PARTY SERVER, RECEIVE REPLY IN XML.
FROM REPLY EVALUATE MINIMUM PRICE QUOTE, ECHO TO PAGE, EMAIL WEBMASTER.
}
This Wordpress form displays correctly but when I fill it in and submit I land on a "Hello World" page with no price-quote and I recieve no email. form.inc.php is for all intents & purposes the same as the original form from the 1st version of the site.
Have I made some fundamental error in thinking I could transplant the structure straight to Wordpress? I have tried googling for similar issues but can't find anything, feels like I'm on the wrong path .... if anyone can give me a helping hand I'd be very grateful!
Everything works well behind the scene but my clients see a Page not found after Posting a form.
The form.php must have been found otherwise the data wouldn't be parsed to my e-mail smoothly. I have a redirection page: thankpage.html, which is up and running well when I type its address directly.
what could be going on? any help please?
Anyway,
Instead of calling the Thankpage.html from the form.php, I inserted the following into my "form" element in the contact.html page itself:
onsubmit="window.location.href='http://www.inglesparticular-sp.com/thankpage.html';"
So it is now:
<form role="form" id="contact-form" method="post" action="form.php" onsubmit="window.location.href='http://www.inglesparticular-sp.com/thankpage.html';">
Somehow it's all working well and I have no "PAGE NOT FOUND" messages!!!
Sorry if I wasn't clear on the question, it's my first one as you can see... cheers!
Couldn't find the answer I was looking for on any questions regarding php contact forms so have to ask a new question.
I have a contact form that works fine. When submitted the user is taken to success.php by using header("Location: success.php");
The problem lies when errors exist in the contact form. What I have done is use
action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>"
This keeps the user on the same page and displays errors. The problem though is that being a single page website it redirects users to the top of the page and not back down to the contact form where the errors are displayed. How would I use php to scroll down to the contact form so the user knows that their email wasn't sent?
You can use an anchor in your html-code
<a name="jump_here"></a>
after this modify you code:
action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]).'#jump_here'; ?>"
You can use a bookmark.
<h2 id="contactform">Contact Form</h2>
Contact Form
I have a Gmail Sponsored Promotion Ad which has a form. The form collects basic data like name and email, then redirects the user to a page where they can download a pdf file and sends the form data to my email via a php file (submit.php). However, I can't host submit.php in the same server as the form, Google doesn't allow any other files other than index.html and the images, and no script either, only vanilla HTML. All I can do is link to an external action.
This works when the submit.php file is hosted on the same server as the form, but not when they are hosted in different servers - I don't get the email with the data from the form. Why is that? And what can I do to circumvent it?
ps. I don't know any PHP
Form hosted in http://google.com/
<form action=" http://me.com/submit.php" method="post">
<input type='email' name='email'></input>
<input type='submit'></input>
</form>
submit.php hosted in http://me.com
<?php
$email = $_POST['email'];
$msg .= $email;
if (mail ($email_sender, $email_subject, nl2br($msg), $email_headers)){
?>
<script language= "JavaScript">
location.href="http://file.pdf"; </script>
?>
The Problem is not easy to solve ... Here you can find some information about the reason cross-domain-form-posting
One way could be:
In submit.php (when i understand you right) you have access of POST/GET data, if so .. write a function to send the data to a foreign domain, eg. use CURL functions or use a DB
I implemented the contact form into a CMS page here.
As you can see, the forms shows up fine. However, when I fill the form out to test and click "send", there is no message indicating if the mail was sent correctly or failed. But a new page loads, so I think it is doing something. When I check my email, no email comes. I’ve checked spam folder too.
Current Setup:
In the CMS page, I have this code:
{{block type="core/template" name="contactForm" form_action="/contacts/index/post" template="contacts/form.phtml"}}
In the form.phtml file, I have modified the form tag action attribute to:
<form action="/contacts/index/post/" id="contactForm" method="post">
Stuff I’ve tried already:
And I don’t think its the server because I tried the "forgot password” when logging into the Admin, and I received an email to reset the password.
In System Config, I’ve verified that "Enable Contact Us” is Yes. "Disable EMail Communications” is No. And makes no difference if "Set Return Path” is Yes or No.
It is set to send to an email address that is not hosted by the same server as the Magento site is on. The email address is a Google Apps email.
Ok, I figured it out. For some reason, the path in the action attribute of needed another parent folder. So in my case, it should be
<form action="/2/contacts/index/post/" id="contactForm" method="post">
just go to app/design/frontend/your_theme/default/template/contacts/form.phtml
and set form action to <?php echo $this->getFormAction(); ?>
<form action="<?php echo $this->getFormAction(); ?>" id="contactForm" method="post">