Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Redirect POST and URL at same time

Posted on 2003-03-09
4
Medium Priority
?
267 Views
Last Modified: 2006-11-17
I'm developing a simple class for doing basic editing on a MySQL table. By basic, I mean edit the values in a row, delete a row, or just view a row. My script creates an HTML table to display what's in the MySQL table. The last column in each row in the HTML table is a form with a dropdown box and some hidden variables. The action of each form is $PHP_SELF

I want to redirect the POST variables AND the browser to a new URL at the same time.  If the user selects "edit" from the dropdown box, they should be redirected to edit.php and the hidden varables I mentioned need to be redirected as well. One of the hidden post variables edit.php uses is the primary key for the row that the user wishes to edit.

I need to do it this way because in the class I'm writing, the user can specify the URL to handle certian actions. You also get to specify the actions that get in the dropdown box. If I get this to work, it will make this class very flexible for my future projects. I'd also be willing to share it.

I need to use POST to keep the user from figuring out what info is beind sent by looking at the URL in their brower's address bar. For security reasons, I've disabled GET and turned off global vars.

I've seen suggestions that involve using urlencode... but this won't work since a user can just copy and paste the encoded URL into another program that uses urldecode. Not safe.

I've seen solutions on the web that redirect the POSTed variables. I also know how to redirect browsers with the use of php's header tag. What I need is a solution that encompases both of these at the same time.

Thanks in advanced for your help!
0
Comment
Question by:mrbinky3000
3 Comments
 

Accepted Solution

by:
Tidikay earned 152 total points
ID: 8100433
Well, just in case you don't know [0]phpMyAdmin... this project provides exactly the functionality you need plus many many more. I mean, only if your intent is not to write redundant code :)

The dropdownbox thingy is not a big problem and can be easily solved through some JavaScript:

<form method="post">
<input type="hidden" ...>
<select onchange="this.form.submit()">
<option>some option..</option>
</select>
<form>

This should work with both browser (IE and NN from v4 above)

so long,
Tommy.

[0] -  www.phpmyadmin.net
0
 
LVL 9

Assisted Solution

by:waygood
waygood earned 148 total points
ID: 8161758
Why dont you use an intermediate page to grab the posted variables and turn them into a Session variable. Then you can redirect to a page using the information from the form.

This method will also stop some errors when browsing back and forth pages as the intermediate provides no output and doesnt get executed again. Have you even seen the error "page cannot be displayed without resubmitting Post".

This is how i have worked in the past.

form.php
<form action="process.php">
<input type="hidden" name="self" value="<?php echo $PHP_SELF; ?>" />
<input type="submit" name="submit" value="edit">
<input type="submit" name="submit" value="delete">
</form>


process.php
$_SESSION['value']=$_POST['value'];  //etc....
//process info if required if($_POST['submit']="edit") etc...
header("location : ".$_POST['self']);


p.s.
the above has multple submit buttons as I do not know what info you want to use.

0
 
LVL 33

Expert Comment

by:snoyes_jw
ID: 11934416
No comment has been added to this question in more than 21 days, so it is now classified as abandoned.

I will leave the following recommendation for this question in the Cleanup topic area:
    Split: Tidikay {http:#8100433} & waygood {http:#8161758}

Any objections should be posted here in the next 4 days. After that time, the question will be closed.

snoyes_jw
EE Cleanup Volunteer
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this. Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it i…
This article discusses four methods for overlaying images in a container on a web page
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses

581 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question