224k views
2 votes
Create a PHP page that contains an array of at least 20 movie titles or book titles (your choice). The HTML page should have an input box for the user to enter a username and a title of a favorite movie or a book. After the user enters a username, the page should display a welcome message.

1 Answer

7 votes

Answer:

This is the code

Step-by-step explanation:

<html>

<form method="POST" action="welcome.php">

label for="usname">username:</label><br>

<input type="text" id="usname" name="usname"><br>

<label for="movietitles">Movietitles</label><br>

<textarea type="text" id="movetitle" name="movietitles">Please enter movie titles</textarea>

<input type="submit">

</form>

</html>

<?php

$Movietitles= array("bland", "decoy","Mademan", "Rich", "bland", "decoy","Mademan", "Rich", "bland", "decoy","Mademan", "Rich" , "bland", "decoy","Mademan", "Rich, "decoy","Mademan", "Rich", "Adapt" );

$username= $_POST['username'];

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

$username = $_POST['username'];

echo "Welcome";

}

?>

The post method HTTP request is used to send the data from the form to the Welcome.php file above so that it validates/tests that username has been entered using the php if statement and if it is not empty(entered username) php "echos" welcome to the screen.

User Ankesh
by
5.2k points