473,394 Members | 1,821 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,394 software developers and data experts.

Problems with 'if' statement

Hello
I have used the following php script in the form action to determine whether
to post the same page again or open the php file called excelsave.php
depending on which of two submit buttons is pressed in the form

<form action="<?php if(isset($updatestats)){
echo $_SERVER['PHP_SELF'];
}else{
?>excelsave.php<?php
}?>" method="post" enctype="multipart/form-data"
name="savestatments">
problem is whatever button is pressed the excel.php is run. what is wrong
with my 'if.. ' statement?

ian
Aug 10 '06 #1
7 1193
Hi,

what do you think about

<form action="<? if(isset($updatestats))
echo $_SERVER['PHP_SELF'];
else
echo "excelsave.php";
?>" method="post" enctype="multipart/form-data"
name="savestatments">

regards,

karolina

mantrid skrev:
Hello
I have used the following php script in the form action to determine whether
to post the same page again or open the php file called excelsave.php
depending on which of two submit buttons is pressed in the form

<form action="<?php if(isset($updatestats)){
echo $_SERVER['PHP_SELF'];
}else{
?>excelsave.php<?php
}?>" method="post" enctype="multipart/form-data"
name="savestatments">
problem is whatever button is pressed the excel.php is run. what is wrong
with my 'if.. ' statement?

ian
Aug 10 '06 #2

<ra********@hotmail.comwrote in message
news:11**********************@m79g2000cwm.googlegr oups.com...
Hi,

what do you think about

<form action="<? if(isset($updatestats))
echo $_SERVER['PHP_SELF'];
else
echo "excelsave.php";
?>" method="post" enctype="multipart/form-data"
name="savestatments">

regards,

karolina

mantrid skrev:
no sorry that didnt work either
whats a skrev?
Aug 10 '06 #3
*** mantrid escribió/wrote (Thu, 10 Aug 2006 19:27:45 GMT):
<form action="<?php if(isset($updatestats)){
echo $_SERVER['PHP_SELF'];
}else{
?>excelsave.php<?php
}?>" method="post" enctype="multipart/form-data"
name="savestatments">
problem is whatever button is pressed the excel.php is run. what is wrong
with my 'if.. ' statement?
I find it pretty unlikely that the problem is in the if() part. What makes
you think so? Have you var_dumped() your $_POST array? Does $updatestats
have the correct value?
--
-+ http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
++ Mi sitio sobre programación web: http://bits.demogracia.com
+- Mi web de humor con rayos UVA: http://www.demogracia.com
--
Aug 10 '06 #4
mantrid wrote:
Hello
I have used the following php script in the form action to determine whether
to post the same page again or open the php file called excelsave.php
depending on which of two submit buttons is pressed in the form

<form action="<?php if(isset($updatestats)){
echo $_SERVER['PHP_SELF'];
}else{
?>excelsave.php<?php
}?>" method="post" enctype="multipart/form-data"
name="savestatments">
problem is whatever button is pressed the excel.php is run. what is wrong
with my 'if.. ' statement?

ian

Ian,

I think your problem is not the if statement - I suspect $updatestats
isn't being set. What code do you have that sets it?

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Aug 11 '06 #5
>
I think your problem is not the if statement - I suspect $updatestats
isn't being set. What code do you have that sets it?

That occured to me so I tried

<form action="<?php if(isset($_POST['updatestats'])){

instead of

<form action="<?php if(isset($updatestats)){

but still no luck, but I got round it by getting rid of the 'if' in the form
action and placing them at the top of the page, as below

************************************************** **
if(isset($download)){
header("Location: http://www.mysite.co.uk/excelsave.php");
}

if(isset($updatestats)){
script for creating confirmation version of original page
}

<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"
enctype="multipart/form-data"name="savestatments">

************************************************** *
However I would still like to know why the first method didnt work.
Thanks all for the support
Ian
Aug 11 '06 #6
mantrid wrote:
>>I think your problem is not the if statement - I suspect $updatestats
isn't being set. What code do you have that sets it?

That occured to me so I tried

