Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

inputs with arrays

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

inputs with arrays

Postby xlordt » 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>";
 
User avatar
xlordt
New php-forum User
New php-forum User
 
Posts: 34
Joined: Thu Dec 12, 2002 9:00 pm
Location: NJ

Postby Xerpher » 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?
Xerpher
New php-forum User
New php-forum User
 
Posts: 164
Joined: Tue Aug 27, 2002 8:25 pm
Location: Ontario, Canada

Postby Redcircle » 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']];
}
User avatar
Redcircle
Moderator
Moderator
 
Posts: 830
Joined: Tue Jan 21, 2003 10:42 pm
Location: Michigan USA


Return to PHP coding => General

Who is online

Users browsing this forum: Bing [Bot] and 8 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.