dongmi5607 2015-02-10 05:41
浏览 20
已采纳

检查具有Placeholder PHP的表单的值

I would like to achieve this goal:

If the input in an form contains the standard value of the placeholder. In this case "did not receive invitation...", Then an variable which contains the input value may also be : "did not receive invitation..."

BUT if the user overwrites the placeholder and gives in an email-address, That same variable must become that email-address.

This is my form: it's in dutch...sorry for that

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

this is my PHP:

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

For some reason my output is always :

did not receive invitation...

Even if I fill in an email address..

Any suggestions ?

Edit... Full form Code:

<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>
  • 写回答

2条回答 默认 最新

  • dongmimeng5500 2015-02-10 05:45
    关注

    Your form method is POST so you need to check post values using $_POST

    just replace

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

    to

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

    Also you have wrong code above for invite input if you check your full form code there is not any invite input field so use email instead of invite like

    if (!empty($_POST['email'])){
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题