Fosa
Fosa

Reputation: 457

Check value of form that has 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>

Upvotes: 0

Views: 391

Answers (2)

Rakesh Sharma
Rakesh Sharma

Reputation: 13738

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'])){

Upvotes: 5

user3040610
user3040610

Reputation: 760

Try with the below code

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

Upvotes: 0

Related Questions