[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Form handler redirect question

Posted on 2004-08-18
8
Medium Priority
?
337 Views
Last Modified: 2013-12-13
I have a PHP form handler page with this line of code:

$required_errorpage = "../thank_you_error.html";

Is there any way to turn it into an if then else redirect based on where the submit page came from?  In other words, there are two forms and they both go to this page which does all the form handling.

For the error, I would like the page go to 2 different error pages based on which form was submitted.

the other error page would be "../offer_error.html"

I am using "dynaform" so I don't know if any custom code will work with it. I know very little about PHP so this solution works great other than this issue here. here is the URL for the dynaform site if that helps:
http://www.webligo.com/products_dynaform.php

-- Dan
0
Comment
Question by:danomatic
[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
  • 5
  • 2
8 Comments
 
LVL 40

Expert Comment

by:Richard Quadling
ID: 11839941
There are several ways.

1 - Look at the referrer.
2 - Add a hidden field.

e.g

1

switch($_SERVER["HTTP_REFERER"])
      {
      case 'http://site1.com/page1.html':
            $required_errorpage = 'error1.html';
            break;
      case '...' :
            ...;
            break;
      default :
            $required_errorpage = 'defaulterror.html';
      }

or

2 For each form you want a separate error page ...

<input type="hidden" name="new_error_page" value="new_error.html">

and then in the handler php file ...

$required_errorpage = 'defaulterror.html';
if (isset($_POST['new_error_page']) && file_exists($_POST['new_error_page'] . 'html'))
      {
      $required_errorpage = $_POST['new_error_page'] . 'html';
      }


Of course, you may be using $_GET rather than $_POST.

Richard.
0
 
LVL 40

Expert Comment

by:Richard Quadling
ID: 11839974
Just checking the dynaform code.

Can you try in the dynaform code, change ...

$required_on = "yes";

and on the forms ...

<input type="hidden" name="required_errorpage" value="your_error_page.html">

Richard.
0
 
LVL 40

Expert Comment

by:Richard Quadling
ID: 11840009
If this does not work, then change the $required_on back to the value already present and then alter ...

$required_errorpage = "error.html";

to

$required_errorpage = "error.html";
if (isset($_POST['new_error_page']) && file_exists($_POST['new_error_page'] . 'html'))
     {
     $required_errorpage = $_POST['new_error_page'] . 'html';
     }

This is not very secure, so try this ...

<input type="hidden" name="whicherrorpage" value="1">

in the form, changing the value for each form and then ...

$required_errorpage = "error.html";
$aOtherErrors = array('page for error 0.html','page for error 1.html');
if (isset($_POST['whicherrorpage']) && isset($aOtherErrors[$_POST['whicherrorpage']]))
     {
     $required_errorpage = $aOtherErrors[$_POST['whicherrorpage']];
     }

Richard.

I think that just about covers it!
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 3

Author Comment

by:danomatic
ID: 11841601
RQuadling:

How do I indicate to go up a directory with the error page:

$aOtherErrors = array('page for error 0.html','page for error 1.html');

would it be:

$aOtherErrors = array('page for error ../0.html','page for error ../1.html');
0
 
LVL 40

Accepted Solution

by:
Richard Quadling earned 2000 total points
ID: 11850353
../page for error 1.html

Ideally, you should not use relative pages.

Maybe have an /errorpages directory, so no matter where in the structure you are, the errors are ALWAYS in the same place.

$required_errorpage = "error.html";
$aOtherErrors = array('page for error 0.html','page for error 1.html');
if (isset($_POST['whicherrorpage']) && isset($aOtherErrors[$_POST['whicherrorpage']]))
     {
     $required_errorpage = '/errors/' . $aOtherErrors[$_POST['whicherrorpage']];
     }

for example.

Richard.
0
 
LVL 40

Expert Comment

by:Richard Quadling
ID: 11870239
Anything else?
0
 
LVL 3

Author Comment

by:danomatic
ID: 12098454
I am sorry, I have gotten held up on this project, I will resume this week.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article discusses how to create an extensible mechanism for linked drop downs.
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
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…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses

649 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