pflichtfelder

Diese Seite verwendet Cookies. Durch die Nutzung unserer Seite erklären Sie sich damit einverstanden, dass wir Cookies setzen. Weitere Informationen

  • pflichtfelder

    guten morgen,
    neuer Tag neues Glück :)
    also ich hab hier ein Formular, das wenn ich auf Senden drücke gespeichert wird. Falls ein Feld ausgelassen wird, kommt eine Messagebox. Nun möcht ich aber das nicht nur eine Messagebox kommt sondern Die Daten die eingegeben wurden behalten werden UND die Felder die leer sind Rot umrandet werden.
    Hier mal mein Code

    PHP-Quellcode

    1. <?php
    2. error_reporting( -1 );
    3. ini_set('display_errors', TRUE);
    4. ob_start();
    5. setlocale(LC_TIME, "de_DE");
    6. date_default_timezone_set("Europe/Berlin");
    7. ?>
    8. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    9. <html xmlns="http://www.w3.org/1999/xhtml">
    10. <head>
    11. <style type="text/css">
    12. <!--
    13. .text {
    14. position: relative;
    15. margin-top: 160px;
    16. height: 160px;
    17. font-color: yellow;
    18. }
    19. -->
    20. </style>
    21. <title>Supportinfo</title>
    22. </head>
    23. <body background="hintergrundfertig.png" alt="Bild">
    24. <form action="<?php echo $_SERVER['SCRIPT_NAME']; ?>" method="post">
    25. <div align="right" style="position:absolute;top:190px; right:0px;"><font color="yellow"><b>
    26. Nachname:<input type="text" name="Nachname" size="50" /><br />
    27. Vorname:<input type="text" name="Vorname" size="50" /><br />
    28. E-Mail:<input type="text" name="Email" size="50" /><br />
    29. Betreff:<input type="text" name="Betreff" size="50" /><br />
    30. <textarea name="Nachricht" cols="60" rows="20"></textarea><br />
    31. <input type="submit" value="Senden" /><input type="reset" value="Abbrechen" />
    32. </div>
    33. </form>
    34. <?php
    35. if(isset($_POST['Nachname']))
    36. {
    37. $komplett= true;
    38. $Email = $_POST['Email'];
    39. $Betreff = $_POST['Betreff'];
    40. $Nachricht = $_POST['Nachricht'];
    41. $Nachname = $_POST['Nachname'];
    42. $Vorname = $_POST['Vorname'];
    43. $Datum = date('d-m-y');
    44. $Uhrzeit = date('h-i-s');
    45. $Trennzeichen= ("_");
    46. $Leerzeichen = (" ");
    47. $Datei = $Vorname.$Trennzeichen.$Nachname.$Trennzeichen.$Datum.$Trennzeichen.$Uhrzeit.".txt";
    48. $Text = $Vorname.$Leerzeichen. $Nachname.$Leerzeichen. $Email.$Leerzeichen.$Datum.$Leerzeichen. $Uhrzeit.$Leerzeichen.$Betreff.$Nachricht;
    49. if ($Email == "" Or $Betreff == "" Or $Nachricht == "" Or $Nachname=="" Or $Vorname=="" )
    50. {$komplett = false ;
    51. echo "<p align=\"center\" class=\"text\"> Bitte fuellen sie alle Felder aus!</p>"; }
    52. if ($komplett)
    53. {
    54. $FilePointer = fopen($Datei, "w");
    55. fwrite($FilePointer, $Text);
    56. fclose($FilePointer);
    57. }
    58. if(file_exists($Datei))
    59. {
    60. ?>
    61. <script type="text/javascript">
    62. alert("Ihre Email wurde versendet.");
    63. </script>
    64. <?php
    65. }
    66. }
    67. ?>
    68. <script type="javascript">
    69. <STYLE type="text/css">
    70. .okButton {
    71. background-color: #D4D4D4;
    72. font-color: #000000;
    73. font-size: 9pt;
    74. font-family: arial;
    75. width: 70px;
    76. height: 20px;
    77. }
    78. .alertTitle {
    79. background-color: #3C56FF;
    80. font-family: arial;
    81. font-size: 9pt;
    82. color: #FFFFFF;
    83. font-weight: bold;
    84. }
    85. .alertMessage {
    86. font-family: arial;
    87. font-size: 9pt;
    88. color: #000000;
    89. font-weight: normal;
    90. }
    91. .alertBoxStyle {
    92. cursor: default;
    93. filter: alpha(opacity=90);
    94. background-color: #E4E4E4;
    95. position: absolute;
    96. top: 200px;
    97. left: 200px;
    98. width: 100px;
    99. height: 50px;
    100. visibility:hidden; z-index: 999;
    101. border-style: groove;
    102. border-width: 5px;
    103. border-color: #FFFFFF;
    104. </STYLE>
    105. <div id="alertLayer" class=alertBoxStyle></div>
    106. <SCRIPT LANGUAGE="JavaScript">
    107. function BrowserCheck() {
    108. var b = navigator.appName;
    109. if (b == "Netscape") this.b = "NS";
    110. else if (b == "Microsoft Internet Explorer") this.b = "IE";
    111. else this.b = b;
    112. this.v = parseInt(navigator.appVersion);
    113. this.NS = (this.b == "NS" && this.v>=4);
    114. this.NS4 = (this.b == "NS" && this.v == 4);
    115. this.NS5 = (this.b == "NS" && this.v == 5);
    116. this.IE = (this.b == "IE" && this.v>=4);
    117. this.IE4 = (navigator.userAgent.indexOf('MSIE 4')>0);
    118. this.IE5 = (navigator.userAgent.indexOf('MSIE 5')>0);
    119. if (this.IE5 || this.NS5) this.VER5 = true;
    120. if (this.IE4 || this.NS4) this.VER4 = true;
    121. this.OLD = (! this.VER5 && ! this.VER4) ? true : false;
    122. this.min = (this.NS||this.IE);
    123. }
    124. is = new BrowserCheck();
    125. alertBox = (is.VER5) ? document.getElementById("alertLayer").style
    126. : (is.NS) ? document.layers["alertLayer"]
    127. : document.all["alertLayer"].style;
    128. function hideAlert(){
    129. alertBox.visibility = "hidden";}
    130. function makeAlert(aTitle,aMessage){
    131. document.all.alertLayer.innerHTML = "<table border=0 width=100% height=100%>" +
    132. "<tr height=5><td colspan=4 class=alertTitle>" + " " + aTitle + "</td></tr>" +
    133. "<tr height=5><td width=5></td></tr>" +
    134. "<tr><td width=5></td><td width=20 align=left><img src='alert.gif'></td><td align=center class=alertMessage>" + aMessage + "<BR></td><td width=5></td></tr>" +
    135. "<tr height=5><td width=5></td></tr>" +
    136. "<tr><td width=5></td><td colspan=2 align=center><input type=button value='OK' onClick='hideAlert()' class=okButton><BR></td><td width=5></td></tr>" +
    137. "<tr height=5><td width=5></td></tr></table>";
    138. //thisText = aMessage.length;
    139. thisText = 2000
    140. if (aTitle.length > aMessage.length){ thisText = aTitle.length; }
    141. aWidth = (thisText * 5) + 80;
    142. aHeight = 100;
    143. if (aWidth < 150){ aWidth = 200; }
    144. if (aWidth > 350){ aWidth = 350; }
    145. if (thisText > 60){ aHeight = 110; }
    146. if (thisText > 120){ aHeight = 130; }
    147. if (thisText > 180){ aHeight = 150; }
    148. if (thisText > 240){ aHeight = 170; }
    149. if (thisText > 300){ aHeight = 190; }
    150. if (thisText > 360){ aHeight = 210; }
    151. if (thisText > 420){ aHeight = 230; }
    152. if (thisText > 490){ aHeight = 250; }
    153. if (thisText > 550){ aHeight = 270; }
    154. if (thisText > 610){ aHeight = 290; }
    155. alertBox.width = aWidth;
    156. alertBox.height = aHeight;
    157. alertBox.left = (document.body.clientWidth - aWidth)/2;
    158. alertBox.top = (document.body.clientHeight - aHeight)/2;
    159. alertBox.visibility = "visible";
    160. }
    161. // WHEN YOU WANT TO GENERATE AN ALERT DO THIS:
    162. // CALL THE makeAlert FUNCTION AND PASS THE ALERT TITLE AND THE MESSAGE
    163. // TO THE FUNCTION.
    164. // eg. makeAlert('My Alert Title' , 'My Alert Message');
    165. </SCRIPT>
    166. </body>
    167. </html>
    Alles anzeigen

    da ich mit Java-Script noch nicht viel gemacht habe wäre ich euch Dankbar wenn ihr mir ein Beispiel zeigen könntet.
    Liebe Grüße