Jump to content

[SOLVED] page redirect with variables help!


countdrac

Recommended Posts

hi

 

i really am having a difficult time understanding this:

 

i have a admin page that allows users to fill in a form

this page send the form info to a preview page which previews the form on the screen

on this page is another form (just a save and edit button)

 

when they click the save it calls a javascript function which saves the file and attempts to redirect them back to the original admin page      with info (which i have as a php variable) on what was just saved

 

i need to redirect them with the name of the file which was saved!

ie: admin?successfull=<?php $filename; ?>

i cant find anything to do this!!!

 

ive tried: document.goNext.action=

(goNext was the name of the form) - doesnt work

 

ive tried: header(Location:)

which sent but without the variables

 

and ive tried: location.href which did nothing

 

if anyone can help i would be greatly appreciated

Link to comment
Share on other sites

I'm not sure if I totally understand you, but here's a very basic example of how to redirect and pass GET values:

 

<?php

$strFilename = 'sample.txt';

$strUrl = 'http://www.example.com/admin.php?file=' . urlencode($strFilename);

header('Location: ' . $strUrl);

exit;

?>

 

Link to comment
Share on other sites

i am a little confused as well, are you looking for a javascript event to automatically send the user to a new page once the file has been confirmed saved?

ie. so when they click the save button the info is sent to the server and saved, then retrieve the file name and send to a new page.

 

 

Link to comment
Share on other sites

right exactly what you said at the end

except i dont need to retrieve anything as i have the variables from the save function

(auto-forward with php if possible)

 

the redirect is itself within a redirect() javascript function.

 

but for some reason when i try the header('Location :' .$page);

 

it just reloads the current page (but it does the saving and stuff) just the redirect - this header command - doesnt work at all, the page  im currently on just reloads - not the one i indended to go to.

 

also i only want the redirect to excecute once the hit the save button (after which two functions are called - saveFile() and redirect() )

 

ive never seen the exit; command before but if thats in my code the page crashes and the the save button doesnt even appear

 

thanks

Link to comment
Share on other sites

i am less confused but still slightly, can you post some code.

 

one quick point though, the header('Location :' .$page); will only work if it is called before any html is displayed.  I don't know how this would work calling it in a javascript function but i wouldn't expect it to work. 

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.