I have a php page that I'm using a form on and passing the selections/data that is made on the form to a perl script that I created. Unfortunately, when I pass the variables, if there are any empty variables my variables that I'm receiving on the perl script are not coming in at the right order. Is there a way to make sure the variables that are being passed to the perl script are being giving the correct order whether there's data in them or not?
<form action="index.php" method="post">
FTP/SFTP: <select name="TYPE">
<option value="">Select...</option>
<option value="ftpd">FTP</option>
<option value="sftpd">SFTP</option>
</select></t><Br>
Search String: <input type="text" name="SEARCH"></t><br>
Search Type: <select name="STYPE">
<option value="">Select...</option>
<option value="user">Username</option>
<option value="ip">IP Address</option>
<option value="pid">PID</option>
<option value="file">Filename</option>
</select><br>
Date (YYYY-MM-DD): <input type="text" name="DATE"></t><br>
Server: <select name="SERVER">
<option value="">Select...</option>
<option value="test1ftp">test1</option>
<option value="test2ftp">test2</option>
</select></t><Br>
<input type="submit" name="formSearch" value="Search">
</form></font></p>
</body>
</html>
This is the php portion that is calling the perl script:
<?php
if(isset($_POST['formSearch']) == "Search")
{
if(empty($_POST['SEARCH']))
$_POST['SEARCH'] = "undef";
if(empty($_POST['SERVER']))
$_POST['SERVER'] = "undef";
if(empty($_POST['DATE']))
$_POST['DATE'] = "undef";
//system("perl search.pl $_POST[TYPE] $_POST[SEARCH] $_POST[STYPE] $_POST[DATE] $_POST[SERVER]", $return_val);
}
?>
When it gets to the perl script, I have the variables that are being passed go to the following.
my $TYPE = $ARGV[0];
my $SEARCH = $ARGV[1];
my $STYPE = $ARGV[2];
my $DATE = $ARGV[3];
my $SYSTEM = $ARGV[4];
So if I have no data in SEARCH it seems that the data that should have been passed to $DATE now ends up in $SEARCH.
Any help would be appreciated.
Thank you.