Newbie - Problem Two - Ruby and Form Variables, re-loading like PHP_SELF

P

page77.office

I am attempting to copy a PHP project I did in Ruby.

I basically have a search form / web page, which looks for matching
records and displays them prior to the search box form.

I reload the page with

<FORM action="<?php print $_SERVER['PHP_SELF'];?>" method="POST" name =
"Nextrec" >

I then use the isset function to test whether any records have been
displayed and skip the display and go straight to the form. I know
this could have been achieved with javascript, but that was a no no.

I have discovered require cgi and it sems to give me all the info I
need, but how do I replicate the form button action re-loading the page
with all the variables in tact.

Thanks

Richard
 
E

Edward Faulkner

--fdj2RfSjLxBAspz7
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

<FORM action="<?php print $_SERVER['PHP_SELF'];?>" method="POST" name =
"Nextrec" >

If I remember my PHP correctly, $_SERVER['PHP_SELF'] is simply the
name of the currently executing file. The Ruby equivalent is
__FILE__.

regards,
Ed

--fdj2RfSjLxBAspz7
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: Digital signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQFDvSbunhUz11p9MSARAtnqAJ9dwbhfKxQ6UZUt6FWqY4sqhayO3wCgzvAu
3ZKov8l2bG346NSCPC1EYxw=
=Qa5u
-----END PGP SIGNATURE-----

--fdj2RfSjLxBAspz7--
 
J

J. Ryan Sobol

Actually, you'll also need to call basename(). So,

basename($_SERVER['PHP_SELF'] ) == __FILE__

~ ryan ~


On Thu, Jan 05, 2006 at 07:03:34AM +0900,
<FORM action="<?php print $_SERVER['PHP_SELF'];?>" method="POST"
name =
"Nextrec" >

If I remember my PHP correctly, $_SERVER['PHP_SELF'] is simply the
name of the currently executing file. The Ruby equivalent is
__FILE__.

regards,
Ed
 
M

mosscliffe

Thanks for the replies, and yes PHP_SELF is the name of the running
current page.

I am sorry to be stupid, but how do I get the form action to execute
basename(__FILE__) as I did with:

<FORM action="<?php print $_SERVER['PHP_SELF'];?>" method="POST"

Thanks again

Richard

J. Ryan Sobol said:
Actually, you'll also need to call basename(). So,

basename($_SERVER['PHP_SELF'] ) == __FILE__

~ ryan ~


On Thu, Jan 05, 2006 at 07:03:34AM +0900,
<FORM action="<?php print $_SERVER['PHP_SELF'];?>" method="POST"
name =
"Nextrec" >

If I remember my PHP correctly, $_SERVER['PHP_SELF'] is simply the
name of the currently executing file. The Ruby equivalent is
__FILE__.

regards,
Ed
 
J

J. Ryan Sobol

basename() is a PHP function, not a Ruby one.

~ ryan ~


Thanks for the replies, and yes PHP_SELF is the name of the running
current page.

I am sorry to be stupid, but how do I get the form action to execute
basename(__FILE__) as I did with:

<FORM action="<?php print $_SERVER['PHP_SELF'];?>" method="POST"

Thanks again

Richard

J. Ryan Sobol said:
Actually, you'll also need to call basename(). So,

basename($_SERVER['PHP_SELF'] ) == __FILE__

~ ryan ~


<FORM action="<?php print $_SERVER['PHP_SELF'];?>" method="POST"
name =
"Nextrec" >

If I remember my PHP correctly, $_SERVER['PHP_SELF'] is simply the
name of the currently executing file. The Ruby equivalent is
__FILE__.

regards,
Ed
 
J

James Edward Gray II

basename() is a PHP function, not a Ruby one.

$ ri -T File::basename
--------------------------------------------------------- File::basename
File.basename(file_name [, suffix] ) -> base_name
------------------------------------------------------------------------
Returns the last component of the filename given in file_name,
which must be formed using forward slashes (``/'') regardless of
the separator used on the local file system. If suffix is given
and present at the end of file_name, it is removed.

File.basename("/home/gumby/work/ruby.rb") #=>
"ruby.rb"
File.basename("/home/gumby/work/ruby.rb", ".rb") #=> "ruby"


James Edward Gray II
 
J

J. Ryan Sobol

Thanks James. :)

~ ryan ~


basename() is a PHP function, not a Ruby one.

$ ri -T File::basename
---------------------------------------------------------
File::basename
File.basename(file_name [, suffix] ) -> base_name
----------------------------------------------------------------------
--
Returns the last component of the filename given in file_name,
which must be formed using forward slashes (``/'') regardless of
the separator used on the local file system. If suffix is given
and present at the end of file_name, it is removed.

File.basename("/home/gumby/work/ruby.rb") #=>
"ruby.rb"
File.basename("/home/gumby/work/ruby.rb", ".rb") #=> "ruby"


James Edward Gray II
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,201
Messages
2,571,049
Members
47,655
Latest member
eizareri

Latest Threads

Top