473,378 Members | 1,493 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

form action = <?=$_SERVER['PHP_SELF']?> - stopped working

My form action code to submit values to itself have stopped working using
the code

form action = <?=$_SERVER['PHP_SELF']?>

This code used to work

My web host recently told me they enabled phpsuexec option in apache which
apparently needs me to CHMOD my PHP page to 750 and the directory to 755. (I
don't know what this means but know how to CHMOD files). I have CHMODed the
files this but my PHP page doesn't work with those settings, so I set them
back.

Thanks in advance for any help.

Best regards,

tHatDudeUK
Jul 17 '05 #1
10 15156
On Thu, 13 Jan 2005 19:54:06 -0000, "tHatDudeUK"
<th********@gmail.com.removethisbit> wrote:
My form action code to submit values to itself have stopped working using
the code

form action = <?=$_SERVER['PHP_SELF']?>
You've got some extra spaces and missing quotes there. A step in the right
direction would be:

<form action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']);?>">
This code used to work

My web host recently told me they enabled phpsuexec option in apache which
apparently needs me to CHMOD my PHP page to 750 and the directory to 755. (I
don't know what this means but know how to CHMOD files). I have CHMODed the
files this but my PHP page doesn't work with those settings, so I set them
back.


Define "doesn't work". What does it do? What do you get in the HTML output?
How does it differ from before?

--
Andy Hassall / <an**@andyh.co.uk> / <http://www.andyh.co.uk>
<http://www.andyhsoftware.co.uk/space> Space: disk usage analysis tool
Jul 17 '05 #2

"Andy Hassall" <an**@andyh.co.uk> wrote in message
news:oa********************************@4ax.com...
You've got some extra spaces and missing quotes there. A step in the right
direction would be:

<form action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']);?>">
I've cut and paste that and no joy :-(
Define "doesn't work". What does it do? What do you get in the HTML
output?
How does it differ from before?


I'll put all the relevant code at the bottom of this page so you can examine
it. It doesn't work as in the values don't appear to be submitted to itself
as in it won't print the error message if a box isn't ticked, and it won't
forward to the page if it is ticked. It did work before! I'm not really very
conversant with PHP although I managed to put this together myself with a
little forum help etc. All I really need is the two tick boxes, to give an
error message if not ticked, and to take to the appropriate page if ticked.

<?php
$message1 = "";
$message2 = "";
if (isset($Submit) && $Submit == "I consent and wish to participate")
{
if ($_POST[withdraw]!= "Yes")
{
$message1 = "You must tick the box in order to continue";
}
if ($_POST[noanswer]!= "Yes")
{
$message2 = "You must tick the box in order to continue";
}
if ($message1 == "" && $message2 == "")
{
header("Location: http://www.an1.co.uk/survey");
}
}
?>

<form action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']);?>"
method="post" name="form1" class="style4">
<p align="left">
<input name="withdraw" type="checkbox" id="withdraw6"
value="Yes">
I understand that I may withdraw
from this investigation at any stage <br>
<span class="style3">
<?php
if ($message1!= "")
{
print "$message1";
}
?>
</span> </p>
<p align="left">
<input name="noanswer" type="checkbox" id="noanswer6"
value="Yes">
I understand that I am free to choose not to
answer a question without giving a reason why
<br>
<span class="style3">
<?php
if ($message2!= "")
{
print "$message2";
}
?>
</span> </p>
<p align="left">
<input type="submit" name="Submit" value="I consent and wish
to participate">
</p>
</form>
Jul 17 '05 #3
tHatDudeUK wrote:
if (isset($Submit) && $Submit == "I consent and wish to participate")


I'm guessing your ISP also turned register_globals off, meaning $Submit
needs to be replaced with $_POST['Submit']. Basically, if
register_globals is turned off, $Submit will never be set, and your
statement will always evaluate to false.

It's also a good idea to surround associative array keys with single
quotes if they're literals (i.e. if they're not numbers or variables).

$myvar['key'] is good, $myvar[key] isn't.
$myvar[$key] is good, $myvar['$key'] isn't.

I doubt that's causing your problem here though, but making a habit of
doing it like that will decrease the chance of you running into trouble
at some point due to conflict between an array key and a constant. I
learned this the hard way ;)
Roy W. Andersen
--
ra at broadpark dot no / http://roy.netgoth.org/

"Hey! What kind of party is this? There's no booze
and only one hooker!" - Bender, Futurama
Jul 17 '05 #4

"Roy W. Andersen" <ro******@netgoth.org> wrote in message
news:34*************@individual.net...
tHatDudeUK wrote:
if (isset($Submit) && $Submit == "I consent and wish to participate")


I'm guessing your ISP also turned register_globals off, meaning $Submit
needs to be replaced with $_POST['Submit']. Basically, if register_globals
is turned off, $Submit will never be set, and your statement will always
evaluate to false.


Ok many thanks, looks like I have that bit sorted. Now I have a different
problem.I get the following error message when it should send me to the page
I want it to go to.

Warning: Cannot modify header information - headers already sent by (output
started at /home/an1cou/public_html/musicdownloading/index.php:2) in
/home/an1cou/public_html/musicdownloading/index.php on line 17

line 17 of the code is this one
Jul 17 '05 #5

"Roy W. Andersen" <ro******@netgoth.org> wrote in message
news:34*************@individual.net...
tHatDudeUK wrote:
if (isset($Submit) && $Submit == "I consent and wish to participate")


