473,769 Members | 4,591 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

help with posting conditional if statement

Art
Can anyone help. I've tried scaling down a script to the bare minimum and
it still is not working correctly. What I think should happen is that when
the field app_fname is blank, that $hold_chk will get set to 1 and the 1st
if statement will be executed. What actually happens is that when I hit
submit, the form stays where it is, for example if the form where the submit
button is located is on the form other.php, then when I hit submit this is
where it stays. If I then hit the submit button a 2nd time, it post to the
some.php form. I've tried this script without the conditional if(isset()
and it works. I need to have the isset() otherwise the form displays all
empty fields as soon as it loads, before the submit button is hit. Any help
would be appreciated. After working on this for 2 weeks it seems like i'm
stuck.

Thanks
Art

<?php

$holdchk = 0;

if (isset($_POST['B1'])) {

echo "<br><br><b r>";
if (empty($_POST['app_fname'])) {
$holdchk = 1;
}

if ($holdchk == 1 ){
echo "<form method=\"POST\" action=\"some.p hp\">";

}

if ($holdchk == 0 ){
echo "<form method=\"POST\" action=\"other. php\">";

}
}
?>

<html>

<head>
</head>

<form method="POST" action="">

When
hit the submit button</font></b<input
type="submit" value="Submit" name="B1"></p>
</form>
</body>

</html>

May 4 '07 #1
16 1761
Message-ID: <ry************ *******@bignews 7.bellsouth.net from Art
contained the following:
>After working on this for 2 weeks it seems like i'm
stuck.
Don't multipost. And haven't we seen this before?
--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
May 4 '07 #2
Art
Sort of, but this is a scaled down version of the code, which was requested.
I'm still stuck and still trying to understand why it's not working.

Thanks
Art
"Geoff Berrow" <bl******@ckdog .co.ukwrote in message
news:8c******** *************** *********@4ax.c om...
Message-ID: <ry************ *******@bignews 7.bellsouth.net from Art
contained the following:
>>After working on this for 2 weeks it seems like i'm
stuck.

Don't multipost. And haven't we seen this before?
--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/

May 4 '07 #3
Art

Try something like this.

$holdchk= (strlen ($_POST['B1'])>0 and strlen($_POST['app_fname'])==0);
$action= ($holdchk)? "some.php": "other.php" ;
echo "<form method='POST' action='$action '>";

avoid isset and empty

S

"Art" <c_***@bellsout h.netwrote in message
news:ry******** ***********@big news7.bellsouth .net...
Can anyone help. I've tried scaling down a script to the bare minimum and
it still is not working correctly. What I think should happen is that
when
the field app_fname is blank, that $hold_chk will get set to 1 and the 1st
if statement will be executed. What actually happens is that when I hit
submit, the form stays where it is, for example if the form where the
submit
button is located is on the form other.php, then when I hit submit this is
where it stays. If I then hit the submit button a 2nd time, it post to
the
some.php form. I've tried this script without the conditional if(isset()
and it works. I need to have the isset() otherwise the form displays all
empty fields as soon as it loads, before the submit button is hit. Any
help
would be appreciated. After working on this for 2 weeks it seems like i'm
stuck.

Thanks
Art

<?php

$holdchk = 0;

if (isset($_POST['B1'])) {

echo "<br><br><b r>";
if (empty($_POST['app_fname'])) {
$holdchk = 1;
}

if ($holdchk == 1 ){
echo "<form method=\"POST\" action=\"some.p hp\">";

}

if ($holdchk == 0 ){
echo "<form method=\"POST\" action=\"other. php\">";

}
}
?>

<html>

<head>
</head>

<form method="POST" action="">

When
hit the submit button</font></b<input
type="submit" value="Submit" name="B1"></p>
</form>
</body>

</html>

May 4 '07 #4

"Simon Stewart" <ad*****@www.si monstewart.iewr ote in message
news:5a******** *****@mid.indiv idual.net...
Art

Try something like this.

$holdchk= (strlen ($_POST['B1'])>0 and strlen($_POST['app_fname'])==0);
$action= ($holdchk)? "some.php": "other.php" ;
echo "<form method='POST' action='$action '>";

avoid isset and empty
And why is that?
May 4 '07 #5
Message-ID: <na************ *******@bignews 7.bellsouth.net from Art
contained the following:
>Sort of, but this is a scaled down version of the code, which was requested.
I'm still stuck and still trying to understand why it's not working.
And you took no notice of my post on the subject before. You are still
echoing html /before/ the<htmltag!

I think you need something like this:

<?php

$holdchk = 0;
if (isset($_POST['B1'])) {
$form= "<br><br><b r>";
if (empty($_POST['app_fname'])) {
$holdchk = 1;
}

if ($holdchk === 1 ){
$form.= "<form method=\"POST\" action=\"some.p hp\">";
}

if ($holdchk === 0 ){
$form.= "<form method=\"POST\" action=\"other. php\">";

}
}
?>

<html>

<head>
</head>

<?php echo $form;?>

When
hit the submit button</font></b<input
type="submit" value="Submit" name="B1"></p>
</form>
</body>

</html>

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
May 4 '07 #6
Simon Stewart wrote:
Art

Try something like this.

$holdchk= (strlen ($_POST['B1'])>0 and strlen($_POST['app_fname'])==0);
$action= ($holdchk)? "some.php": "other.php" ;
echo "<form method='POST' action='$action '>";

avoid isset and empty
Why avoid isset?
I use that function in every script that receives clientinformati on...
Couldn't life without it.

Personally I think your posted code is a bad example on how to solve it...
You need to read it twice and rethink it. Clear code is better and happens
to use isset().
Just my 2 cent of course...

Regards,
Erwin Moller
May 4 '07 #7
Erwin Moller kirjoitti:
Simon Stewart wrote:
>Art

