A2xA Posted August 24, 2008 Share Posted August 24, 2008 I'm copying an html file with a different name for my script and it works fine. I just need it to copy when I press submit instead of when the page loads. The copy code: <?php $file = './x/x.html'; $newfile = "./x/x/".$rnd_id. "" .".html"; if (!copy($file, $newfile)) { echo "failed to copy $file...\n"; } ?> My current submit button: <input type="submit" value="Post" /> Quote Link to comment https://forums.phpfreaks.com/topic/121056-solved-copy-on-submit-not-when-page-loads/ Share on other sites More sharing options...
JasonLewis Posted August 24, 2008 Share Posted August 24, 2008 PHP is server-side, meaning it executes before anything is loaded to the client. So, you can't use PHP's copy() without reloading the page. Or can you... Look into AJAX, it may help you out with your problem. Quote Link to comment https://forums.phpfreaks.com/topic/121056-solved-copy-on-submit-not-when-page-loads/#findComment-624054 Share on other sites More sharing options...
A2xA Posted August 24, 2008 Author Share Posted August 24, 2008 alright thanks. I wasn't sure Quote Link to comment https://forums.phpfreaks.com/topic/121056-solved-copy-on-submit-not-when-page-loads/#findComment-624056 Share on other sites More sharing options...
DarkWater Posted August 24, 2008 Share Posted August 24, 2008 No, ProjectFear, he means something like: if (isset($_POST['submit'])) { //code } [/php Quote Link to comment https://forums.phpfreaks.com/topic/121056-solved-copy-on-submit-not-when-page-loads/#findComment-624058 Share on other sites More sharing options...
JasonLewis Posted August 24, 2008 Share Posted August 24, 2008 I just need it to copy when I press submit instead of when the page loads. From reading that my first thought is "Oh so the OP want's to do it without reloading the page. Meaning client-side, not server-side." Isn't that what the OP was asking? ??? Quote Link to comment https://forums.phpfreaks.com/topic/121056-solved-copy-on-submit-not-when-page-loads/#findComment-624062 Share on other sites More sharing options...
DarkWater Posted August 24, 2008 Share Posted August 24, 2008 "I just need it to copy when I press submit instead of when the page loads." He just needs an if statement to see if the button was pressed. Quote Link to comment https://forums.phpfreaks.com/topic/121056-solved-copy-on-submit-not-when-page-loads/#findComment-624065 Share on other sites More sharing options...
JasonLewis Posted August 24, 2008 Share Posted August 24, 2008 Ah yeah I can see that now. Question need's to be explained a lot clearer for me. Quote Link to comment https://forums.phpfreaks.com/topic/121056-solved-copy-on-submit-not-when-page-loads/#findComment-624100 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.