View Full Version : HTTP Redirect Snafu

07-08-2006, 06:47 AM
Hello. I am a new forum member and a fairly inexperienced developer. I could really use some help on what I believe must be a very common function.

My objective is to use javascript and cgi to search the O'Reilly book listings by keyword from a webpage hosted on my localhost. I could just use the O'Reilly webpage, however, I am trying to understand what goes on behind the scenes by using the API.

I have tried to sort the code on the O'Reilly search pages without success.

Overall, I am trying to declare a variable with a value of 'http://my.safaribooksonline.com/xmlapi/?mytoken=keyword' within a web form

- 'mytoken' is my O'Reilly issued token
- 'keyword' is a user-input keyword on the

Then, before sending data to my CGI script, I want to append the variable and the keyword so that it forms the complete URL so CGI can load it into my web browser.

Basically, this is just an HTTP Redirect, but I cannot get it to work. Now, I do not want anyone to write my code for me. However, can someone validate my approach? Am I using the right tools (CGI and Javascript)? Or, would you recommend something else? I had tried PHP and also asp.net... but am lost there, too.

Thank you very kindly.

07-08-2006, 07:07 PM
i don't understand what you're doing.

you have a webform (on your localhost page) where you type in a keyword:

<form name="foo" action="myScript.cgi" method="post">
<input type="text" name="keyword">
<input type="submit">
what is your CGI script supposed to do?

why can't you just use one webform like this:

<form name="foo" action="http://my.safaribooksonline.com/xmlapi/" method="get">
<input type="text" name="token">
<input type="submit>

i'm sure i'm off the mark, but i just don't understand what you're trying to do.

07-08-2006, 07:37 PM
Thank you very kindly for your reply. Yes, my description is confusing.

Basically, I want to input text into a text box, click the submit button, have the text in the text box appended to a static URL, and then have the brower go to that URL.

So, for example, if my static URL is: http://my.safaribooksonline.com/xmlapi/=.

And, I enter 'XML' into my text box, I want the browser to go to http://my.safaribooksonline.com/xmlapi/=XML.

Is CGI the right approach for that?

Thank you.

07-08-2006, 07:42 PM
you can use an HTML form without any CGI to do this. Safari Books is doing all the CGI work necessary.

here is a form.

<form name="foo" action="http://my.safaribooksonline.com/xmlapi/" method="get">
<input type="text" name="token" value="XML">
<input type="submit>

when you click submit your browser will go to: http://my.safaribooksonline.com/xmlapi/?token=XML
the red part will change to whatever you enter in the text box.

07-08-2006, 07:52 PM
Ah! Fabulous! You are a scholar and a gentleman! Thank you!