Jump to content

running a script and staying on the same page


mechedd

Recommended Posts

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
Share on other sites

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
Share on other sites

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
Share on other sites

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.