473,785 Members | 3,285 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 15205
On Thu, 13 Jan 2005 19:54:06 -0000, "tHatDudeUK "
<th********@gma il.com.removeth isbit> 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 htmlspecialchar s($_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.andyhsoftwa re.co.uk/space> Space: disk usage analysis tool
Jul 17 '05 #2

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

<form action="<?php echo htmlspecialchar s($_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("Locatio n: http://www.an1.co.uk/survey");
}
}
?>

<form action="<?php echo htmlspecialchar s($_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_global s off, meaning $Submit
needs to be replaced with $_POST['Submit']. Basically, if
register_global s 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******@netgo th.org> wrote in message
news:34******** *****@individua l.net...
tHatDudeUK wrote:
if (isset($Submit) && $Submit == "I consent and wish to participate")


I'm guessing your ISP also turned register_global s off, meaning $Submit
needs to be replaced with $_POST['Submit']. Basically, if register_global s
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/musicdownloadin g/index.php:2) in
/home/an1cou/public_html/musicdownloadin g/index.php on line 17

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

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


I'm guessing your ISP also turned register_global s off, meaning $Submit
needs to be replaced with $_POST['Submit']. Basically, if register_global s
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/musicdownloadin g/index.php:2) in
/home/an1cou/public_html/musicdownloadin g/index.php on line 17

line 17 of the code is this one

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

"Roy W. Andersen" <ro******@netgo th.org> wrote in message
news:34******* ******@individu al.net...
tHatDudeUK wrote:
if (isset($Submit) && $Submit == "I consent and wish to participate")
I'm guessing your ISP also turned register_global s off, meaning $Submit
needs to be replaced with $_POST['Submit']. Basically, if register_global s
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/musicdownloadin g/index.php:2) in


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

line 17 of the code is this one

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


See http://php.net/header

--
Andy Hassall / <an**@andyh.co. uk> / <http://www.andyh.co.uk >
<http://www.andyhsoftwa re.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/musicdownloadin g/index.php:2) in
/home/an1cou/public_html/musicdownloadin g/index.php on line 17

line 17 of the code is this one

header("Locatio n: 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******@netgo th.org> wrote in message
news:34******** *****@individua l.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

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

Similar topics

1
1592
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; if (typeof(oFrame.divSummary) != 'undefined'){***** fails here! updateContent(oFrame);
2
15694
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? Thanks, Brett
2
9065
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 = document.body.scrollTop;"> allways reports "0" , even if i scroll down in the iframe. Is this a known bug?
4
2044
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 'UPN' (unique pupil number). I have a form which is bound to a query that is drawn from both of these tables and contains Pupil.UPN but not SEN.UPN aswell. When I update the form I get the error 'The field SEN.UPN cannot contain a
6
1443
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 Web Service from a ASP.Net web project... /// <summary> /// Some text /// </summary>
4
3975
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" type="text/javascript"> </script> <noscript> <b>Please</b> Try this page for browsers that can not handle SCRIPTing. <a href="EnableJavascript.aspx">click here</a> </noscript>
9
6428
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 suitable to this? Thanks
2
2271
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 an error. stripped down code + fake data: $fp = fsockopen("udp://999.999.999.999",9999,$errNo,$errMsg) or die("$errNo : $errMsg"); $test = fwrite($fp, "Logging Test");
0
9643
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10315
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9947
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8968
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7494
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6737
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5379
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3645
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.