Page 1 of 1

echoing to a div box on html page

Posted: Thu Jun 17, 2004 5:00 pm
by fresh
ok... here's my script:

Code: Select all

<?
if ($_GET&#1111;'pass'] == "getsum") &#123;
$fp = fopen("win.txt","a");
 if(!$fp) &#123;
   print "There was an error while attempting to open the file!";
   exit;
&#125; else &#123;
  echo "Wrong!";
&#125;
$fp = fopen("win.txt","a");
 if(!$fp) &#123;
   print "There was an error while attempting to open the file!";
   exit;
   &#125;
$stringtowrite="<font color=white><b>".$name."</b></font>&nbsp;<font color=white>has beaten this challenge!</font><div><br>";
fwrite($fp, $stringtowrite);
fclose($fp);
$sp = readfile("win.txt","r");
 if(!$sp) &#123;
   print "There was an error while attempting to print the file!";
   exit;
&#125;
?>
ok as you can see I'm trying to validate a password and store the users name along with a message, that will first be validated and if correct, the users name would then be printed into the div box on my page... heres the htm code:

Code: Select all

<form action="http://newb.t35.com/nixwin.php">
<font size=2 color=white>Users who have beaten this challenge
<div style="border:#FFFFFF 1px solid;width:300;height:100;" name="winners">
</div>
</font>
ok so far all it does, is open a new page and echos the username and the message, I would like for it to simply print that info inside my div box instead, as you can see above... how would I go about doing this? And I understand you are busy and this may take up sometime, so if you know of a good tutorial you think I will benifit from, that in place of syntax fixing will be just as appreciated... thank you ahead of time... regards

Posted: Thu Jun 17, 2004 5:06 pm
by tim

Code: Select all

$name = $_GET['username'];
echo $name;
seems your using the get mehtod, change the username to whatever the name of the username field is

hey

Posted: Thu Jun 17, 2004 5:42 pm
by fresh
here check this out:

Code: Select all

<?
// check if pass is correct
$name = $_GET&#1111;'you'];
if ($_GET&#1111;'pass'] == "blah") &#123;

//opens file for writing
$fp = fopen("log.txt","a");
 if(!$fp) &#123;
   print "There was an error while attempting to open the file!";
   exit;
&#125;

//write string to txt file
$stringtowrite="<font color=white><b>".$name."</b></font><div><font color=white> has beaten this challenge!</font><div><br>";
fwrite($fp, $stringtowrite);
fclose($fp);
&#125; else &#123;
  echo "<font color=white>Wrong!</font>";    //this is fine
&#125;

//print txt file contents newest first
$sp = readfile("log.txt","r");         //this wont print the above in my div box named winners
 if(!$sp) &#123;
   print "There was an error while attempting to print the file!";
   exit;
&#125;
?>
I went back and noticed how tired I was when I attempted to code that script...lol, so I went back and fixed it as far as I can tell, and it is now alot more logical, however, it still doesn't print the name and message, in the div box on my htm page, the form again is:

Code: Select all

<form action="http://newb.t35.com/nixwin.php">
<font size=2 color=white>Users who have beaten this challenge
<div style="border:#FFFFFF 1px solid;width:300;height:100;" name="winners">
</div>
</font>
i think it has to do with the readfile command, is that where I should put some other command like

sp = $_GET['divBoxName']
sp.readfile("log.txt","r");

???

thanks