Hello,
i alredy buid my form and input fields, but don’t know how to connect to a php file. Where i have to put the email.php? Or is their a tutorial on create a contact form with kirby??
THX for any help
Hello,
i alredy buid my form and input fields, but don’t know how to connect to a php file. Where i have to put the email.php? Or is their a tutorial on create a contact form with kirby??
THX for any help
Not a tutorial, but a basic example: https://gist.github.com/bastianallgeier/c396df7923848912393d
Cool! But i don´t check where to put the php files??
The first one goes into /site/controllers, the second into /site/snippets and the third into /site/templates
i see. stupid question But it dosn´t work. Can i test this on my local Host?
This depends on your local host, if you can configure it to send mails …
My Form looks like this:
<form id="registrationForm" class="form-horizontal" method="post" >
<div class="form-group">
<label class="col-xs-2 control-label">Name</label>
<div class="col-lg-8 col-md-8">
<input type="text" class="form-control" name="name" />
</div>
</div>
<div class="form-group">
<label class="col-xs-2 control-label">Firma</label>
<div class="col-lg-8 col-md-8">
<input type="text" class="form-control" name="Firma" />
</div>
</div>
<div class="form-group">
<label class="col-xs-2 control-label">E-Mail</label>
<div class="col-lg-8 col-md-8">
<input type="text" class="form-control" name="email" />
</div>
</div>
<div class="form-group">
<label class="col-xs-2 control-label">Telefon</label>
<div class="col-lg-8 col-md-8">
<input type="text" class="form-control" name="phone" />
</div>
</div>
<div class="form-group">
<label class="col-xs-12 col-md-2 col-lg-2 control-label">Rückruf</label>
<div class="col-lg-8 col-md-2">
<div class="radio">
<label>
<input type="radio" name="call" value="ja" /> JA
</label>
</div>
<div class="radio">
<label>
<input type="radio" name="call" value="nein" /> NEIN
</label>
</div>
</div>
</div>
<div class="form-group">
<label class="col-xs-2 control-label">Nachricht</label>
<div class="col-lg-8 col-md-8">
<textarea type="text" class="form-control" name="text" rows="8"/></textarea>
</div>
</div>
<div class="form-group">
<div class="col-xs-9 col-md-offset-2">
<button type="submit" class="btn btn-primary" name="submit" value="submit">SENDEN</button>
</div>
</div>
The form looks good. What you need to get the example working:
contact
with a contact.txt in it and a separate subfolder named `thank-you’ with your thank you text./site/controllers
and must be named contact.php
/site/snippets
and must be names contactmail.php
/site/templates
and must be named contact.php
Then you can either test on a remote server or you have to find out how to enable sendmail() on your local server
IT DOES`T WORK On my server and on my local host. What can i do??
Hm, if you have followed the instructions step by step and sendmail() is enabled on your server, this code should work. Have you entered a valid email address in the controller?
$email = email(array(
'to' => 'youremail@example.com',
'from' => 'youremail@example.com',
'subject' => 'New contact request',
'replyTo' => $data['email'],
'body' => $body
));
Have you made sure that sendmail() is enabled on your remote and/or local server (what server are you using locally?)
Do you get any error messages in your server error logs?
Yes, i entered my email in there. The only thing i change in the contact controller PHP is the redirect and my email:
$email = email(array(
'to' => 'mail@sandroieva.com',
'from' => 'mail@sandroieva.com',
'subject' => 'New contact request',
'replyTo' => $data['email'],
'body' => $body
));
// try to send it and redirect to the
// thank you page if it worked
if($email->send()) {
go('ueber-pretty-check');
// add the error to the alert list if it failed
} else {
$alert = array($email->error());
}
Yes i enabled email, but jam not sure i f it works, but on my server also doesn’t work. Any methods to check if emailing works?
when i use a other email php, where i have to put it? so my contact is in a subfolder
You could check your mail logs, on a UNIX/Mac System that should be in /var/log/mail.log. If you want to use another email.php, the site/plugin folder would be a good place.
Have you also edited your php.ini to enable mail? If you are using Mamp, that would be in conf/php5.x.x/php.ini, I don’t know what software you are using …
jes, exactly. I use MAMP on a MAC and change the sendmail_path. I finde out when i press submit nothing receives, i just echo my data but nothing receives. My contact template looks like this:
<div class="row row-fix kontaktbereich">
<div class="col-lg-6 col-md-6">
<form id="registrationForm" class="form-horizontal" method="post" action="email.php">
<div class="form-group">
<label class="col-xs-2 control-label">Name</label>
<div class="col-lg-8 col-md-8">
<input type="text" id="name" class="form-control" name="name" />
</div>
</div>
<div class="form-group">
<label class="col-xs-2 control-label">Firma</label>
<div class="col-lg-8 col-md-8">
<input type="text" class="form-control" name="Firma" />
</div>
</div>
<div class="form-group">
<label class="col-xs-2 control-label">E-Mail</label>
<div class="col-lg-8 col-md-8">
<input type="text" id="email" class="form-control" name="email" />
</div>
</div>
<div class="form-group">
<label class="col-xs-2 control-label">Telefon</label>
<div class="col-lg-8 col-md-8">
<input type="text" class="form-control" name="phone" />
</div>
</div>
<div class="form-group">
<label class="col-xs-12 col-md-2 col-lg-2 control-label">Rückruf</label>
<div class="col-lg-8 col-md-2">
<div class="radio">
<label>
<input type="radio" name="call" value="ja" /> JA
</label>
</div>
<div class="radio">
<label>
<input type="radio" name="call" value="nein" /> NEIN
</label>
</div>
</div>
</div>
<div class="form-group">
<label class="col-xs-2 control-label">Nachricht</label>
<div class="col-lg-8 col-md-8">
<textarea type="text" id="text" class="form-control" name="text" rows="8"/></textarea>
</div>
</div>
<div class="form-group">
<div class="col-xs-9 col-md-offset-2">
<button type="submit" class="btn btn-primary" name="signup" value="submit">Submit</button>
</div>
</div>
I think the best way to check this is by just trying to send an email via php mail()
command, that way you can test if it works without having to worry if the problem is in your code. I think the problem is rather how or if php works with sendmail.
In my php.ini in Mamp/conf/php5.6.6, I have made the following changes:
[mail function]
; For Win32 only.
;SMTP = localhost
;smtp_port = 25
; For Win32 only.
;sendmail_from = me@example.com
; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
;sendmail_path =
sendmail_path =/usr/sbin/sendmail -t -i -f mymail@example.com
yes, did exactly the same changes in php.ini file. Do you use the same form like in bastiansgeier guide?
Yes, I tested this with the same form (just copied and pasted from the gist into a fresh install) and it works without any problems on my system.
maybe because my contact is in a subfolder?
That shouldn’t make any difference, if the text file in your contact folder is called contact.txt it will look for the template contact.php and the controller contact.php and that’s all that is needed.
seems that it doesn´t work with my template. When i use Bastians Template it works, but when i just use my Button does´t work, too