Hi Everyone. I've been working on this script, and have just become completely stuck. What the script does is parses a defined page (in my example, I use: http://www.jgrc.net/Index.php3), and locates all <FORM> elements, and replaces them with a new form tag, and places the old one in a hidden field. Yet, when the page gets parsed, and creates the output, it creates a page for each form field. So, in this example, I have three overlapping pages, instead of just one.
Here's the code I've used:
<?php
// Get File And Write to Field
$filename = "http://www.jgrc.net/Index.php3";
$fd = fopen($filename, "r" );
$contents = fread("$fd", 10000000);
fclose( $fd );
// Get <FORM> Elements and write whole field to field!
function locate($regex, $contents) {
while (eregi($regex, $contents, $regs)) {
$mylist[] = $regs[1];
$contents = substr($contents, strpos($contents, $regs[1]) + strlen($regs[1]));
}
return $mylist;
}
$located = locate("(<FORM([>]+)>)", $contents);
$var43 = count($located);
for($i=0; $i<count($located); $i++) {
//print htmlentities($located[$i])."<BR><BR>";
$a[$i] = eregi_replace("[\"\']", "", $located[$i]);
$contents = eregi_replace($located[$i], "<FORM action='http://www.jgrc.net/PARSEVARS.php3' METHOD=POST><INPUT TYPE='HIDDEN' NAME='SPECIALIZEDFORMTAG' VALUE='$a[$i]'>", $contents);
print $contents;
}
?>
You can also view this code in action at:
http://www.jgrc.net/Test93.php3
When it prints out $contents, it prints out one page, which replaces the first form field, the second which replaces the first two, and the last that prints it out correctly with all three replaced. How can I get it to just print out one with all the form fields replaced correctly?
Any help, or pointers would be very much appreciated.
Thanks Very Much,
Justin Funston
jfunston@powersurfr.com