Navigation Menu

Skip to content

Commit

Permalink
Form handling
Browse files Browse the repository at this point in the history
  • Loading branch information
RalphAtHamburg committed Mar 29, 2012
1 parent 2f305a3 commit 224a88c
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 7 deletions.
26 changes: 25 additions & 1 deletion 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"
Expand All @@ -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 ""



Expand Down
11 changes: 6 additions & 5 deletions source/localizable/kontakt.html.haml
Expand Up @@ -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
26 changes: 26 additions & 0 deletions 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."; }

?>
1 change: 1 addition & 0 deletions source/stylesheets/_common.sass
Expand Up @@ -10,6 +10,7 @@ $text-invert: #FFF
$light-text: #999
$top-border: #000
$light-grey: #f3f3f3
$form-error: red

// Fonts
@mixin headline-font
Expand Down
8 changes: 7 additions & 1 deletion 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

0 comments on commit 224a88c

Please sign in to comment.