2015-02-10 104 views
0

我想实现这个目标:检查占位符表单的值PHP

如果表单中的输入包含占位符的标准值。 在这种情况下,“没有收到邀请函......”, 那么它包含输入值也可以是一个变量:“没有收到邀请函......”

但如果用户覆盖占位符,并给出了一个电子邮件地址, 该变量必须成为该电子邮件地址。

这是我的形式: 它在荷兰...为了

<label for="invite">Email contact invitation</label> 
    <input name="invite" type="text" id="invite" style="width:200px" 
      placeholder="did not receive invitation..."/><br/> 

抱歉,这是我的PHP:

if (!empty($_GET['invite'])) { 
    $invitation = filter_input(INPUT_POST, 'invite'); 
} else { 
    $invitation = "did not receive invitation..."; 
} 

出于某种原因,我的输出永远是:

未收到邀请...

即使我填写一个电子邮件地址..

有什么建议吗?

编辑... 赛程表编号:

<form class="cmxform" id="Offerteform" method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>" enctype="multipart/form-data"> 
    <div> 

    <label for="Uitnodiging">Email contact uitnodiging</label> 
    <input name="Uitnodiging" type="text" id="Uitnodiging" style="width:200px" placeholder="Geen uitnodiging ontvangen..." /> 
    <br/> 

    <label for="Soort_Werken">Soort Werken</label> 
    <select name="Soort Werken" id="Soort_Werken" style="width:200px" title="Selecteer iets AUB!" required> 
     <option selected="selected" value="">Selecteer...</option> 
     <option value="algemene schoonmaak">algemene schoonmaak</option> 
     <option value="industriële reiniging">industriële reiniging</option> 
     <option value="petrochemische reiniging">petrochemische reiniging</option> 
     <option value="nucleaire reiniging">nucleaire reiniging</option> 
     <option value="oplevering werkzaamheden">oplevering werkzaamheden</option> 
     <option value="werken in onderaanneming">werken in onderaanneming</option> 
     <option value="calamiteiten">calamiteiten</option> 
     <option value="schoonmaak voertuigen">schoonmaak voertuigen</option> 
     <option value="ruitenwassen">ruitenwassen</option> 
     <option value="andere">andere</option> 
    </select> 
    <br/> 


    <label for="Frequentie">Frequentie</label> 
    <select name="Frequentie" id="Frequentie" style="width:200px" title="Selecteer iets AUB!" required> 
     <option selected="selected" value="">Selecteer...</option> 
     <option value="eenmalig">eenmalig</option> 
     <option value="dagelijks">dagelijks</option> 
     <option value="wekelijks">wekelijks</option> 
     <option value="maandelijks">maandelijks</option> 
     <option value="anders">anders</option> 
    </select> 
    <br/> 


    <label for="Oppervlakte">Oppervlakte in m²</label> 
    <input name="Oppervlakte" type="text" id="Oppervlakte" style="width:200px" /> 
    <br/> 


    <label for="Bedrijfsnaam">Bedrijfsnaam</label> 
    <input name="Bedrijfsnaam" type="text" id="Bedrijfsnaam" style="width:200px" /> 
    <br/> 


    <label for="Contactpersoon_achternaam">Contactpersoon Naam</label> 
    <input name="Contactpersoon_achternaam" type="text" id="Contactpersoon_achternaam" style="width:200px" /> 
    <br/> 

    <label for="Contactpersoon_voornaam">Contactpersoon Voornaam</label> 
    <input name="Contactpersoon_voornaam" type="text" id="Contactpersoon_voornaam" style="width:200px" /> 
    <br/> 


    <label for="Functie">Functie</label> 
    <input name="Functie" type="text" id="Functie" style="width:200px" /> 
    <br/> 


    <label for="Telefoon">Telefoon</label> 
    <input name="Telefoon" type="text" id="Telefoon" style="width:200px" /> 
    <br/> 


    <label for="email">E-mail</label> 
    <input name="email" type="email" id="email" style="width:200px" /> 
    <br/> 
    <br/> 

    <label for="Werkzaamheden">Type Werkzaamheden</label> 

    <br/> 


    <br/> 
    <label> 
     <input type="checkbox" name="Werkzaamheden[]" value="kantoor onderhoud" id="Werkzaamheden_0" required/>kantoor onderhoud</label> 
    <label> 
     <input type="checkbox" name="Werkzaamheden[]" value="tapijtreiniging" id="Werkzaamheden_1" />tapijtreiniging 
    </label> 
    <br/> 

    <label> 

     <input type="checkbox" name="Werkzaamheden[]" value="stoomreiniging" id="Werkzaamheden_2" />stoomreiniging 
    </label> 
    <label> 
     <input type="checkbox" name="Werkzaamheden[]" value="hogedrukreiniging" id="Werkzaamheden_3" />hogedrukreiniging 
    </label> 
    <br /> 
    <label> 
     <input type="checkbox" name="Werkzaamheden[]" value="vloer onderhoud" id="Werkzaamheden_4" />vloer onderhoud</label> 
    <label> 
     <input type="checkbox" name="Werkzaamheden[]" value="sanitair onderhoud" id="Werkzaamheden_5" />sanitair onderhoud</label> 
    <br /> 
    <label> 
     <input type="checkbox" name="Werkzaamheden[]" value="gevelreiniging" id="Werkzaamheden_6" />gevelreiniging 
    </label> 
    <label> 
     <input type="checkbox" name="Werkzaamheden[]" value="hoogwerker" id="Werkzaamheden_7" />hoogwerker 
    </label> 
    <br /> 
    <label> 
     <input type="checkbox" name="Werkzaamheden[]" value="andere" id="Werkzaamheden_8" />andere 
    </label> 
    <br/> 
    <br/> 

    <label for="Werkzaamheden" class="error1">Selecteer type AUB.</label> 

    <br/> 
    <br/> 

    <div id="Opmerking"> 
     <label for="opmerkingen">Opmerkingen</label> 

     <textarea name="opmerkingen" id="opmerkingen" cols="50" rows="9" style="width:350px"></textarea> 
    </div> 
    <div id="knoppen"> 

     <input name="send" type="submit" class="submit2" id="send" value="verzenden" /> 
     <input name="reset" type="reset" class="submit2" id="reset" value="wissen" /> 
    </div> 
    </div> 
</form> 
+0

你可以显示你的表单完整的代码吗? – 2015-02-10 05:42:54

回答

5

你的形式方法是POST所以你需要使用$_POST

检查值后只需更换

if (!empty($_GET['invite'])){ 

if (!empty($_POST['invite'])){ 

你也有错误的代码上面的邀请输入,如果您检查您的完整形式的代码没有任何邀请输入字段所以使用电子邮件,而不是invite

if (!empty($_POST['email'])){ 
+0

没有修复它:(编辑!!我改变了错误的IF语句!它的工作原理!! thanx !!问题已解决 – Fosa 2015-02-10 05:50:45

+0

检查我的更新回答 – 2015-02-10 05:55:24

+0

我知道这里没有邀请字段。英语邀请的荷兰语是“Uitnodiging”,这不是让英国人在这里混淆,但我想我变得更糟了嘿嘿,它现在工作Thanx人! – Fosa 2015-02-10 05:59:13

0

与下面的代码

尝试
if (isset($_POST['invite'])){ 
$invitation = filter_input(INPUT_POST, 'invite'); 
} 
else{ 
$invitation = "did not receive invitation..."; 
} 
+0

我不认为isset会工作原因isset检查如果变量存在,我不想检查它是否存在,因为它显然确实,我想检查它的值,所以我需要'空' – Fosa 2015-02-10 06:01:17