Pianoman993
07-24-2007, 06:04 PM
Here are my two files. One contains the script that sends an array of information and stores it in a text file named log.txt.
Here is the form page.
<html><head><title>Add Users</title></head>
<body>
<form action="added.php" method="post">
Register <input type="text" size="3" name="newusers" /> users to nuance_cd log.<br />
<input type="reset" value="Clear" /><input type="submit" value="Generate IDs and PWs" />
</form>
</body>
</html>
Here is the .php page
<html><head><title>Add Users</title></head>
<body>
<?php
if ( isset ($_POST['submit'])) {
$newusers = $_POST['newusers'];
$anewusers = array();
$fp = fopen('log.txt', 'a+'); //***added change here
for ($num = 1; $num <= $newusers; $num++) {
$username = time() . rand(0, 4596);
$password = time() . rand(0, 4596).'a';
$data = $username . "\t" . $password . "\r\n";
$anewusers[] = $data;
fwrite ($fp, $data."\r\n");
}//close loop
fclose ($fp);
foreach ($anewusers as $value) {
print $value . '<br />\n'; }
} else { print 'You forgot to fill in some information';}
?>
</body>
</html>
Anyone who can solve the problem of why no error messages appear when no information is entered and why the log remains empty is a God. PLEASE HELP!
Here is the form page.
<html><head><title>Add Users</title></head>
<body>
<form action="added.php" method="post">
Register <input type="text" size="3" name="newusers" /> users to nuance_cd log.<br />
<input type="reset" value="Clear" /><input type="submit" value="Generate IDs and PWs" />
</form>
</body>
</html>
Here is the .php page
<html><head><title>Add Users</title></head>
<body>
<?php
if ( isset ($_POST['submit'])) {
$newusers = $_POST['newusers'];
$anewusers = array();
$fp = fopen('log.txt', 'a+'); //***added change here
for ($num = 1; $num <= $newusers; $num++) {
$username = time() . rand(0, 4596);
$password = time() . rand(0, 4596).'a';
$data = $username . "\t" . $password . "\r\n";
$anewusers[] = $data;
fwrite ($fp, $data."\r\n");
}//close loop
fclose ($fp);
foreach ($anewusers as $value) {
print $value . '<br />\n'; }
} else { print 'You forgot to fill in some information';}
?>
</body>
</html>
Anyone who can solve the problem of why no error messages appear when no information is entered and why the log remains empty is a God. PLEASE HELP!