Start Free Trial
Come for the solution, stay for everything else.
Start Free Trial
Save values to file using php
How can I click on a button and save a string to a file in php please?
For example:MainPage ... contains a button or link ...
I click on it and it saves: eg: $var1 = 'somestring';
Then, if I click another button for $var1 .. it would replace 'something' with 'somethingElse'
Very Important: I don't want the page to reload everytime a press a button to save.
Can anyone help please?
8/22/2022 - Mon
<a href="#" onclick="<?php echo file_put_contents("test.tx
t","Hello World. Testing!"); ?>">Save Me</a>
and it saves the data and creates the file even if I don't click on the link :o/
It would be perfect if I could control that.
Right. Php is serverside. It will "do" that code when the page loads. If you want to do anything after page load, you have to do it in js. The js can call another file onclick though. So put the save code in a different file. Let's call it save.php. It can take get or post vars for filename and data.
Call save.php with js. That way you don't leave the page you are on.
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
I have no idea on how to code that i js :o/
ASKER CERTIFIED SOLUTION
Log in or sign up to see answer
Become an EE member today
7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Plans and Pricing
Certified Expert Program
© 1996-2022 Experts Exchange, LLC. All rights reserved. Covered by US Patent