...

View Full Version : My request script is not working



MPCODER
01-17-2004, 07:15 PM
Hi,
I've made a script which logs some information the quest has typed in a .txt file.
Here is the code im using:

This is what you posted: <br>
Username: <?php echo $_POST["name"]; ?>. <br>
Desired Password: <?php echo $_POST["password"]; ?> <br>
Email Adress: <?php echo $_POST["email"]; ?> <br>
Portfolio Site: <?php echo $_POST["site"]; ?><br>
<br>
If this is invalid, please contact me, phpengine@hotmail.com <br>
This script will be on PHPEngine later. At the moment i only wrote it for job
requests.
<?php
$file = "jobs.txt"
$username = $_POST["name"];
$password = $_POST["password"];
$email = $_POST["email"];
$site = $_POST["site"];

if(is_writable($file)){
$open = fopen($file,"a");
fwrite($open,$username);
fwrite($open,$password);
fwrite($open,$email);
fwrite($open,$site);
fclose($open);
}else{
chmod($file,0777) or die("Attempted to chmod the file, it was unsuccessful, please chmod ".$file." to 0777 yourself");
echo 'File was unwritable. Please refresh the page to try again';
}
?>

DsgnrsTLZAdmin
01-17-2004, 07:22 PM
<?php
$file = fopen("jobs.txt", "w+"); //not sure about what access code you need so change this if needed
$username = $_POST["name"];
$password = $_POST["password"];
$email = $_POST["email"];
$site = $_POST["site"];

if(is_writable($file)){
$open = fopen("$file", "a+");
fputs($open,$username);
fputs($open,$password);
fputs($open,$email);
fputs($open,$site);
fputs($open);
}else{
chmod($file,0777) or die("Attempted to chmod the file, it was unsuccessful, please chmod ".$file." to 0777 yourself");
echo 'File was unwritable. Please refresh the page to try again';
}
?>




make sure your files called by this script are in the same directory as this script. make sure the permissions are set according to these access modes ( read/write )

MPCODER
01-17-2004, 07:29 PM
Thanks. But can you tell me what was wrong with my own one?

MPCODER
01-17-2004, 07:38 PM
It's not working. This is what it logs:
H@-

mordred
01-17-2004, 07:38 PM
MPCODER, you missed a semicolon at the end of this line:



$file = "jobs.txt"


Besides that, your script works fine. It only fails if "jobs.txt" does not exist, or if you haven't got the permission to change it's permissions.

mordred
01-17-2004, 07:41 PM
There is an error in DsgnrsTLZAdmins script:



$file = fopen("jobs.txt", "w+");


Both for is_writable() and fopen() later the variable $file should be a string containing the filename, and not an already opened file. Change the line in question to



$file = "jobs.txt";

MPCODER
01-17-2004, 08:23 PM
thanks mordred

MPCODER
01-18-2004, 09:35 AM
Now my script works. But can someone tell me how to let it log so that there is a character between every option like if you type hello as username and bye as password it logs this: hello|bye|



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum