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
carlostAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

_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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.