select onclick

D

Dawn

Hi,

I use to have apache 1.3 installed on my computer. I did a clean
install and went from RedHat 9.0 to SUSE 9.0. In this clean installed I
decided to try apache2. Now I am having some problems. I know that php
and mySQL are working fine. There were a few changed that I had to make
to my code to get it to work, but for the most part, my code is working.

This part of my code however is not working. I have the same code on
another computer that is running apache1 and it is working find. Did I
miss some in the setup?

<form name="act_list" border=0>
<table align="center">
<tr><td>
<select name=actors size=10
onclick="parent.bottom.location.href='./actors.php?id=' +
this.form.actors.options[this.form.actors.selectedIndex].value">

<option value=331>Animal Characters
<option value=319>Animation Characters
<option value=98>Brandy
<option value=366>Eve
<option value=249>Madonna

</select>
</td></tr>
</table>
</form>

When one of the select is click it is suppose to call the actors.php
file (which it does) and send it the value (which it does not). I do
not know why this does not work in apache2.

Thanks
Dawn
 
H

Hywel Jenkins

Hi,

I use to have apache 1.3 installed on my computer. I did a clean
install and went from RedHat 9.0 to SUSE 9.0. In this clean installed I
decided to try apache2. Now I am having some problems. I know that php
and mySQL are working fine. There were a few changed that I had to make
to my code to get it to work, but for the most part, my code is working.

<form name="act_list" border=0>
<table align="center">
<tr><td>
<select name=actors size=10
onclick="parent.bottom.location.href='./actors.php?id=' +
this.form.actors.options[this.form.actors.selectedIndex].value">
When one of the select is click it is suppose to call the actors.php
file (which it does) and send it the value (which it does not). I do
not know why this does not work in apache2.

What does actors.php do? Does it use globals or does it use $_GET or
$_POST? How is your form submitting the data - GET or POST? I think
your code in actors.php is faulty, not Apache 2.
 
D

Dawn

Hywel said:
Hi,

I use to have apache 1.3 installed on my computer. I did a clean
install and went from RedHat 9.0 to SUSE 9.0. In this clean installed I
decided to try apache2. Now I am having some problems. I know that php
and mySQL are working fine. There were a few changed that I had to make
to my code to get it to work, but for the most part, my code is working.

<form name="act_list" border=0>
<table align="center">
<tr><td>
<select name=actors size=10
onclick="parent.bottom.location.href='./actors.php?id=' +
this.form.actors.options[this.form.actors.selectedIndex].value">
When one of the select is click it is suppose to call the actors.php
file (which it does) and send it the value (which it does not). I do
not know why this does not work in apache2.


What does actors.php do? Does it use globals or does it use $_GET or
$_POST? How is your form submitting the data - GET or POST? I think
your code in actors.php is faulty, not Apache 2.
This same code works in apache1. actors.php gets the id number by using
$HTTP_POST_VARS['id'] and use that number to get information from a
mysql DB and displays the information. I know the part where it gets
the info and displays it works for tests that I have run. What I don't
understand is how come I can not get the 'id' value.

Because of the '?id=' from the code above, the form is submitted using
the get method.
 
H

Hywel Jenkins

Hywel said:
Hi,

I use to have apache 1.3 installed on my computer. I did a clean
install and went from RedHat 9.0 to SUSE 9.0. In this clean installed I
decided to try apache2. Now I am having some problems. I know that php
and mySQL are working fine. There were a few changed that I had to make
to my code to get it to work, but for the most part, my code is working.

<form name="act_list" border=0>
<table align="center">
<tr><td>
<select name=actors size=10
onclick="parent.bottom.location.href='./actors.php?id=' +
this.form.actors.options[this.form.actors.selectedIndex].value">
When one of the select is click it is suppose to call the actors.php
file (which it does) and send it the value (which it does not). I do
not know why this does not work in apache2.


What does actors.php do? Does it use globals or does it use $_GET or
$_POST? How is your form submitting the data - GET or POST? I think
your code in actors.php is faulty, not Apache 2.
This same code works in apache1. actors.php gets the id number by using
$HTTP_POST_VARS['id'] and use that number to get information from a
mysql DB and displays the information. I know the part where it gets
the info and displays it works for tests that I have run. What I don't
understand is how come I can not get the 'id' value.

Because of the '?id=' from the code above, the form is submitted using
the get method.

So you're using HTTP_POST_VARS to get the value but as submitting using
GET? That's wrong.

Check REGISTER_GLOBALS in php_info() - I suspect it's off. It's not a
problem with Apache - it's your code or your PHP set-up. The POST array
is nothing to do with Apache.
 
O

Owen Jacobson

This same code works in apache1.

And an older version of PHP.
actors.php gets the id number by using $HTTP_POST_VARS['id']