I'm guessing your ISP also turned register_globals off, meaning $Submit
needs to be replaced with $_POST['Submit']. Basically, if register_globals
is turned off, $Submit will never be set, and your statement will always
evaluate to false.


Ok many thanks, looks like I have that bit sorted. Now I have a different
problem.I get the following error message when it should send me to the page
I want it to go to.

Warning: Cannot modify header information - headers already sent by (output
started at /home/an1cou/public_html/musicdownloading/index.php:2) in
/home/an1cou/public_html/musicdownloading/index.php on line 17

line 17 of the code is this one

header("Location: http://www.an1.co.uk/survey");
Jul 17 '05 #6
On Thu, 13 Jan 2005 21:22:29 -0000, "tHatDudeUK"
<th********@gmail.com.removethisbit> wrote:

"Roy W. Andersen" <ro******@netgoth.org> wrote in message
news:34*************@individual.net...
tHatDudeUK wrote:
if (isset($Submit) && $Submit == "I consent and wish to participate")
I'm guessing your ISP also turned register_globals off, meaning $Submit
needs to be replaced with $_POST['Submit']. Basically, if register_globals
is turned off, $Submit will never be set, and your statement will always
evaluate to false.


Ok many thanks, looks like I have that bit sorted. Now I have a different
problem.I get the following error message when it should send me to the page
I want it to go to.

Warning: Cannot modify header information - headers already sent by (output
started at /home/an1cou/public_html/musicdownloading/index.php:2) in


OK, so what's line 2?
/home/an1cou/public_html/musicdownloading/index.php on line 17

line 17 of the code is this one

header("Location: http://www.an1.co.uk/survey");


See http://php.net/header

--
Andy Hassall / <an**@andyh.co.uk> / <http://www.andyh.co.uk>
<http://www.andyhsoftware.co.uk/space> Space: disk usage analysis tool
Jul 17 '05 #7
.oO(Roy W. Andersen)
It's also a good idea to surround associative array keys with single
quotes if they're literals (i.e. if they're not numbers or variables).


It's an even better idea to set error_reporting to E_ALL in the php.ini,
then PHP will complain about such things.

Micha
Jul 17 '05 #8
tHatDudeUK wrote:
Warning: Cannot modify header information - headers already sent by (output
started at /home/an1cou/public_html/musicdownloading/index.php:2) in
/home/an1cou/public_html/musicdownloading/index.php on line 17

line 17 of the code is this one

header("Location: http://www.an1.co.uk/survey");


In the script you posted, that line is #16 if you count the line with
<?php as #1, which probably means you have a linebreak before your <?php
tag (or you didn't post the beginning of the script previously).

Headers must be sent before any actual content of the page. If you start
your page with a linebreak (or anything else) then that becomes a part
of the page, and hence once it's been sent to output you can't send any
more headers.

So, as your error explains, the actual page output started at line #2 of
index.php, which means you can't send a header on line #17. If you want
to redirect to a different page after you've started the output you'll
have to use a meta-tag or clientside script.
Roy W. Andersen
--
ra at broadpark dot no / http://roy.netgoth.org/

"Hey! What kind of party is this? There's no booze
and only one hooker!" - Bender, Futurama
Jul 17 '05 #9

"Roy W. Andersen" <ro******@netgoth.org> wrote in message
news:34*************@individual.net...
In the script you posted, that line is #16 if you count the line with
<?php as #1, which probably means you have a linebreak before your <?php
tag (or you didn't post the beginning of the script previously).


Doh, silly me. All working now. Many thanks everyone...
Jul 17 '05 #10
.oO(Roy W. Andersen)
So, as your error explains, the actual page output started at line #2 of
index.php, which means you can't send a header on line #17. If you want
to redirect to a different page after you've started the output you'll
have to use a meta-tag or clientside script.


Never use unreliable client-side redirections if you're able to do it
properly with a server-side script. If necessary use output control
functions.

Micha
Jul 17 '05 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Jeff Johnson | last post by:
Hi Everybody, I have a function that works great in IE but fails in NN. Would someone please give me some insight as to how to correct this: function init(){ var oFrame = parent.frames; ...
2
by: Brett | last post by:
I have a text area form object. A user clicks a send button and the text area information is submitted. How can I also allow the information to be submitted after the user hits the <enter> key? ...
2
by: Axel Schick | last post by:
Hello everybody! I encountered a strange behavior when trying to read the scrollTop propery of the <body> element from inside an iFrame: <body onmousemove = "window.status =...
4
by: Mark Hanley | last post by:
I have found similar problems to mine on this and other newsgroups but I still haven't been able to solve my problem... I have two tables 'Pupil' and 'SEN' which are related on a field called...
6
by: Ambuj | last post by:
Can anyone please help me understand why this is not working?!?! I have got this code in a C# Web service project, the project compiles correctly but I can't see the description when I access the...
4
by: phpmel | last post by:
<%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script language="JavaScript"...
9
by: eric | last post by:
I'm trying to define a dictionary whose value is an Generic Action<> delegate private Dictionary<string, List<Action<T>>> Any ideas on to how specify T or a different collection type more...
2
dlite922
by: dlite922 | last post by:
Hello Hello! I'm trying to connect to a host that accepts UDP on a port I setup and tested from a command line too called udp_write. However a PHP fsocketopen() call doesn't work nor does it give...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.