Jump to content

Recommended Posts

Posted

I'm just fiddling with a bit php that adds some data from a form to a mysql database. At the same time this form is submitted I want to add the same data to a text file.

 

Can anybody help me with how to achieve this?

Posted

Cheers localzuk.

 

The file goes back to itself when submitted so the user can submit something different straight away. As confirmation of submitting the previous one successfully I was wanting to put something like:

 

You have successfully added $string

 

How would I go about doing this?

Posted

I have a form on a page with a field called 'txtTitle'. When this form is submitted it adds that info to a database and then goes back to the same page so they can add something again. All I want is to show what they have just added so they know they have been successful.

 

Something like print $txtTitle

 

I don't want to post code because I'm a little ashamed of it. Any help is appreciated :D

Posted

I wouldn't be ashamed of your code - you should see the horror that is some of mine! I think there a generally two ways of doing what you want, if I understand it correctly.

 

The first is to use a cookie or session to pass a couple of variables - a flag and the submitted text. You could then reload the page, check the flag and

 

if flag = 1 then

flag = 0

print $string

end if

 

Or, the other way is to do it with out reloading the page. This would require some Javascript. Javascript can pick up an onClick() event on the submit button and can be used to print the success command to the screen.

 

I'd probably use the first method myself along with a test to make sure they were successful.

  • Thanks 1
Posted

I would store the input data in a variable so like:

 

$datasent = $_POST["txtTitle"];

 

I would then have:

 

print $datasent;

 

This should solve your problem.

  • Thanks 1
Posted
I would store the text entered in a session variable, adding each new text entry to it. This can then be printed when the page reloads giving an audit trail of all text entered in that session.
Posted
I would store the text entered in a session variable, adding each new text entry to it. This can then be printed when the page reloads giving an audit trail of all text entered in that session.

 

Hightower said he/she wanted to print out what they have just entered not everything they have entered in that session.

Posted

Thanks for all the help so far - I'm getting there. I have just one thing left to do, and need help again.

 

I have managed to open, append and close a text file in the same location of the php files, but now need to open, append and close a text file that is stored on a different server.

 

Can anybody help me?

 

The code I have so far for this bit is:

 

$myFile = "whitelist.txt";
$fh = fopen($myFile, 'a') or die("can't open file");
$stringData = $_POST['txtAddress'];
fwrite($fh, $stringData);           
fwrite($fh, "\r\n");
fclose($fh);

 

The whitelist.txt bit needs to be pointing to \\SERVER\SHARE\whitelist.txt

 

Thanks, :D

Posted

hmm a quick google says writing to windows network drives from php is massively problematic. you could maybe call up a local batch file that do the copying for you.

 

or stick ftp on server so you can php > ftp instead.

Posted
How do I find out which user that is?

 

Err. In the Services administrative tool, look at the settings for the 'World Wide Web Publishing Service?'.

 

It is probably 'Local System Account' - whatever that may be...

  • Thanks 1

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...