Sponsor-Board.de
Form value JS Abfrage

+- Sponsor-Board.de (https://www.sponsor-board.de)
+-- Forum: Community (/forumdisplay.php?fid=56)
+--- Forum: Hilfe (/forumdisplay.php?fid=102)
+---- Forum: Scripting (/forumdisplay.php?fid=108)
+---- Thema: Form value JS Abfrage (/showthread.php?tid=7536)


Form value JS Abfrage - Sysix - 26.10.2010 19:22

Hallo Smile

Ich versuch mal eine E-mail Funktion zu bauen. Das Senden der E-mail klappt ja schon Super, auch wenn der Sicherheitscode falsch ist zeigt er mir an, dass es ein Fehler ist.
Bloß jetzt will ich, dass wenn Die Values Ausgelassen worden sind ein Fenster beim Abschicken kommt, dass man etwas vergessen hat. Wie bei Artikel FUnktion von Webspell..

Mein Code sieht so aus:

Code:
<script type="text/javascript">
function submitform()
{
    document.forms["kontakt_form"].submit();
}
function chkFormular () {

    if (document.Formular.title.value == "") {
        alert("Bitte ein Titel eingeben!");
        document.Formular.title.focus();
        return false;
    }
    
    if (document.Formular.title.value == "Titel") {
        alert("Bitte ein Titel eingeben!");
        document.Formular.title.focus();
        return false;
    }
    
    if (document.Formular.mail.value == "") {
        alert("Bitte eine E-Mail Adresse eingeben!");
        document.Formular.mail.focus();
        return false;
    }
    
    if (document.Formular.mail.value.indexOf("@") == -1) {
    alert("Bitte eine E-Mail Adresse eingeben!");
    document.Formular.mail.focus();
    return false;
      }

    
    if (document.Formular.ucode.value == "") {
        alert("Bitte den Sicherheitscode eingeben!");
        document.Formular.ucode.focus();
        return false;
    }
}
</script>


<?php

if($_POST) {
    $tomail = '----';
    $mail = $_POST['mail'];
    $title = $_POST['title'];
    $text = $_POST['text'];
    $text=str_replace('\r\n', "\n", $text);
    $normalcode = $_POST['code'];
    $usercode = $_POST['ucode'];
    $header="From:$from\n";
    $header.= "Reply-To: $from\n";
    $header.="Content-Type: text/html; charset=utf-8\n";
    
    if ($normalcode == $usercode) {
        mail($tomail, $title, $text, $header);
        $error = 'Erfolgreich abgeschickt';
    } else { $error = 'Sicherheitscode falsch'; }
    
}

$zahl = rand(10000, 99999);

?>
<h1>Kontakt aufnehmen</h1>
        <div id="kontakt_gerust">
          <div id="kontakt_links">
              <div id="kontakt_links_text">Titel:<br /><br /><br />E-mail:<br /><br /><br />
              Naricht:</div>
            <div id="kontakt_warning">
                ------</div>        
          </div>
          <div id="kontakt_rechts">
          <?php echo $error; ?>
          <form action="index.php?site=kontakt" method="post" id="kontakt_form" name="Formular"  onsubmit="return chkFormular()">
              <input type="text" value="Titel" name="title" /><br /><br /><input type="text" name="mail"  />
              <textarea rows="10" cols="10" name="text" >Naricht</textarea>
            <input value="<?php echo $zahl; ?>" type="hidden" name="code" /> <?php echo $zahl; ?> <input value="" type="text" maxlength="5" name="ucode" id="kontakt_code" /><a href="javascript: submitform();">Senden</a>
            </form>
          </div>
        </div>


Hoffe ihr könnt mir helfen Biggrin

MFG Sysix


RE: Form value JS Abfrage - KingKaSo - 26.10.2010 19:28

Warum mit JS? Und warum nihct php?


RE: Form value JS Abfrage - pl0x - 26.10.2010 19:34

@Kaso
Darum.


RE: Form value JS Abfrage - Sysix - 26.10.2010 20:07

Wenn ich es mit PHP mache muss ich die Seite neu laden.

Und so wird vor den Abschicken ein Fenster geöffnet. Und das Abschicken unterbrochen

Mit freundlichen Grüßen

Sysix


RE: Form value JS Abfrage - Tobias - 26.10.2010 20:09

Sysix schrieb:
Wenn ich es mit PHP mache muss ich die Seite neu laden.

Und so wird vor den Abschicken ein Fenster geöffnet. Und das Abschicken unterbrochen

Mit freundlichen Grüßen

Sysix


Genau Biggrin