• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 223
  • Last Modified:

Need a form, which would return a specific URL.

I have a page/file, which is named "account_history_info.php".

Through account_history_info.php, other specific, detailed pages (with specific URL addresses) are generated (example: "www.mysite.com/account_history_info.php?order_id=12345")

All generated pages/URLs have "www.mysite.com/account_history_info.php?order_id=" in common, with just a number distinguishing them.

I need to have a form, which would have just one input field, in which would be inserted an order number (example: 12345), and then when submitted, would take me to the URL (www.mysite.com/account_history_info.php?order_id=12345).

Thanks.

Carlos
0
carlost
Asked:
carlost
  • 7
  • 2
  • 2
  • +1
1 Solution
 
neesterCommented:
HERE YOU GO!!!
:)

<?
if ($_POST['id'])
{
header("Location: http://www.mysite.com/account_history_info.php?order_id={$_POST['id']}");
exit;
}
?>
<form action="thispage.php" method="post">
<input type="text" name="id" id="id" />
<input type="submit" value="Goto Page" name="submit" />
</form>
0
 
neesterCommented:
put all that inside a PHP file called: thispage.php
0
 
neesterCommented:
also - you cannot have ANYTHING before the PHP code I posted there.
Put that code above any HEADER information you have, otherwise it will not work.
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.

 
_the_mars_Commented:
If you have code which may send headers you can use this variant, instead of the only header from neester:

<?php

if (headers_sent()) {
    printf('<meta http-equiv="refresh" content="0;url="%s" />', 'http://www.mysite.com/account_history_info.php?order_id=' . $_POST['id']);
} else {
    header('Location: http://www.mysite.com/account_history_info.php?order_id=' . $_POST['id']);
}
exit;

?>

NB. neester and I assumed you used the "post" method in your form. If you did not, replace $_POST with $_GET.
0
 
neesterCommented:
>> _the_mars_

I didnt assume.
I wrote that it is a POST method.
0
 
_the_mars_Commented:
neester, you are right. I've not readed your <form> tag well.
0
 
neesterCommented:
No worries :)
0
 
RoonaanCommented:
Why not use a getform?

<form method="get" action="'http://www.mysite.com/account_history_info.php">
 <input type="text" name="order_id" value=""  />
</form>

If it is the GET-method of posting you are worried about and you need POST, then neester solution wouldn't help either.

Regards

-r-
0
 
neesterCommented:
Roonaan,
Nice code.
But i think he wants to log the hits or something.
There isnt really any purpose to thise code otherwise.
Tahts why I thought there needed to be some PHP intervention...
0
 
RoonaanCommented:
It could be a simple search form?

-r-
0
 
neesterCommented:
Could be - but I doubt he woud need help for that?

N e way - good code and we will need to see what he thinks :)
0
 
carlostAuthor Commented:
I just wanted to say thanks to you All!

I haven't read everything thoroughly yet, and I haven't tried anything yet. In fact I just got up, and came here to see if I got any replies!

I'll be back as soon as I implement the responses, to see what works best for me!

Thanks again All!

Carlos
0
 
carlostAuthor Commented:
Neester, Mars - Thank you for your time!

Roonaan, that's what I needed, Thanks!

0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

  • 7
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now