Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Form handling

  • Loading branch information...
commit 224a88cacb4e8c848cc67fecb1287cb3ef2f710b 1 parent 2f305a3
@RalphAtHamburg authored
View
26 source/javascripts/script.js.coffee
@@ -1,6 +1,7 @@
# See http://coffeescript.org/
-# Load tweets for user
+# ----- Load tweets for user --------------------
+
jQuery ($) ->
$(".tweet").tweet
username: "ralphathamburg"
@@ -12,6 +13,29 @@ jQuery ($) ->
auto_join_text_url: ""
count: 8
loading_text: "Lade Tweets ..."
+
+# ----- Form handling --------------------
+
+$ ->
+ $("#contact").submit ->
+ str = $(this).serialize()
+
+ if $("#_name").val() is "" or $("#_mail").val() is "" or $("#_anfrage").val() is ""
+ $("#note").css('color', 'red');
+ $("#note").html "Bitte füllen Sie alle Felder aus."
+ return true
+
+ $.ajax
+ type: "POST"
+ url: "sendmail.php"
+ data: str
+ success: (msg) ->
+ $("#note").ajaxComplete (event, request, settings) ->
+ $("#note").css('color', 'black');
+ $(this).html msg
+ $("#_name").val ""
+ $("#_mail").val ""
+ $("#_anfrage").val ""
View
11 source/localizable/kontakt.html.haml
@@ -33,15 +33,16 @@
%form#contact{:action => 'javascript:;'}
%label{:for => "name"}= t("form.name")
- %input{:type => "text", :name => "name"}
+ %input{:type => "text", :name => "name", :id => "_name"}
- %label{:for => "email"}= t("form.mail")
- %input{:type => "text", :name => "email"}
+ %label{:for => "mail"}= t("form.mail")
+ %input{:type => "text", :name => "mail", :id => "_mail"}
%label{:for => "anfrage"}= t("form.anfrage")
- %textarea{:type => "text", :name => "Anfrage", :rows => "10"}
+ %textarea{:type => "text", :name => "anfrage", :id => "_anfrage", :rows => "10"}
%br
%button{:type => 'submit'}= t("form.abschicken")
-
+
+ %p#note
View
26 source/sendmail.php
@@ -0,0 +1,26 @@
+<?php
+
+// Predefined Variables
+$sender = "noreply@ralph-moecklinghoff.de";
+$to = "mail@ralph-moecklinghoff.de";
+$subject = "Anfrage über Homepage";
+
+$name = htmlspecialchars($_REQUEST['name']);
+$mail = htmlspecialchars($_REQUEST['mail']);
+$anfrage = htmlspecialchars($_REQUEST['anfrage']);
+
+$message = "Anfrage von der Website:\n\nName: " . $name . "\nMail:\t" . $mail ."\nAnfrage:\t" . $anfrage;
+
+$headers = "From: $sender";
+
+$sent = mail($to, $subject, $message, $headers);
+
+$headers = "From: $fromnReply-To:
+$fromnContent-type: text/plain; charset=iso-8859-1";
+
+if($sent)
+ {print "Vielen Dank für Ihre Kontaktaufnahme, ich melden mich bei Ihnen."; }
+else
+ {print "Beim Senden der Anfrage ist leider ein Fehler aufgetreten."; }
+
+?>
View
1  source/stylesheets/_common.sass
@@ -10,6 +10,7 @@ $text-invert: #FFF
$light-text: #999
$top-border: #000
$light-grey: #f3f3f3
+$form-error: red
// Fonts
@mixin headline-font
View
8 source/stylesheets/_kontakt.sass
@@ -1,3 +1,9 @@
//
// Kontakt Page Stylesheet
-//
+//
+
+.kontakt
+
+ p#note
+ margin: 1em 2.2em 0 0
+ font-family: gesta, 'Lucida Grande', 'Lucida Sans Unicode', Arial, sans-serif
Please sign in to comment.
Something went wrong with that request. Please try again.