RE: [PHP-DB] Submitting form from a href

2006-07-17 Thread Sean Mumford
 Couldn't you achieve the same effect without javascript by simply using GET
values instead of post? As in each hyperlink would say something like a
href=search.php?letter=aA/a a href=search.php?letter=bB/a,
although perhaps you're trying to intentionally avoid using GET as to not
clutter up their browser history.
..
-Original Message-
From: Andrew Kreps [mailto:[EMAIL PROTECTED] 
Sent: Friday, July 14, 2006 7:15 PM
To: Skip Evans
Cc: Php-Db
Subject: Re: [PHP-DB] Submitting form from a href

Skip,

Just so you know, there is a general PHP user's list available for just such
a request.  It's rather high-traffic, so be warned.

Now then, on to the problem.  I believe I've figured out a way to make this
happen.  I've only tested it on IE 6 and Firefox 1.5.0.4, so your browser
compatibility may vary.  I'll just post the scripts I used to test it here
and you can take what you need and run with it.

Here is the script that my form is built in:

--

html
head
script language=Javascript
function submitForm (letter)
{
document.search.letter.value = letter;//
Here's where we're
setting the form value 'letter' to the letter the user clicked on.
document.search.submit();   // Then, submit
the form.
}
/script
/head
body
form name=search method=POST
action=testingLinkSubmit.php
input type=hidden name=letter value=  !--
If this isn't here, the Javascript letter.value code won't work, since
form.letter doesn't exist.  --
input type=checkbox name=checky/ Search all
campuses
br

?
for ($i = 65;  $i = 90;  $i++)
{
$letter = chr($i);
print a
href=\javascript:submitForm('$letter')\$letter/a ;
}
?
/form
/body
/html

-

The receiving end of the form looks much as you might expect, it just parses
the form values:

--

html
body
?
if (isset($_POST[checky]))
{
print Checkbox value is: Truebr\n;
}
else
{
print Checkbox value is: Falsebr\n; }

print Letter:  . $_POST[letter];
?
/body
/html



And there you go!  Let me know if you have any problems.



On 7/14/06, Skip Evans [EMAIL PROTECTED] wrote:
 Hey all,

 This is not database related, but I get the impression this list 
 entertains general PHP questions? If I'm mistaken, flame away.

 I need submit a form when a hyper link is pressed, and have been 
 trying all manner of onlicks, etc, but have been unable to hit the 
 right combination.

 Here's the scenario:

 I have the alphabet in hyper links with a check box below:


 form...
 A B C D E F G H I J K.

 [] check for all campuses
 /form

 What needs to happen is that when they click a
 letter, which is a a href=... now, it submits
 the check box value as well, to be read through
 $_POST on the receiving end.

 And of course I need to know what letter was
 click, this I was trying to get through a
 $_REQUEST var, but was not able to do so.

 Any tips would be monstrously appreciated.
 --
 Skip Evans
 Big Sky Penguin, LLC
 61 W Broadway
 Butte, Montana 59701
 406-782-2240

 --
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Submitting form from a href

2006-07-17 Thread Dave W

The problem with GET is that a user that looks at the source code of the
html can easily just input what they want for the argument. Can you say SQL
injection?

On 7/17/06, Sean Mumford [EMAIL PROTECTED] wrote:


Couldn't you achieve the same effect without javascript by simply using
GET
values instead of post? As in each hyperlink would say something like a
href=search.php?letter=aA/a a href=search.php?letter=bB/a,
although perhaps you're trying to intentionally avoid using GET as to not
clutter up their browser history.
..
-Original Message-
From: Andrew Kreps [mailto:[EMAIL PROTECTED]
Sent: Friday, July 14, 2006 7:15 PM
To: Skip Evans
Cc: Php-Db
Subject: Re: [PHP-DB] Submitting form from a href

Skip,

Just so you know, there is a general PHP user's list available for just
such
a request.  It's rather high-traffic, so be warned.

Now then, on to the problem.  I believe I've figured out a way to make
this
happen.  I've only tested it on IE 6 and Firefox 1.5.0.4, so your browser
compatibility may vary.  I'll just post the scripts I used to test it here
and you can take what you need and run with it.

Here is the script that my form is built in:

--

html
head
script language=Javascript
function submitForm (letter)
{
document.search.letter.value =
letter;//
Here's where we're
setting the form value 'letter' to the letter the user clicked on.
document.search.submit();   // Then,
submit
the form.
}
/script
/head
body
form name=search method=POST
action=testingLinkSubmit.php
input type=hidden name=letter value=  !--
If this isn't here, the Javascript letter.value code won't work, since
form.letter doesn't exist.  --
input type=checkbox name=checky/ Search all
campuses
br

?
for ($i = 65;  $i = 90;  $i++)
{
$letter = chr($i);
print a
href=\javascript:submitForm('$letter')\$letter/a ;
}
?
/form
/body
/html

-

The receiving end of the form looks much as you might expect, it just
parses
the form values:

--

html
body
?
if (isset($_POST[checky]))
{
print Checkbox value is: Truebr\n;
}
else
{
print Checkbox value is: Falsebr\n; }

print Letter:  . $_POST[letter];
?
/body
/html



And there you go!  Let me know if you have any problems.



On 7/14/06, Skip Evans [EMAIL PROTECTED] wrote:
 Hey all,

 This is not database related, but I get the impression this list
 entertains general PHP questions? If I'm mistaken, flame away.

 I need submit a form when a hyper link is pressed, and have been
 trying all manner of onlicks, etc, but have been unable to hit the
 right combination.

 Here's the scenario:

 I have the alphabet in hyper links with a check box below:


 form...
 A B C D E F G H I J K.

 [] check for all campuses
 /form

 What needs to happen is that when they click a
 letter, which is a a href=... now, it submits
 the check box value as well, to be read through
 $_POST on the receiving end.

 And of course I need to know what letter was
 click, this I was trying to get through a
 $_REQUEST var, but was not able to do so.

 Any tips would be monstrously appreciated.
 --
 Skip Evans
 Big Sky Penguin, LLC
 61 W Broadway
 Butte, Montana 59701
 406-782-2240

 --
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php



--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php





--
Dave W


RE: [PHP-DB] Submitting form from a href

2006-07-17 Thread Dwight Altman
I don't think so, because the OP needs other form fields submitted as well.

Regards,
Dwight
 -Original Message-
 From: Sean Mumford [mailto:[EMAIL PROTECTED]
 Sent: Monday, July 17, 2006 9:24 AM
 To: 'Php-Db'
 Subject: RE: [PHP-DB] Submitting form from a href
 
  Couldn't you achieve the same effect without javascript by simply using
 GET
 values instead of post? As in each hyperlink would say something like a
 href=search.php?letter=aA/a a href=search.php?letter=bB/a,
 although perhaps you're trying to intentionally avoid using GET as to not
 clutter up their browser history.
 ..
 -Original Message-
 From: Andrew Kreps [mailto:[EMAIL PROTECTED]
 Sent: Friday, July 14, 2006 7:15 PM
 To: Skip Evans
 Cc: Php-Db
 Subject: Re: [PHP-DB] Submitting form from a href
 
 Skip,
 
 Just so you know, there is a general PHP user's list available for just
 such
 a request.  It's rather high-traffic, so be warned.
 
 Now then, on to the problem.  I believe I've figured out a way to make
 this
 happen.  I've only tested it on IE 6 and Firefox 1.5.0.4, so your browser
 compatibility may vary.  I'll just post the scripts I used to test it here
 and you can take what you need and run with it.
 
 Here is the script that my form is built in:
 
 --
 
 html
   head
   script language=Javascript
   function submitForm (letter)
   {
   document.search.letter.value = letter;//
 Here's where we're
 setting the form value 'letter' to the letter the user clicked on.
   document.search.submit();   // Then, submit
 the form.
   }
   /script
   /head
   body
   form name=search method=POST
 action=testingLinkSubmit.php
   input type=hidden name=letter value=  !--
 If this isn't here, the Javascript letter.value code won't work, since
 form.letter doesn't exist.  --
   input type=checkbox name=checky/ Search all
 campuses
   br
 
   ?
   for ($i = 65;  $i = 90;  $i++)
   {
   $letter = chr($i);
   print a
 href=\javascript:submitForm('$letter')\$letter/a ;
   }
   ?
   /form
   /body
 /html
 
 -
 
 The receiving end of the form looks much as you might expect, it just
 parses
 the form values:
 
 --
 
 html
 body
 ?
 if (isset($_POST[checky]))
 {
   print Checkbox value is: Truebr\n;
 }
 else
 {
   print Checkbox value is: Falsebr\n; }
 
 print Letter:  . $_POST[letter];
 ?
 /body
 /html
 
 
 
 And there you go!  Let me know if you have any problems.
 
 
 
 On 7/14/06, Skip Evans [EMAIL PROTECTED] wrote:
  Hey all,
 
  This is not database related, but I get the impression this list
  entertains general PHP questions? If I'm mistaken, flame away.
 
  I need submit a form when a hyper link is pressed, and have been
  trying all manner of onlicks, etc, but have been unable to hit the
  right combination.
 
  Here's the scenario:
 
  I have the alphabet in hyper links with a check box below:
 
 
  form...
  A B C D E F G H I J K.
 
  [] check for all campuses
  /form
 
  What needs to happen is that when they click a
  letter, which is a a href=... now, it submits
  the check box value as well, to be read through
  $_POST on the receiving end.
 
  And of course I need to know what letter was
  click, this I was trying to get through a
  $_REQUEST var, but was not able to do so.
 
  Any tips would be monstrously appreciated.
  --
  Skip Evans
  Big Sky Penguin, LLC
  61 W Broadway
  Butte, Montana 59701
  406-782-2240
 
  --
  PHP Database Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 
 --
 
 --

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Submitting form from a href

2006-07-17 Thread Skip Evans
If you use a GET and submit through the link you 
don't carry the check box through with the POST.


Here is the code that I used after help from the list:

First, the JS function

script language='javascript'
function submitForm(letter)
{
 document.search.letter.value=letter;// 
put the letter in the post value
 document.search.submit();   // 
submit the form

}
/script

// the check box
td class='fieldprompt'All Campusesbrinput 
type='checkbox' name='all_campuses' !!checked!!/td


... and the links that call the JS function:

form name='search' 
action='modules.php?mod=listreq=listbooks' 
method='post'

a href=javascript:submitForm('A')A/a
...etc, etc...

And finally the PHP code that picks up the value 
for the letter selected.


$letter=$_POST['letter'];
$all_campuses=$_POST['all_campuses'];

This solution was very straightforward and a snap 
to put in place. Gobs of thanks to the guys who 
sent through suggestions.


I'm sure this is code that I'll be using again.

Skip



Sean Mumford wrote:

 Couldn't you achieve the same effect without javascript by simply using GET
values instead of post? As in each hyperlink would say something like a
href=search.php?letter=aA/a a href=search.php?letter=bB/a,
although perhaps you're trying to intentionally avoid using GET as to not
clutter up their browser history.
..
-Original Message-
From: Andrew Kreps [mailto:[EMAIL PROTECTED] 
Sent: Friday, July 14, 2006 7:15 PM

To: Skip Evans
Cc: Php-Db
Subject: Re: [PHP-DB] Submitting form from a href

Skip,

Just so you know, there is a general PHP user's list available for just such
a request.  It's rather high-traffic, so be warned.

Now then, on to the problem.  I believe I've figured out a way to make this
happen.  I've only tested it on IE 6 and Firefox 1.5.0.4, so your browser
compatibility may vary.  I'll just post the scripts I used to test it here
and you can take what you need and run with it.

Here is the script that my form is built in:

--

html
head
script language=Javascript
function submitForm (letter)
{
document.search.letter.value = letter;//
Here's where we're
setting the form value 'letter' to the letter the user clicked on.
document.search.submit();   // Then, submit
the form.
}
/script
/head
body
form name=search method=POST
action=testingLinkSubmit.php
input type=hidden name=letter value=  !--
If this isn't here, the Javascript letter.value code won't work, since
form.letter doesn't exist.  --
input type=checkbox name=checky/ Search all
campuses
br

?
for ($i = 65;  $i = 90;  $i++)
{
$letter = chr($i);
print a
href=\javascript:submitForm('$letter')\$letter/a ;
}
?
/form
/body
/html

-

The receiving end of the form looks much as you might expect, it just parses
the form values:

--

html
body
?
if (isset($_POST[checky]))
{
print Checkbox value is: Truebr\n;
}
else
{
print Checkbox value is: Falsebr\n; }

print Letter:  . $_POST[letter];
?
/body
/html



And there you go!  Let me know if you have any problems.



On 7/14/06, Skip Evans [EMAIL PROTECTED] wrote:


Hey all,

This is not database related, but I get the impression this list 
entertains general PHP questions? If I'm mistaken, flame away.


I need submit a form when a hyper link is pressed, and have been 
trying all manner of onlicks, etc, but have been unable to hit the 
right combination.


Here's the scenario:

I have the alphabet in hyper links with a check box below:


form...
A B C D E F G H I J K.

[] check for all campuses
/form

What needs to happen is that when they click a
letter, which is a a href=... now, it submits
the check box value as well, to be read through
$_POST on the receiving end.

And of course I need to know what letter was
click, this I was trying to get through a
$_REQUEST var, but was not able to do so.

Any tips would be monstrously appreciated.
--
Skip Evans
Big Sky Penguin, LLC
61 W Broadway
Butte, Montana 59701
406-782-2240

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php







--
Skip Evans
Big Sky Penguin, LLC
61 W Broadway
Butte, Montana 59701
406-782-2240

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Submitting form from a href

2006-07-17 Thread Stut

Dave W wrote:

The problem with GET is that a user that looks at the source code of the
html can easily just input what they want for the argument. Can you 
say SQL

injection?


Can you say input validation? Regardless of where user input comes from, 
whether it's in the URL, in POST vars or in cookies they should all be 
subjected to the same validation. Trust nothing.


-Stut

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Submitting form from a href

2006-07-14 Thread Micah Stevens


A little javascript would do it.. like so:

a href=Javascript: getElementById('letterpressed').value = 'A'; 
getElementById('thisform').submit; void 0;A/a

!-- Repeat for each letter --

form action=target.php id=thisform
input type=hidden id=letterpressed name=letterpressed value=
input type=checkbox name=campuses Check for all campuses
/form


Then you have a $_POST that contains both.

-Micah

Skip Evans wrote:

Hey all,

This is not database related, but I get the impression this list 
entertains general PHP questions? If I'm mistaken, flame away.


I need submit a form when a hyper link is pressed, and have been 
trying all manner of onlicks, etc, but have been unable to hit the 
right combination.


Here's the scenario:

I have the alphabet in hyper links with a check box below:


form...
A B C D E F G H I J K.

[] check for all campuses
/form

What needs to happen is that when they click a letter, which is a a 
href=... now, it submits the check box value as well, to be read 
through $_POST on the receiving end.


And of course I need to know what letter was click, this I was trying 
to get through a $_REQUEST var, but was not able to do so.


Any tips would be monstrously appreciated.


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Submitting form from a href

2006-07-14 Thread Andrew Kreps

Skip,

Just so you know, there is a general PHP user's list available for
just such a request.  It's rather high-traffic, so be warned.

Now then, on to the problem.  I believe I've figured out a way to make
this happen.  I've only tested it on IE 6 and Firefox 1.5.0.4, so your
browser compatibility may vary.  I'll just post the scripts I used to
test it here and you can take what you need and run with it.

Here is the script that my form is built in:

--

html
head
script language=Javascript
function submitForm (letter)
{
document.search.letter.value = letter;// 
Here's where we're
setting the form value 'letter' to the letter the user clicked on.
document.search.submit();   // Then, submit the 
form.
}
/script
/head
body
form name=search method=POST 
action=testingLinkSubmit.php
input type=hidden name=letter value=  !-- If 
this isn't
here, the Javascript letter.value code won't work, since form.letter
doesn't exist.  --
input type=checkbox name=checky/ Search all 
campuses
br

?
for ($i = 65;  $i = 90;  $i++)
{
$letter = chr($i);
print a 
href=\javascript:submitForm('$letter')\$letter/a ;
}
?
/form
/body
/html

-

The receiving end of the form looks much as you might expect, it just
parses the form values:

--

html
body
?
if (isset($_POST[checky]))
{
print Checkbox value is: Truebr\n;
}
else
{
print Checkbox value is: Falsebr\n;
}

print Letter:  . $_POST[letter];
?
/body
/html



And there you go!  Let me know if you have any problems.



On 7/14/06, Skip Evans [EMAIL PROTECTED] wrote:

Hey all,

This is not database related, but I get the
impression this list entertains general PHP
questions? If I'm mistaken, flame away.

I need submit a form when a hyper link is pressed,
and have been trying all manner of onlicks, etc,
but have been unable to hit the right combination.

Here's the scenario:

I have the alphabet in hyper links with a check
box below:


form...
A B C D E F G H I J K.

[] check for all campuses
/form

What needs to happen is that when they click a
letter, which is a a href=... now, it submits
the check box value as well, to be read through
$_POST on the receiving end.

And of course I need to know what letter was
click, this I was trying to get through a
$_REQUEST var, but was not able to do so.

Any tips would be monstrously appreciated.
--
Skip Evans
Big Sky Penguin, LLC
61 W Broadway
Butte, Montana 59701
406-782-2240

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php