mechedd Posted October 16, 2009 Share Posted October 16, 2009 Hi all, Ok, so now I have my uploader working fine but I am running into another problem. Is there a way to run the upload script when a user presses submit on the form and refresh the page when it is complete instead of navigating to the upload.php page? -mechedd Link to comment https://forums.phpfreaks.com/topic/177980-running-a-script-and-staying-on-the-same-page/ Share on other sites More sharing options...
Warz Posted October 16, 2009 Share Posted October 16, 2009 If I understand you correctly this is what you need to do in <form> you choose action="" this will send request to same page... then you can either include the upload.php script on your page or simply copy the code over. Then check if user has submitted. Assuming post value look like this <input type="submit" name="submit" value="Upload"> Example: if (isset($_POST['submit'])) // Has user submitted/uploaded yet? { include 'upload.php'; // If so, let's include this page } else // if not.... { Place your original page here... the one user will see before (and after) uploading. } Link to comment https://forums.phpfreaks.com/topic/177980-running-a-script-and-staying-on-the-same-page/#findComment-938418 Share on other sites More sharing options...
mechedd Posted October 17, 2009 Author Share Posted October 17, 2009 I am trying to use PHP in an .aspx page linked to a .master page.... is this a bad idea? I am starting to think it is. Link to comment https://forums.phpfreaks.com/topic/177980-running-a-script-and-staying-on-the-same-page/#findComment-938432 Share on other sites More sharing options...
mechedd Posted October 17, 2009 Author Share Posted October 17, 2009 It isn't working for me... Since I am using a .master page I need to do everything in a predefined content region. If I have my form in the content region, would I put the php script beneath the form html? IDK if this works...... <asp:Content> <form></form> <?php ?> </asp:Content> Link to comment https://forums.phpfreaks.com/topic/177980-running-a-script-and-staying-on-the-same-page/#findComment-938445 Share on other sites More sharing options...
mechedd Posted October 17, 2009 Author Share Posted October 17, 2009 Ok i switched from .asp but I still cant get your method to work. when you say { Place your original page here... the one user will see before (and after) uploading. } Do you mean put the html there or is there some function to call it? My format is now: <html> <form></form> <?php ?> </html> Should that be able to work? Link to comment https://forums.phpfreaks.com/topic/177980-running-a-script-and-staying-on-the-same-page/#findComment-938497 Share on other sites More sharing options...
Dorky Posted October 17, 2009 Share Posted October 17, 2009 lets say you are using post. if (isset($_POST['whatever'])) { //do whatever } this can be put anywhere. i put all of my application scripts before <html> then work in any dynamic portions in the html by using echo "<html> and using single quotes so i dont have to escape all of the double quotes. this also allows the information that was just uploaded to be viewed when the page refreshes without having to call it with jscript. if you dont have dynamic markup just put it above the html and disregard the html echo. Link to comment https://forums.phpfreaks.com/topic/177980-running-a-script-and-staying-on-the-same-page/#findComment-938502 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.