Try something like this.

$holdchk= (strlen ($_POST['B1'])>0 and strlen($_POST['app_fname'])==0);
$action= ($holdchk)? "some.php": "other.php" ;
echo "<form method='POST' action='$action '>";

avoid isset and empty

Why avoid isset?
I don't think he knows what he's talking about. isset is essential.
I use that function in every script that receives clientinformati on...
Couldn't live without it.
Same here. And it's really handy when using forms with multiple submit
buttons, to see which was pressed. (print, edit, delete, for example.)
Personally I think your posted code is a bad example on how to solve it...
You need to read it twice and rethink it. Clear code is better and happens
to use isset().
Yeah, the example is indeed a bit messy. And concidering the level of
the OP, it's no help at all, it only confuses more. The OP requires the
"php for dummies" answer.

--
Ra*********@gma il.com

"Wikipedia on vähän niinq internetin raamattu, kukaan ei pohjimmiltaan
usko siihen ja kukaan ei tiedä mikä pitää paikkansa." -- z00ze
May 4 '07 #8
Art
Geoff, I tried modifying the code with your suggestions. It had the effect
of disabling the submit button. It seems like there has to be <form
method="POST" action=""in the html, to enable the submit button.
Variables aren't being recognized by the html as defining the form.

Thanks
Art
"Geoff Berrow" <bl******@ckdog .co.ukwrote in message
news:lo******** *************** *********@4ax.c om...
Message-ID: <na************ *******@bignews 7.bellsouth.net from Art
contained the following:
>>Sort of, but this is a scaled down version of the code, which was
requested.
I'm still stuck and still trying to understand why it's not working.

And you took no notice of my post on the subject before. You are still
echoing html /before/ the<htmltag!

I think you need something like this:

<?php

$holdchk = 0;
if (isset($_POST['B1'])) {
$form= "<br><br><b r>";
if (empty($_POST['app_fname'])) {
$holdchk = 1;
}

if ($holdchk === 1 ){
$form.= "<form method=\"POST\" action=\"some.p hp\">";
}

if ($holdchk === 0 ){
$form.= "<form method=\"POST\" action=\"other. php\">";

}
}
?>

<html>

<head>
</head>

<?php echo $form;?>

When
hit the submit button</font></b<input
type="submit" value="Submit" name="B1"></p>
</form>
</body>

</html>

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/

May 4 '07 #9
Message-ID: <DX************ *******@bignews 8.bellsouth.net from Art
contained the following:
>Geoff, I tried modifying the code with your suggestions. It had the effect
of disabling the submit button. It seems like there has to be <form
method="POST " action=""in the html, to enable the submit button.
Variables aren't being recognized by the html as defining the form.
I was in a hurry last night because I was going out and not really
paying attention. Your code /is/ still seriously screwed but that
wasn't the solution.

Can you please describe what you /expect/ it to do? I'm sure the answer
is very simple.

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
May 5 '07 #10

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

Similar topics

4
4689
by: mux | last post by:
Hi I found out that the following piece of code throws an error. 1 #include "stdio.h" 2 3 int main() 4 { 5 int a,b; 6 a= 10;
2
1619
by: estafford | last post by:
I am having trouble writing a conditional block using ASP.NET and C#. I am trying to do something like this: 1. if page is PostBack - transfer to another page 2. if not postback - connect to database and get information using a querystring id and create a DataReader (as DR). - generate a Form to display using values from the database query.
9
4783
by: Marty | last post by:
Hi, Does using the the conditional operator (?:) instead of the common "if" statement will give a performance gain in a C# .NET 2003 application (even in C# .NET 2005?). What is the advantage of using it in C# other than typing shorter if ? Thanks, Marty
5
2904
by: paulo | last post by:
Can anyone please tell me how the C language interprets the following code: #include <stdio.h> int main(void) { int a = 1; int b = 10; int x = 3;
43
7587
by: dev_cool | last post by:
Hello friends, I'm a beginner in C programming. One of my friends asked me to write a program in C.The purpose of the program is print 1 to n without any conditional statement, loop or jump. How is it possible? Please help me. Thanks in advance.
0
4130
by: RCapps | last post by:
When running the below SQL Query I keep getting the following error: Server: Msg 4924, Level 16, State 1, Line 1 ALTER TABLE DROP COLUMN failed because column 'ContractDef' does not exist in table 'zContractDefault'. For some reason it is only returning the first 11 chars of the column name? Any help would be greatly appreciated... This query searches a DB and determines which columns are 'Invalid' if the column name is >30 and...
10
4374
by: strife | last post by:
Hi, This is a homework question. I will try to keep it minimal so not to have anyone do it for me. I am really just stuck on one small spot. I have to figure out the highest number from a users input. I give them a menu to choose from, and I am stuck on only one of the choices. When this choice is picked I must allow the user to enter how many numbers he/she wants to enter; then I must figure out which number is the highest. I have...
13
1555
by: Neal Becker | last post by:
In hindsight, I am disappointed with the choice of conditional syntax. I know it's too late to change. The problem is y = some thing or other if x else something_else When scanning this my eye tends to see the first phrase and only later notice that it's conditioned on x (or maybe not notice at all!). Particularly if 'some thing or other' is long or complicated.
7
4315
by: tiptap | last post by:
Hey Guys, I have a huge statement loads of if statements in... and its getting bigger. On closer inspection there is only 3 difference in the select statement. so I thought I could cut the whole thing down to just 1 select statement if I have a conditional Having. I've simplified the IF statement down a bit to give you an idea of what im trying to achieve IF @month <> 0 & @diffFuture = 0 & @showDate <> 0
0
9424
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10223
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
10051
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9866
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
8879
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...
0
6675
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
5448
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3571
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.