inputs with arrays

Ask about general coding issues or problems here.

Moderators: egami, macek, gesf

Post Reply
User avatar
xlordt
New php-forum User
New php-forum User
Posts: 34
Joined: Thu Dec 12, 2002 9:00 pm
Location: NJ
Contact:

Thu Mar 27, 2003 4:44 am

I have added an array of commands.. but.. how do i check to see if what the user has inputed in to the textarea is in the array

Code: Select all


$cmd = array('0'=>'Command not found',
           'ftp'=>'Connecting to MF server', 'rename'=>'Now renaming file');
 $mfserver = "<font color=\"#FFFFFF\"><u>Mindfuk Winblows system</u>
              <br><br>C:\\ " . $c . "<br></font>";

 if ($_GET['c'] == "ftp"){
   $c .= "Connecting to MF server"; 
}else{    
  $c .= "Sintax error Command not found";
 }
 
    echo "<table width=\"100%\" hight=\"80%\" bgcolor=\"#000000\"><br>
       <tr><td>$mfserver<br>
      </td></tr><tr><td><br><br><br><br><br><br><br><br>
      <form method=\"get\" action=\"$PHP_SELF\">
      <font color=\"#FFFFFF\">
      cmd:&&
      <input type=\"text\" name=\"c\" size=\"70%\">
      </td></tr></form></table>";
 
Computer/Programm rox.. (php, c/c++ will take over soon muhahah

Xerpher
New php-forum User
New php-forum User
Posts: 164
Joined: Tue Aug 27, 2002 8:25 pm
Location: Ontario, Canada
Contact:

Thu Mar 27, 2003 7:15 am

What exactly are you asking for? how to check if the user put something in the box? how to get the contents of the box? something else?
Terra Design, my business and sole / huge PHP project... a fully dynamic and adaptive site engine.

User avatar
Redcircle
Moderator
Moderator
Posts: 826
Joined: Tue Jan 21, 2003 10:42 pm
Location: Michigan USA
Contact:

Thu Mar 27, 2003 11:42 pm

Code: Select all

if(!in_array($_GET['c'],$cmd))
{
echo 'Command not found';
}
else
{
  echo $cmd[$_GET['c']];
}

Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 3 guests