Hi good day. i am designing a little project for school. This project is to register the MAC address of the laptops of every student in the school.
My problem is, when i put in the student's MAC address in the textbox, i would like the little search algorithm i got to revise the text file to see if the MAC address is already registered.
I am facing problems with the textbox content to do the search.
Contains two files : getdata.php
<?php
$hoy=date("d-m-y");
?>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=windows-1250">
<meta name="generator" content="PSPad editor, www.pspad.com">
<title> Register MAC </title>
</head>
<body bgcolor="#ffffff">
<form action="savedata.php" method="post">
<table class="fd">
<tr><td>Identification No.: <input type="text" name="ncontrol" MAXLENGTH ="8" size="30"><br></td></tr>
<tr><td>MAC Address:<input type="text" name="mac1" size = "1" MAXLENGTH="2" class="macs">:
<input type="text" name="mac2" size = "1" MAXLENGTH="2" class="macs">:
<input type="text" name="mac3" size = "1" MAXLENGTH="2" class="macs">:
<input type="text" name="mac4" size = "1" MAXLENGTH="2" class="macs">:
<input type="text" name="mac5" size = "1" MAXLENGTH="2" class="macs">:
<input type="text" name="mac6" size = "1" MAXLENGTH="2" class="macs"></td>
</tr>
<tr><td>Date Registered: <?php echo "<input type='text' name='hoy' id='hoy' value='$hoy'>"; ?></td></tr>
</table>
<input type="submit" value="Save>>">
</form>
</body>
</html>
<?php
?>
and savedata.php
<?php
$Ncontrol = @$_POST["ncontrol"];
$Fdate = @$_POST["hoy"];
$dMAC = @$_POST["mac1"];
$dMAC1 = @$_POST["mac2"];
$dMAC2 = @$_POST["mac3"];
$dMAC3 = @$_POST["mac4"];
$dMAC4 = @$_POST["mac5"];
$dMAC5 = @$_POST["mac6"];
// Set the string to be written to the file
//save numero de control
$values = "$Ncontrol \t\t\t\t\t\t\t\t\t";
//save MAC
$values .= "$dMAC:$dMAC1:$dMAC2:$dMAC3:$dMAC4:$dMAC5 \t\t\t\t";
//save date
$values .= "$Fdate\r\n";
// Open the file for reading and writing
$fp = @fopen("MACS.data", "a+") or die("CANNOT OPEN THE FILE MACS.daTA!");
$numBytes = @fwrite($fp, $values) or die("CANNOT WRITE TO THE FILE!");
$people = file("MACS.data");
//THE SEARCH ALGORITHM. TO REVISE IF THE MAC ADDRESS IS ALREADY IN THE TEXTFILE
for ($posn=0; $posn < count($people); $posn++)
if (ereg("PHP",$people[$posn])) {
print ("Person $posn is $people[$posn]<br>");
}
}
@fclose($fp);
?>
.
I am using the MAC.data to save the results (as a txt file)