check input from textbox

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
kabucek
Forum Commoner
Posts: 50
Joined: Thu Sep 04, 2008 2:20 pm

check input from textbox

Post by kabucek »

hi all,
i have this piece of code to check the textbox input:

Code: Select all

$selectedProdCode="LMQ";
if ($memberDataArray['eventDate']="FEBRUARY 28")   //changed from ttevents
 {
    $selectedProdCode="febevent";
         }
 
 elseif ($memberDataArray['eventDate']='ttevents')
 {
    $selectedProdCode="ttevents";
         }
- with this i want to check:
if user types: FEBRUARY 28 in the box the system will select febevent

if user tyeps: ttevents in the box the system will select ttevents


somehow it doesn't work, it selects febevent all the time.

thanks!
orobian
Forum Newbie
Posts: 4
Joined: Mon Dec 29, 2008 3:48 pm
Location: Italia

Re: check input from textbox

Post by orobian »

Hi kabucek,
the problem you face is beacuse of the =. You should have two of them to check if a var equals another, so:

Code: Select all

 
   1. $selectedProdCode="LMQ";
   2. if ($memberDataArray['eventDate']=="FEBRUARY 28")   //changed from ttevents
   3.  {
   4.     $selectedProdCode="febevent";
   5.          }
   6.  
   7.  elseif ($memberDataArray['eventDate']=='ttevents')
   8.  {
   9.     $selectedProdCode="ttevents";
  10.          }
 
kabucek
Forum Commoner
Posts: 50
Joined: Thu Sep 04, 2008 2:20 pm

Re: check input from textbox

Post by kabucek »

yes, I've tried that and it didn't work.

this: $memberDataArray['eventDate']
is the value of the textbox,
does "if" function work with textboxes?
maybe there is a way to use switch or some function?
I'm thinking about something maybe like:

Code: Select all

$selectedProdCode = <what to put here ???> ('febevent');
SWITCH ($selectedProdCode):
   CASE $memberDataArray['eventDate']('febevent');
      $selectedProdCode="febevent" . $selectedProdCode;
      BREAK;
   CASE $memberDataArray['eventDate']('ttevents');
      $selectedProdCode="ttevents" . $selectedProdCode;
      BREAK;
ENDSWITCH;

Code: Select all

any other ideas?

thanks
Post Reply