?
Solved

Redirect POST and URL at same time

Posted on 2003-03-09
4
Medium Priority
?
265 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

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…
Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Suggested Courses

752 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