2016-03-29 23 views
0

Ich brauche meine Form aus, um wie das folgende Beispiel zu generieren, statt alle EX-Abstand. Hallo _______, wie machst du das ______? Hoffe, du hast eine wundervolle Zeit _____________. bitte hilfe! Ich bin neu in der Programmierung!Wie kann ich mein Formular für mein Formular anzeigen lassen?

<html> 
     <head> 
      <title>Test1-1</title> 
     </head> 
     <body> 
    <?php 
    if (filter_has_var(INPUT_POST, "userName")){ 
    // the form exists, so work with it 
    $userName = filter_input(INPUT_POST, "userName"); 
    print "<h2>Hi $userName</h2>"; 
    } 

    if(filter_has_var(INPUT_POST, "morning")){ 
     filter_input(INPUT_POST, "morning"); 
     print"<h2>how are you doing this morning?</h2>"; 
    } 
    if(filter_has_var(INPUT_POST, "afternoon")){ 
     print"<h2>how are you doing this afternoon?</h2>"; 
     filter_input(INPUT_GET, "afternoon"); 
    } 
    if(filter_has_var(INPUT_POST, "evening")){ 
     print"<h2>how are you doing this evening?</h2>"; 
     filter_input(INPUT_POST, "evening"); 
    } 
    if(filter_has_var(INPUT_POST, "plan")){ 
     $plan = filter_input(INPUT_POST, "plan"); 
     print "<h2>Hope you have a wonderful time $plan</h2>"; 
    } 
    //there's no input. Create the form 
    print <<< HERE 

    <form action ="" method = "post"> 
    <fieldset> 
    <label>Please enter your name</label> 
    <input type = "text" 
      name = "userName"/><br> 
    <label>Time of Day</label> 
    <input type = "checkbox" 
      name = "morning"/> 
      <label>Morning</label> 
    <input type = "checkbox" 
      name = "afternoon"/> 
      <label>Afternoon</label> 
    <input type = "checkbox" 
      name = "evening"/> 
      <label>Evening</label><br> 
    <label>What are your plans?</label> 
      <input type = "text" 
      name = "plan"/><br> 
    <button type = "submit"> 
    submit 
    </button> 
    </fieldset> 
    </form> 
    HERE; 
    // end 'value exists' if 
    ?> 
     </body> 
    </html> 

Antwort

0

Eine Lösung ist es, die <h2> und </h2> Tags mit <span> und </span> zu ersetzen. Das wird sie platzieren wie du willst.

0
<html> 
    <head> 
     <title>Test1-1</title> 
    </head> 
    <body> 
<?php 
echo '<p>'; 
if (filter_has_var(INPUT_POST, "userName")){ 
// the form exists, so work with it 
$userName = filter_input(INPUT_POST, "userName"); 
print "Hi $userName"; 
} 

if(filter_has_var(INPUT_POST, "morning")){ 
    filter_input(INPUT_POST, "morning"); 
    print"how are you doing this morning?"; 
} 
if(filter_has_var(INPUT_POST, "afternoon")){ 
    print"how are you doing this afternoon?"; 
    filter_input(INPUT_GET, "afternoon"); 
} 
if(filter_has_var(INPUT_POST, "evening")){ 
    print"how are you doing this evening?"; 
    filter_input(INPUT_POST, "evening"); 
} 
if(filter_has_var(INPUT_POST, "plan")){ 
    $plan = filter_input(INPUT_POST, "plan"); 
    print "Hope you have a wonderful time $plan"; 
} 
echo '</p>'; 
//there's no input. Create the form 
print <<< HERE 

<form action ="" method = "post"> 
<fieldset> 
<label>Please enter your name</label> 
<input type = "text" 
     name = "userName"/><br> 
<label>Time of Day</label> 
<input type = "checkbox" 
     name = "morning"/> 
     <label>Morning</label> 
<input type = "checkbox" 
     name = "afternoon"/> 
     <label>Afternoon</label> 
<input type = "checkbox" 
     name = "evening"/> 
     <label>Evening</label><br> 
<label>What are your plans?</label> 
     <input type = "text" 
     name = "plan"/><br> 
<button type = "submit"> 
submit 
</button> 
</fieldset> 
</form> 
HERE; 
// end 'value exists' if 
?> 
    </body> 
</html> 
0

Der Grund die verschiedenen Teile auf verschiedenen Linien auftauchen werden, ist, dass man sie in <h2> Tags eingeschlossen haben.

HTML-Überschriftenelemente (wie <h2>) sind Elemente auf Blockebene. Here is a link zu einem gewissen Dokumentation für eine bessere Erklärung, was genau das bedeutet, aber kurz (aus dem verknüpften Dokument zitiert):

Browser angezeigt werden typischerweise das Block-Level-Element mit einem Newline sowohl vor als auch nach dem Elemente.

Um dies zu vermeiden, können Sie entweder einfach entfernen Sie die <h2> Tags oder ersetzen sie durch eine inline element wie <span>.

Verwandte Themen