Search code examples
phphtmlformsisset

how to add html form in php?


how do you add a html form in php? I have to check a condition from isset i.e if session has been set only then should the form be displayed. ECHO statement is not working because of ""

<pre>
<form action="index.php" method="post">
<br />
&nbsp;First Name:    Last Name:<br/>
<input type="text" name="firstname" placeholder ="First Name"/>  
<input type="text" name="lastname" placeholder ="Last Name"/><br />

&nbsp;Email-id:<br />
<input type="text" name="email-id" placeholder ="Your Email-id"/><br />

&nbsp;Password:<br />
<input type="password" name="password" placeholder ="Your Password"/>
<br />
&nbsp;Re-enter Password:<br />
<input type="password" name="password1" placeholder ="Re-enter Password"/>
<br /></form><pre>

Solution

  • <?php if( isset( $_SESSION['someValue'] ) ): ?>
    <form action="index.php" method="post">
        <p>Whatevs...</p>
    </form>
    <?php endif; ?>