<form action="<?php if(isset($_POST['updatestats'])){

instead of

<form action="<?php if(isset($updatestats)){

but still no luck, but I got round it by getting rid of the 'if' in the form
action and placing them at the top of the page, as below

************************************************** **
if(isset($download)){
header("Location: http://www.mysite.co.uk/excelsave.php");
}

if(isset($updatestats)){
script for creating confirmation version of original page
}

<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"
enctype="multipart/form-data"name="savestatments">

************************************************** *
However I would still like to know why the first method didnt work.
Thanks all for the support
Ian

Ian,

Were you trying to change the action based on a click on the same page?
If so, it won't work.

PHP is server side. By the time the page gets to your browser, PHP has
done its job and ended processing for this page.

Your if statement should work if $_POST['updatestats'] was set when this
page was called. But only then.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Aug 11 '06 #7

"Jerry Stuckle" <js*******@attglobal.netwrote in message
news:ge******************************@comcast.com. ..
mantrid wrote:
>I think your problem is not the if statement - I suspect $updatestats
isn't being set. What code do you have that sets it?


That occured to me so I tried

<form action="<?php if(isset($_POST['updatestats'])){

instead of

<form action="<?php if(isset($updatestats)){

but still no luck, but I got round it by getting rid of the 'if' in the
form
action and placing them at the top of the page, as below

************************************************** **
if(isset($download)){
header("Location: http://www.mysite.co.uk/excelsave.php");
}

if(isset($updatestats)){
script for creating confirmation version of original page
}

<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"
enctype="multipart/form-data"name="savestatments">

************************************************** *
However I would still like to know why the first method didnt work.
Thanks all for the support
Ian

Ian,

Were you trying to change the action based on a click on the same page?
If so, it won't work.
PHP is server side. By the time the page gets to your browser, PHP has
done its job and ended processing for this page.

Your if statement should work if $_POST['updatestats'] was set when this
page was called. But only then.
Yes silly me that was exactly what I was doing. and it works the second way
because when the page it resent only then does $_POST['updatestats'] have a
value. nice one, thanks
ian


Aug 11 '06 #8

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

Similar topics

17
by: Axel | last post by:
Hiho, here my Newbie question (Win32 GUI): I'm reading a file in binary mode to a char* named buffer. I used malloc(filesize) to make the needed space avaiable. The filedata in the buffer...
3
by: Mark Morton | last post by:
I'm writing an if statement for a UK credit card form validation script. Users who specify that their card is Switch need to enter either the issue number or the 'valid from' date. I'm trying to...
0
by: Tim::.. | last post by:
Can someone please help! I'm trying to write an insert statement for a complex datagrid! The database consists of the following data structure! ..tblContent PageID PK ModDate Description...
21
by: matvdl | last post by:
I have a system that was originally developed in asp - the pages are saved in SQL (there are over 10,000 pages) and saved to a temp directory in the server when requested by a client. I have...
4
by: marti | last post by:
I've run into three problems trying to solve this one issue. Using VS2005 B2 & sql server 2000, I create a sqldatasource and bind a gridview to it. Everything looks good. However, if there is an...
4
by: James | last post by:
I have a VB windows forms application that accesses a Microsoft Access database that has been secured using user-level security. The application is being deployed using No-Touch deployment. The...
10
by: RainerF | last post by:
Hi Folks, My Problem is: My SQL Statement Structure: SELECT TABLEA.FIELDA, TABLEA.FIELDB, TABLEA.FIELDC, TABLEA.FIELDD,
4
by: Ivan | last post by:
Hi to all !!! And thanks to answer my topics. I have problems when I try of run stored procedures, show diferents errors. I made one test with one example of the tutorials. The example is this ...
3
by: sjt003 | last post by:
I have been developing web apps in Visual Studio 2003, but since the other developers in my office don't use Visual Studio, I may have to stop too unless there is an efficient way for them to...
4
by: ii2o | last post by:
Hi all, I'm trying to develop a website that selects from 3 stylesheets depending on which style they have chosen. Their preference is stored in a cookie and this is where the problems begin. I...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...

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.