I am creating a form where I am using $_POST php function.
Here is how my form looks like.
form.php
<h1>Songs Movies Form</h1>
<hr />
<form action="songs-movies.php" method="post">
Song Name:
Enter Song Name: <input type="text" name="SongName" size="25" />
Enter Movie Name: <input type="text" name="MovieName" size="25" />
<input type="submit" value="Submit" name="submit" />
</form>
<br />
<a href="/forms/">Back to Forms</a>
<hr />
Now I want to display result of SongName and MovieName, so I used echo $_POST["SongName"]; and echo $_POST["MovieName"]; which generates the result perfectly.
Now I want to put these values SongName and MovieName between the text/line/para in the result/output page and if the value of SongName or MovieName is empty then the result/output should not display that specific text/line/para where I have put those functions.
e.g.
ABC Song is the popular Song of the XYZ Movie. The ABC Song of XYZ Movie is directed by PQR Director.
Now you can see there are two sentences in the above Para. I want to put the function for the first sentence only when the field values of SongName and MovieName are empty then
- It should display the first sentence whether the field values of SongName and MovieName is empty or not i.e. ABC Song is the popular Song of the XYZ Movie. If the field values of SongName and MovieName are empty then it can leave blank space between them and I know it can be done through this function echo $_POST["SongName"];.
BUT
- It should not display the first sentence line if the field values of SongName and MovieName are empty i.e. The ABC Song of XYZ Movie is directed by PQR Director.
$_POST['key']
is set withisset($_POST['key'])
and then do whatever you like.