I understand how to write to a file. I'm using the file to store username
assword in that format. I got this example from WebMonkey. My question is, how do I get me content variable to format with multiple varibales from my add form? Here is the code I am using. The form passes $newuser and $newpass:
.:TUCK:.
Code:
<html>
<head>
<title>Add User</title>
</head>
<body>
<?php
if(isset( $submit ) && ($newpass == $cnewpass))
{
//If the Submitbutton was pressed do:
$filename = '../login/f6kr2yb.txt';
$somecontent = $newuser, ":", $newpass";
// Let's make sure the file exists and is writable first.
if (is_writable($filename)) {
// In our example we're opening $filename in append mode.
// The file pointer is at the bottom of the file hence
// that's where $somecontent will go when we fwrite() it.
if (!$fp = fopen($filename, 'a')) {
print "Cannot open file ($filename)";
exit;
}
// Write $somecontent to our opened file.
if (!fwrite($fp, $somecontent)) {
print "Cannot write to file ($filename)";
exit;
}
print "<center>Success, wrote ($somecontent) to file ($filename)</center>";
fclose($fp);
} else {
print "The file $filename is not writable";
}
}
else{
?>
<form name="Add_User" action="" method="get">
<input type="hidden" name="SID" value="<?php echo $SID; ?>">
<table align="center">
<tr>
<td align="center" colspan="2"><b>Add User</b></td>
</tr>
<tr>
<td>Username :</td><td><input type="text" name="newuserid"></td>
</tr>
<tr>
<td>Password :</td><td><input type="password" name="newpass"></td>
</tr>
<tr>
<td>Confirm Password :</td><td><input type="text" name="cnewpass"></td>
</tr>
<tr>
<td align="center" colspan="2"><input type="submit" name="submit" value="Add User"> <input type="reset" name="reset" value="Cancel"></td>
</tr>
</table>
</form>
</body>
</html>