Getting value from Select dropdown list (HTML) to .PHP file and show an image based off selection-ThrowExceptions

Exception or error:

I have an assignment due for my web developing class. I am currently having trouble with a part of an assignment. My prof wants us to make a two page web application where the user specifies a t-shirt color, size, and text to be written on the t shirt itself. The second page is supposed to be php only, using the selected choices from the html page and displaying what the user wants on his/her shirt in the .php page. I am currently having trouble trying to figure out how to display a tshirt image from the drop down menu of 3 choices, which are “red”,”blue” and “green”. I am a total rookie to this and I would just like some help if anyone could kindly tell me what I can do to make this work.

html code

<label for ="colorShirt" name = "colorshirt" method = "get"> Select Color of Shirt: </label>
    <select name= "var">
      <option name = "var[]" method = "get"> Red </option>
      <option name = "var[]" method = "get"> Blue </option>
      <option name = "var[]" method = "get"> Green </option>
      <input type="submit" name = "submit" value = "proceed"><a href = "tshirt.php"></a>

php code for dropdown menu


   for ($i=0; $i < count($_GET["var"]); $i++ ){
     echo $_GET["var"][$i]
      if ($_GET ["var"][0]){
         echo'<img src="../a1/images/redt.png"/>';
       else if ($_GET["var"][1]){
         echo '<img src="../a1/images/bluet.png"/>';
      else if ($_GET["var"][2]){
         echo '<img src="../a1/images/greent.png"/>';

How to solve:

Leave a Reply

Your email address will not be published. Required fields are marked *