I am making a website for movie ticket booking , I have added several images of the movie posters in the landing page. I wanted to make it as when the user clicks on the image of a particular movie poster it displays the name of the movie on the next webpage. So the problem is I don’t know know how to send the name of the movie the user has clicked on to the next page through php with or without using the form tag.?
I have tried by giving the images of the posters ID’s as the movie name and retrieve the name of the movie from the ID as-:
<?php
$name = $_POST['Name']
?>
here ‘Name’ is the name of the movie given as the ID of the image in html
but this does not work!`
2
Answers
If the user is only clicking on a link then the general approach is to put a query string value on that link.
For example:
Then in
movie.php
you’d get the "123" value with:And you’d query your database (or wherever you store your data) using that
$id
value to get the specific record you’re looking for.I have created you a simple demo for what you are asking using good php security. You can take what I have done here and improve on it however you like. I have made the code as simple as possible.
The premise of this code is based on security. For something like this always pass an id / number in the query string and access your data like this:
test.php?id=3
I will keep your code secure and easy to manage.
Create a file named test.php and add the below code