Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6124145
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:05:58+00:00 2026-05-23T16:05:58+00:00

I made this function to display a form, the form had to be sticky

  • 0

I made this function to display a form, the form had to be sticky so I wanted to add an if POST is set that it echoes that value. This makes sure that when a user enters bad input, all the right input will still be in filled out. However I used to use

<input type="text" name="Avoornaam"  value = "<?php if(isset($_POST['Avoornaam'])){echo htmlentities($_POST['Avoornaam']);} ?>"/>

But now I want to migrate that to a function :

function BabysitterForm(){
        return '        <form id="form_206335" class="appnitro"  method="post" action="self">
                        <div class="form_description">
                <h2>Babysitter</h2>
                <p>Gelieve je hier in te schrijven als babysitter</p>
            </div>                      
                <ul >

                        <li id="li_1" >
            <label class="description" for="element_1">Naam </label>
            <div>
                <input id="element_1" name="element_1" class="element text medium" type="text" maxlength="255" value="'.if(isset($_POST['Avoornaam'])){echo htmlentities($_POST['Avoornaam']);}.'"/> 
            </div><p class="guidelines" id="guide_1"><small>Voer uw naam in.</small></p> 
            </li>       <li id="li_2" >
            <label class="description" for="element_2">Voornaam </label>
            <div>
                <input id="element_2" name="element_2" class="element text medium" type="text" maxlength="255" value=""/> 
            </div><p class="guidelines" id="guide_2"><small>Vul uw voornaam in.</small></p> 
            </li>       <li id="li_3" >
            <label class="description" for="element_3">Adres </label>
            <div>
                <input id="element_3" name="element_3" class="element text medium" type="text" maxlength="255" value=""/> 
            </div><p class="guidelines" id="guide_3"><small>vul uw straat en huisnummer in.</small></p> 
            </li>       <li id="li_4" >
            <label class="description" for="element_4">Woonplaats </label>
            <div>
                <input id="element_4" name="element_4" class="element text medium" type="text" maxlength="255" value=""/> 
            </div><p class="guidelines" id="guide_4"><small>vul uw woonplaats in.</small></p> 
            </li>       <li id="li_5" >
            <label class="description" for="element_5">Postcode </label>
            <div>
                <input id="element_5" name="element_5" class="element text small" type="text" maxlength="255" value=""/> 
            </div><p class="guidelines" id="guide_5"><small>Vul uw Postcode hier in</small></p> 
            </li>       <li id="li_6" >
            <label class="description" for="element_6">telefoonnummer </label>
            <div>
                <input id="element_6" name="element_6" class="element text medium" type="text" maxlength="255" value=""/> 
            </div><p class="guidelines" id="guide_6"><small>Vul uw telefoonnummer in.</small></p> 
            </li>       <li id="li_7" >
            <label class="description" for="element_7">email </label>
            <div>
                <input id="element_7" name="element_7" class="element text medium" type="text" maxlength="255" value=""/> 
            </div><p class="guidelines" id="guide_7"><small>vul uw email in.</small></p> 
            </li>       <li id="li_8" >
            <label class="description" >Geboortedatum </label>
            <span>
                <input id="element_8_1" name="element_8_1" class="element text" size="2" maxlength="2" value="" type="text"> /
                <label for="element_8_1">MM</label>
            </span>
            <span>
                <input id="element_8_2" name="element_8_2" class="element text" size="2" maxlength="2" value="" type="text"> /
                <label for="element_8_2">DD</label>
            </span>
            <span>
                <input id="element_8_3" name="element_8_3" class="element text" size="4" maxlength="4" value="" type="text">
                <label for="element_8_3">YYYY</label>
            </span>

            <li id="li_10" >
            <label class="description" for="element_10">Wachtwoord </label>
            <div>
                <input id="element_10" name="element_10" class="element text medium" type="text" maxlength="255" value=""/> 
                <input id="element_10_1" name="element_10_1" class="element text medium" type="text" maxlength="255" value=""/> 
            </div><p class="guidelines" id="guide_10"><small>Vul uw wachtwoord twee maal in. Hierdoor voorkomt men typfouten door validatie.</small></p> 
            </li>       



                <li id="li_9" >
            <label class="description" for="element_9">Opmerkingen </label>
            <div>
                <textarea id="element_9" name="element_9" class="element textarea medium"></textarea> 
            </div> 
            </li>

                        <li class="buttons">
                    <input type="hidden" name="form_id" value="206335" />

                    <input id="saveForm" class="button_text" type="submit" name="submit" value="Submit" />
            </li>
                </ul>
            </form> ';
    }

The problem is that I get a syntax error on my if where I concatinate the function with the HTML.

Anyone a nice solution ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T16:05:58+00:00Added an answer on May 23, 2026 at 4:05 pm

    Instead of

    "'.if(isset($_POST['Avoornaam'])){echo htmlentities($_POST['Avoornaam']);}.'"
    

    You could use something like

    "'.((isset($_POST['Avoornaam']))?htmlentities($_POST['Avoornaam']):'').'"
    

    But this is a lot worse to read than the other solution posted by Mike.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Since I'm sure many people have different standard, I've made this post a community
This is something that made me doubt for a while so I thought it
Reading this blog post about HttpOnly cookies made me start thinking, is it possible
I have a get/post/JSON function on an aspx page. This page adds data entered
I have started using jQuery and rails. I have made a simple form that
I'd to create some transitions between pages. I've made it this way: $(div.fading).css('display', 'none');
I made a form with ajax email validation. My problem is that I need
I made this web service that returns a datatable from sql server db. Can
Made this custom alert box: <script type="text/javascript"> $(function () { var $alert = $('#alert');
I've made this decorator, which results in an infinite redirect loop. The problem is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.