php - If statement in my switch program doesn't work. What am I doing wrong? -


this program supposed show dropdown selection user, output of response particular choice using switch statement in php. can't if statement work though. can me please? thank all.

<!doctype html> <html> <head>    <title>program 2</title> </head> <body>    <form action="<?php $php_self; ?>" method="post">  <select name="pick"> <option value="regular">i regular customer</option> <option value="friend">from friend</option> <option value="television">on television</option> <option value="online">in online search</option>  </select> <input type="submit" value="submit form"><br> </form>   <?php        $choice = $_post['pick'];      if($choice($_post['pick']) echo "excellent. love our regular     customers!";) { } else { switch($choice) {     case 'regular':          echo "excellent. love our regular customers!";          break;     case 'friend':          echo "please thank friend us.";          break;     case 'television':          echo "we glad hear our tv ads working.";          break;      case 'online':          echo "we work hard found on google.";          break;     }    } ?> 

you've got lots of random copy/paste errors in code... instead use:

<!doctype html> <html>     <head>        <title>program 2</title>     </head>     <body>         <form action="" method="post">             <select name="pick">                 <option value="regular">i regular customer</option>                 <option value="friend">from friend</option>                 <option value="television">on television</option>                 <option value="online">in online search</option>             </select>             <input type="submit" value="submit form"><br>         </form>           <?php             if(isset($_post['pick'])) {                 switch($_post['pick']) {                     case 'regular':                          echo "excellent. love our regular customers!";                          break;                     case 'friend':                          echo "please thank friend us.";                          break;                     case 'television':                          echo "we glad hear our tv ads working.";                          break;                      case 'online':                          echo "we work hard found on google.";                          break;                 }            }         ?>     </body> </htm 

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -