Carrying Variables from one page to another

They have: 7 posts

Joined: Jul 2001

Hi,
I'm using a whois script which is generating a result like
XYZ.com - Available - Order Now

The Order Now is hyperlinked and the url ends with
domains/?domain=xyz.com . This points to an online order form. This form has a text box into which I want to place the xyz.com. I've tried giving the text box an initial value of ?domain and $domain as well as

<?php
=$domain
?>
but it does not display XYZ.com.

Can anyone tell me where I'm going wrong?

Cheers

nipropman

Abhishek Reddy's picture

He has: 3,348 posts

Joined: Jul 2001

i'm not sure...but is this like asp?
anyway, i believe that u first have to assign the value of "domain" to a variable.

something to the effect of:

strDomain=$Request->QueryString("domain")

then insert

<?php
=$strDomain
?>

i hope this is right Smiling

They have: 7 posts

Joined: Jul 2001

Hi thanks for the reply,

Unfortunately if the code you just gave me was asp then I doubt I can get it to work. I'm on a unix platform.

Im under a serious deadline with this one...and I know the answer is probably so simple I'll kick myself when it's pointed out to me.

Any more ideas Abhishek? Anyone?

Thanks

detox's picture

They have: 571 posts

Joined: Feb 2001

what server-side lanquage are you using?

i remember a few weeks ago i found a tutorial on doing this with javascript, i'll go have a look for it now for you

They have: 7 posts

Joined: Jul 2001

Hi detox
I don't know if any of this helps you. But here goes.
The whois script is perl and generates a url to my order form page eg: http://mysite.com/cgi-bin/domains/?domain=xyz.com

This order form page is currently just a normal html page with a form pointing to the order.cgi. In that form is the input box for the domain name. Rather than leaving it blank and asking visitors to fill it in, I wanted the form to pick up the domain value and insert it in the box.

It's what goes into the value part that has stumped me. I can use javascript or ssi if need be to solve it.

Thanks for your help.

Abhishek Reddy's picture

He has: 3,348 posts

Joined: Jul 2001

hold on.
let me grab the cgi book...Smiling

Abhishek Reddy's picture

He has: 3,348 posts

Joined: Jul 2001

this may be grossly wrong Confused :

use query_string (cgi.pm method) or environment var $ENV{QUERY_STRING}.

my $q = new CGI;

my $domain = $q->query_string;

or

my $domain = $ENV{QUERY_STRING};

<?php
=$domain
?>

dunno if it'll work but im quite certain that u have to use query_string and assign it to a var. Smiling hope that helps

merlin's picture

They have: 410 posts

Joined: Oct 1999

try this code-sample:

use strict;
use CGI qw(:standard);
use vars qw($query @parname %list @referers);
$query = new CGI;
@parname = $query->param;
my $n;
foreach $n (@parname) {
   $list{$n} = $query->param($n);
}
'
with that you can access the domain-name specified in the url simply by $list{'domain'}.

in your example it would look like this:

<input type=text name="DOMAIN to REGISTER" size=27 value="$list{'domain'}">
'

well, i havent tried it out with your stuff, probably i forgot a small code-block, but i suppose it should work. Wink

Abhishek Reddy's picture

He has: 3,348 posts

Joined: Jul 2001

r u using cgi to genereate the page?
y not use:

print $q->textfield(
-name => "domainname",
-default => $domain
);
'

add this to the pevious code i posted, omit the

<?php
...
?>
, if u are creating the page dynamically. Smiling

They have: 7 posts

Joined: Jul 2001

Hi guys,
No the page is not generated with cgi. I'm trying to implement all of your suggestions without success. Excuse my obvious ignorance of this area but I'm assuming that all of the codes that each of you have given has to be placed into the head of the page in between
<script language="JavaScript"> tags???

Well anyway, I'm doing that and still got no joy.

They have: 7 posts

Joined: Jul 2001

Ignore that load of balloney in the last post. I've been up all night with this. Im in the UK and its just gone 8.10 am and my brain is dead. (that's my excuse anyway.)

If this helps you guys, this is the part of the whois script that generates the url.

sub whois {
$output .= '';
foreach $ext(@ext) {
$output .= "$domain.$ext";
@whois = `whois $domain.$ext` ;
$status="taken";
foreach $i (@whois) {
if($i=~/No match for/g){$status="available"}
}
if ($status eq "available") {
if ($orderform) { $hyperlink = "Order Now >"; }
$output .= "Available$hyperlink";
} else { $output .= "Taken "; }
}
$output .= '';
&printpage("$output");
}

merlin's picture

They have: 410 posts

Joined: Oct 1999

well, in the form, you would have to place a 'submit'-button and the code i posted you have to place in your order.cgi/order.pl.
the page with the form can be a normal html-page (without anything dynamic).

if you're looking for some java-code i can't help you out, i don't know anything 'bout it...

[edit]
could you post the url to your site?
[/edit]

Mark Hensler's picture

He has: 4,048 posts

Joined: Aug 2000

He needs some javascipt.

FYI..
$domain is a variable in Perl and PHP (maybe others)

<?php
=domain
?>
is ASP (but
<?php
=$domain
?>
is invalid syntax)

I don't remember the code to get something out of the URL, sorry.

Mark Hensler
If there is no answer on Google, then there is no question.

They have: 105 posts

Joined: Jun 2001

Your on UNIX right? Does your host support PHP?

Try this code, it should work. You need to rename your page to .php

They have: 7 posts

Joined: Jul 2001

Thanks Gyrbo,
I'm trying your suggestion, but is there something not right with the end of the code? I'm not up on php (my server does support it).

Thanks for your help.

They have: 105 posts

Joined: Jun 2001

It's perfectly fine code, you were using asp syntax. This is the easiest code. Gee, all you guys are trying to make thing harder then they are.

Abhishek Reddy's picture

He has: 3,348 posts

Joined: Jul 2001

Hi,

i'm really quite sure that if you want to retrieve any data persisted in the url, u must use the query_string method...i honestly don't know any other way to grab persisted data. this applies only to cgi. Smiling

as for javascript, i've only been able to pass data over from one page to another if the second page was opened as a child window.

hope this post held some meaning. Laughing out loud

They have: 105 posts

Joined: Jun 2001

No in PHP, that's the good one about it! It automatically stores the querry string in variables (ex.: url.php?p=val => $p=="val")

They have: 7 posts

Joined: Jul 2001

Hi guys,
I've tried all of your suggestions (and then some) and been unable to get any to work.

I managed to track down the guy that wrote the whois perl script and he tells me that the url extension is past as an arguement and not a variable. (this is beyond me).

Does that shed any light?

Either way...thanks for all of your input.

They have: 105 posts

Joined: Jun 2001

I saw what's wrong, add the following line at the beginning of the script: $orderform = "orderform.php";'
And then use my script, and rename it to orderfrom.php . Now it should work.

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.