Which has since been replaced with $_POST (matching $_GET, and if you
don't care which method, $_REQUEST). That's probably the bug.

You might try

<?php
$HTTP_POST_VARS = $_POST;
?>

if going through and replacing every instance of the former with the
latter is too much effort. It's a bandaid at best, though, and you'd do
far better to fix the code properly.
 
D

DU

Dawn said:
Hi,

I use to have apache 1.3 installed on my computer. I did a clean
install and went from RedHat 9.0 to SUSE 9.0. In this clean installed I
decided to try apache2. Now I am having some problems. I know that php
and mySQL are working fine. There were a few changed that I had to make
to my code to get it to work, but for the most part, my code is working.

This part of my code however is not working. I have the same code on
another computer that is running apache1 and it is working find. Did I
miss some in the setup?

<form name="act_list" border=0>

A form does not have a default border. So, border=0 is unneeded.
<table align="center">

<tr><td>
<select name=actors size=10

For various reasons, it is always preferable and desirable to quote
attribute values.

Why attribute values should always be quoted in HTML
http://www.cs.tut.fi/~jkorpela/qattr.html
onclick="parent.bottom.location.href='./actors.php?id=' +
this.form.actors.options[this.form.actors.selectedIndex].value">

The triggering event attribute is onchange. Also, I would code this in a
more compact manner:

onchange="parent.bottom.location.href='./actors.php?id=' +
this.options[this.selectedIndex].value;"
<option value=331>Animal Characters

Here, the value must be a string.

<option value="331">Animal Characters</option>

HTH

DU
 
D

Dawn

DU said:
Dawn said:
Hi,

I use to have apache 1.3 installed on my computer. I did a clean
install and went from RedHat 9.0 to SUSE 9.0. In this clean installed
I decided to try apache2. Now I am having some problems. I know that
php and mySQL are working fine. There were a few changed that I had
to make to my code to get it to work, but for the most part, my code
is working.

This part of my code however is not working. I have the same code on
another computer that is running apache1 and it is working find. Did
I miss some in the setup?

<form name="act_list" border=0>


A form does not have a default border. So, border=0 is unneeded.
<table align="center">


<tr><td>
<select name=actors size=10


For various reasons, it is always preferable and desirable to quote
attribute values.

Why attribute values should always be quoted in HTML
http://www.cs.tut.fi/~jkorpela/qattr.html
onclick="parent.bottom.location.href='./actors.php?id=' +
this.form.actors.options[this.form.actors.selectedIndex].value">

The triggering event attribute is onchange. Also, I would code this in a
more compact manner:

onchange="parent.bottom.location.href='./actors.php?id=' +
this.options[this.selectedIndex].value;"
<option value=331>Animal Characters


Here, the value must be a string.

<option value="331">Animal Characters</option>

HTH

DU
<option value=319>Animation Characters
<option value=98>Brandy
<option value=366>Eve
<option value=249>Madonna

</select>
</td></tr>
</table>
</form>

When one of the select is click it is suppose to call the actors.php
file (which it does) and send it the value (which it does not). I do
not know why this does not work in apache2.

Thanks
Dawn

Thank you everyone for all of your help. It looks like I will need to
get some updated HTML and PHP books. I will give these a try.
 
L

Leif K-Brooks

Owen said:
Which has since been replaced with $_POST (matching $_GET, and if you
don't care which method, $_REQUEST). That's probably the bug.

You might try

<?php
$HTTP_POST_VARS = $_POST;
?>

$HTTP_POST_VARS is still set in every current version of PHP, it's just
deprecated. That can't be the problem.
 
T

Toby A Inkster

Dawn said:
<form name="act_list" border=0>
<select name=actors size=10
onclick="parent.bottom.location.href='./actors.php?id=' +
this.form.actors.options[this.form.actors.selectedIndex].value">

This is really suboptimal. Try:

<form method="get" name="act_list" action="actors.php">
<select name=id size=10
onclick="parent.bottom.location.href='./actors.php?id=' +
this.form.id.options[this.form.id.selectedIndex].value">

And now your form will work for those 10%-15% of people without JavaScript.

Getting back to your question...
I know that php [is] working fine.

How? Because it worked under Apache 1.x? Because it works from the command
line? If so, that's not enough.

Check that you have the Apache2 version of mod_php installed. On Mandrake
the package is called apache2-mod_php.

Check that a basic test PHP file works:

<?php
header("Content-Type: text/plain");
echo 1+1;
?>

visit that page and you should just see a plain text file with the numeral
2.

If all that works, post back here with a test URL.
 
H

Hywel Jenkins

Leif K-Brooks said:
$HTTP_POST_VARS is still set in every current version of PHP, it's just
deprecated. That can't be the problem.

Is it populated if REGISTER_GLOBALS is off?
 
C

Chris Morris

Though $HTTP_POST_VARS isn't superglobal and $_POST is, which can
cause problems.
Is it populated if REGISTER_GLOBALS is off?

Yes, that just stops $foo being set to $_REQUEST['foo']
 
H

Hywel Jenkins

Though $HTTP_POST_VARS isn't superglobal and $_POST is, which can
cause problems.
Is it populated if REGISTER_GLOBALS is off?

Yes, that just stops $foo being set to $_REQUEST['foo']

Of course - I was having a blonde moment.
 

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

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top