Bookmarks

Yahoo Gmail Google Facebook Delicious Twitter Reddit Stumpleupon Myspace Digg

Search queries

dbf2mysql parameter, WWWXXXAPC, wwwxxxAPC, How to unsubscrube from dategen spam, docmd.close 2585, WWWXXXDOCO, nu vot, dhcpd lease file "binding state", WWWXXXDOCO, how to setup procmail to process html2text

Links

XODOX
Impressum

#1: Problems w/ goto

Posted on 2010-12-17 17:38:30 by Ethan Rosenberg

Dear List -

I am sending this again since it does not seem to have posted.

Ethan
+++++++
Dear List -

Thank you with your excellent help in the past. Here is another puzzler....

I am trying to write a program that can have two(2) independent forms
in one PHP file. When I run the code below [from PHP - A Beginner's
Guide], to which I have added a second form, it freezes. Without the
goto statements, it runs. When it does run, it displays both forms
on one Web screen. What I desire is for the first form to be
displayed, the data entered and then the second form displayed. In
an actual, not test program like this one, the data in the second
form would be dependent on the first form.

What did I do wrong?

Thanks in advance.

Here is the code:

================
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Project 4-4: Age Calculator</title>
</head>
<body>
<h2>Project 4-4: Age Calculator</h2>
<?php
// if form not yet submitted
// display form

$ender = 0;
begin:

if($ender == 1)
exit();
if (!isset($_POST['dob']))
{
start1:

echo " <form method=\"post\" action=\"agecalc2.php\">";
echo " Enter your date of birth, in mm/dd/yyyy format:
";
echo " <input type=\"text\" name=\"dob\" />";
echo " <p>";
echo " <input type=\"submit\" name=\"submit\" value=\"Submit\" />";
echo " </form>";

goto begin;
// if form submitted
// process form input
}
else
{
starter:
if (isset($_POST['cat']))
goto purr;
// split date value into components
$dateArr = explode('/', $_POST['dob']);

// calculate timestamp corresponding to date value
$dateTs = strtotime($_POST['dob']);

// calculate timestamp corresponding to 'today'
$now = strtotime('today');

// check that the value entered is in the correct format
if (sizeof($dateArr) != 3) {
die('ERROR: Please enter a valid date of birth');
}

// check that the value entered is a valid date
if (!checkdate($dateArr[0], $dateArr[1], $dateArr[2])) {
die('ERROR: Please enter a valid date of birth');
}

// check that the date entered is earlier than 'today'
if ($dateTs >= $now) {
die('ERROR: Please enter a date of birth earlier than today');
}

// calculate difference between date of birth and today in days
// convert to years
// convert remaining days to months
// print output
$ageDays = floor(($now - $dateTs) / 86400);
$ageYears = floor($ageDays / 365);
$ageMonths = floor(($ageDays - ($ageYears * 365)) / 30);
echo "You are approximately $ageYears years and $ageMonths months old.";
goto meow;
}

meow:
if (!isset($_POST['dob']))
goto begin;
if (!isset($_POST['cat']))
{


echo " <form method=\"post\" action=\"agecalc2.php\">";
echo "

Enter your kitten's name:
";
echo " <input type=\"text\" name=\"cat\" />";
echo " <p>";
echo " <input type=\"submit\" name=\"submit\" value=\"Submit
Kitten\" />";
echo " </form>";

}
else
{
purr:
$name_cat = $_POST['cat'];

echo "Your Kitten is $name_cat";
$ender = 1;
}
if ($ender == 0)
goto begin;
first_step:
?>

</body>
</html>

============

Ethan

MySQL 5.1 PHP 5 Linux [Debian (sid)]



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Report this message

#2: RE: Problems w/ goto

Posted on 2010-12-17 17:50:16 by Jay Blanchard

[snip]
Thank you with your excellent help in the past. Here is another
puzzler....

I am trying to write a program that can have two(2) independent forms=20
in one PHP file. When I run the code below [from PHP - A Beginner's=20
Guide], to which I have added a second form, it freezes. Without the=20
goto statements, it runs. When it does run, it displays both forms=20
on one Web screen. What I desire is for the first form to be=20
displayed, the data entered and then the second form displayed. In=20
an actual, not test program like this one, the data in the second=20
form would be dependent on the first form.

What did I do wrong?
[/snip]

You used GOTO.=20

In this case I would recommend using something like jQuery to 'hide' one
form until the other form is complete. PHP has sent the output to the
browser already, both forms are there and display when you remove the
GOTO.=20

GOTO should never be used like this.

GOTO should never be used.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Report this message

#3: RE: Problems w/ goto

Posted on 2010-12-17 18:08:15 by Steven Staples

On Fri, 2010-12-17 at 10:50 -0600, Jay Blanchard wrote:
> [snip]
> Thank you with your excellent help in the past. Here is another
> puzzler....
>
> I am trying to write a program that can have two(2) independent forms
> in one PHP file. When I run the code below [from PHP - A Beginner's
> Guide], to which I have added a second form, it freezes. Without the
> goto statements, it runs. When it does run, it displays both forms
> on one Web screen. What I desire is for the first form to be
> displayed, the data entered and then the second form displayed. In
> an actual, not test program like this one, the data in the second
> form would be dependent on the first form.
>
> What did I do wrong?
> [/snip]
>
> You used GOTO.
>
> In this case I would recommend using something like jQuery to 'hide' one
> form until the other form is complete. PHP has sent the output to the
> browser already, both forms are there and display when you remove the
> GOTO.
>
> GOTO should never be used like this.
>
> GOTO should never be used.
>

Wow... that brought me back to 1990... using basic and batch files...
I honestly didn't even know that the GOTO was still in existence,
especially within PHP.

I had to show the people in my office, and we all got a chuckle from teh
XKCD comic in the PHP documentation for GOTO
http://ca2.php.net/goto

Steve


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Report this message

#4: Re: [PHP] Problems w/ goto

Posted on 2010-12-17 18:16:25 by Richard Quadling

On 17 December 2010 17:08, Steve Staples <sstaples@mnsi.net> wrote:
> On Fri, 2010-12-17 at 10:50 -0600, Jay Blanchard wrote:
>> [snip]
>> Thank you with your excellent help in the past.  Here is another
>> puzzler....
>>
>> I am trying to write a program that can have two(2) independent forms
>> in one PHP file.  When I run the code below [from PHP - A Beginner'=
s
>> Guide], to which I have added a second form, it freezes.  Without t=
he
>> goto statements, it runs.  When it does run, it displays both forms
>> on one Web screen. What I desire is for the first form to be
>> displayed, the data entered and then the second form displayed.  In
>> an actual, not test program like this one, the data in the second
>> form would be dependent on the first form.
>>
>> What did I do wrong?
>> [/snip]
>>
>> You used GOTO.
>>
>> In this case I would recommend using something like jQuery to 'hide' one
>> form until the other form is complete. PHP has sent the output to the
>> browser already, both forms are there and display when you remove the
>> GOTO.
>>
>> GOTO should never be used like this.
>>
>> GOTO should never be used.
>>
>
> Wow... that brought me back to 1990... using basic and batch files...
> I honestly didn't even know that the GOTO was still in existence,
> especially within PHP.
>
> I had to show the people in my office, and we all got a chuckle from teh
> XKCD comic in the PHP documentation for GOTO
> http://ca2.php.net/goto
>
> Steve
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

And have you seen all the sad faces ...

: {

on http://docs.php.net/manual/en/control-structures.goto.php#92 763

Can't be good for them.

--=20
Richard Quadling
Twitter : EE : Zend
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Report this message

#5: Re: Problems w/ goto

Posted on 2010-12-17 18:19:27 by Nicholas Kell

--Apple-Mail-4-766554736
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
charset=us-ascii


On Dec 17, 2010, at 11:08 AM, Steve Staples wrote:

[snip /]

>>=20
>>=20
>> GOTO should never be used like this.
>>=20
>> GOTO should never be used.
>>=20
>=20
> Wow... that brought me back to 1990... using basic and batch files...
> I honestly didn't even know that the GOTO was still in existence,
> especially within PHP.
>=20
> I had to show the people in my office, and we all got a chuckle from =
teh
> XKCD comic in the PHP documentation for GOTO
> http://ca2.php.net/goto
>=20
> Steve

I didn't know it existed in PHP either. The cartoon is priceless. I =
should probably hang that up in my office somewhere.=

--Apple-Mail-4-766554736--

Report this message

#6: Re: Problems w/ goto

Posted on 2010-12-17 18:22:13 by Robert Cummings

On 10-12-17 12:08 PM, Steve Staples wrote:
> On Fri, 2010-12-17 at 10:50 -0600, Jay Blanchard wrote:
>> [snip]
>> Thank you with your excellent help in the past. Here is another
>> puzzler....
>>
>> I am trying to write a program that can have two(2) independent forms
>> in one PHP file. When I run the code below [from PHP - A Beginner's
>> Guide], to which I have added a second form, it freezes. Without the
>> goto statements, it runs. When it does run, it displays both forms
>> on one Web screen. What I desire is for the first form to be
>> displayed, the data entered and then the second form displayed. In
>> an actual, not test program like this one, the data in the second
>> form would be dependent on the first form.
>>
>> What did I do wrong?
>> [/snip]
>>
>> You used GOTO.
>>
>> In this case I would recommend using something like jQuery to 'hide' one
>> form until the other form is complete. PHP has sent the output to the
>> browser already, both forms are there and display when you remove the
>> GOTO.
>>
>> GOTO should never be used like this.
>>
>> GOTO should never be used.
>>
>
> Wow... that brought me back to 1990... using basic and batch files...
> I honestly didn't even know that the GOTO was still in existence,
> especially within PHP.
>
> I had to show the people in my office, and we all got a chuckle from teh
> XKCD comic in the PHP documentation for GOTO
> http://ca2.php.net/goto
>
> Steve

I was one of the people that argued in favour of GOTO on the Internals
list a few years ago. GOTO has a use, and a very good one at that. It is
by far the most efficient construct when creating parsers or other
similar types of logic flow. The demonized GOTO of the 80s was primarily
due to jumping to arbitrary points in the code, or in the case of basic
to arbitrary line numbers in the code which had little meaning for
future readers. When used properly within a well defined scope and with
well named labels, GOTO can be a superior choice. If you think GOTO
doesn't exist in many types of software, you need only grep for it in
the C source code for PHP, MySQL, and Apache.

Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Report this message

#7: Re: Problems w/ goto

Posted on 2010-12-17 18:53:26 by Daniel Brown

On Fri, Dec 17, 2010 at 11:38, Ethan Rosenberg <ethros@earthlink.net> wrote=
:
>
> I am trying to write a program that can have two(2) independent forms in =
one
> PHP file. =A0When I run the code below [from PHP - A Beginner's Guide], t=
o
> which I have added a second form, it freezes.
[snip!]
> What did I do wrong?

You presumed that "A Beginner's Guide" meant that it was a book
for beginners.... not one written by a beginner. Firstly, while GOTO
has a place in programming for certain things, the example (and I can
see the difference between the original and your additions) is
atrocious, and is not at all representative of any code you would
ever, ever want to put into production. That looks like a nightmare
of taking a math final, not knowing the answer, and suddenly realizing
you're in your underwear --- and have explosive uncontrollable
diarrhea on top of it, and your ankles are chained to the chair. Who
is the author? I saw one on Amazon by Vikram Vaswani, but there was
no use of GOTO that I could find there. I'd like to see what other
"tips" are included, or perhaps to see if that code was used in a
different context (as in, "what will work, but what not to do anyway,"
or, "I wrote this on April Fool's Day").

--=20
</Daniel P. Brown>
Network Infrastructure Manager
Documentation, Webmaster Teams
http://www.php.net/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Report this message

#8: Re: [PHP-DB] Re: [PHP] Problems w/ goto

Posted on 2010-12-17 18:57:44 by Daniel Brown

On Fri, Dec 17, 2010 at 12:16, Richard Quadling <rquadling@gmail.com> wrote:
>
> And have you seen all the sad faces ...
>
> : {
>
> on http://docs.php.net/manual/en/control-structures.goto.php#92 763
>
> Can't be good for them.

If only people knew how many hours - literally, hours - it took me
to keep that page clean and free from vandalism after GOTO was
introduced.

--
</Daniel P. Brown>
Network Infrastructure Manager
Documentation, Webmaster Teams
http://www.php.net/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Report this message

#9: Re: [PHP] Problems w/ goto

Posted on 2010-12-17 18:57:50 by Steven Staples

On Fri, 2010-12-17 at 12:22 -0500, Robert Cummings wrote:
> On 10-12-17 12:08 PM, Steve Staples wrote:
> > On Fri, 2010-12-17 at 10:50 -0600, Jay Blanchard wrote:
> >> [snip]
> >> Thank you with your excellent help in the past. Here is another
> >> puzzler....
> >>
> >> I am trying to write a program that can have two(2) independent forms
> >> in one PHP file. When I run the code below [from PHP - A Beginner's
> >> Guide], to which I have added a second form, it freezes. Without the
> >> goto statements, it runs. When it does run, it displays both forms
> >> on one Web screen. What I desire is for the first form to be
> >> displayed, the data entered and then the second form displayed. In
> >> an actual, not test program like this one, the data in the second
> >> form would be dependent on the first form.
> >>
> >> What did I do wrong?
> >> [/snip]
> >>
> >> You used GOTO.
> >>
> >> In this case I would recommend using something like jQuery to 'hide' one
> >> form until the other form is complete. PHP has sent the output to the
> >> browser already, both forms are there and display when you remove the
> >> GOTO.
> >>
> >> GOTO should never be used like this.
> >>
> >> GOTO should never be used.
> >>
> >
> > Wow... that brought me back to 1990... using basic and batch files...
> > I honestly didn't even know that the GOTO was still in existence,
> > especially within PHP.
> >
> > I had to show the people in my office, and we all got a chuckle from teh
> > XKCD comic in the PHP documentation for GOTO
> > http://ca2.php.net/goto
> >
> > Steve
>
> I was one of the people that argued in favour of GOTO on the Internals
> list a few years ago. GOTO has a use, and a very good one at that. It is
> by far the most efficient construct when creating parsers or other
> similar types of logic flow. The demonized GOTO of the 80s was primarily
> due to jumping to arbitrary points in the code, or in the case of basic
> to arbitrary line numbers in the code which had little meaning for
> future readers. When used properly within a well defined scope and with
> well named labels, GOTO can be a superior choice. If you think GOTO
> doesn't exist in many types of software, you need only grep for it in
> the C source code for PHP, MySQL, and Apache.
>
> Cheers,
> Rob.

Oh, i can see where it would be useful, i just hadn't realized it was
still in existence... and the cartoon, was blown up, and put in my
cubical :)

RAWR!!


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Report this message

#10: Re: [PHP] Problems w/ goto

Posted on 2010-12-17 18:59:37 by daniel.brown

On Fri, Dec 17, 2010 at 12:22, Robert Cummings <robert@interjinn.com> wrote:
>
> I was one of the people that argued in favour of GOTO on the Internals list
> a few years ago. GOTO has a use, and a very good one at that. It is by far
> the most efficient construct when creating parsers or other similar types of
> logic flow. The demonized GOTO of the 80s was primarily due to jumping to
> arbitrary points in the code, or in the case of basic to arbitrary line
> numbers in the code which had little meaning for future readers.

Not to mention failure to properly break, as in the OP's code example.

--
</Daniel P. Brown>
Dedicated Servers, Cloud and Cloud Hybrid Solutions, VPS, Hosting
(866-) 725-4321
http://www.parasane.net/

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Report this message

#11: RE: Problems w/ goto

Posted on 2010-12-18 18:45:17 by Geoffrey Bernardo Van Wyk

------=_NextPart_000_002A_01CB9EEC.1E44B1C0
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: 7bit

Ethan,

I tried to test your code, but I get this error next to the labels and goto
statements:

Language feature not compatible with PHP version indicated in project
settings

I have PHP 5.3.0.

Geoffrey

_____

From: Ethan Rosenberg [mailto:ethros@earthlink.net]
Sent: 17 December 2010 06:39 PM
To: php-db-lists.php.net; php-general@lists.php.net
Subject: [PHP] Problems w/ goto



Dear List -

I am sending this again since it does not seem to have posted.

Ethan
+++++++
Dear List -

Thank you with your excellent help in the past. Here is another puzzler....


I am trying to write a program that can have two(2) independent forms
in one PHP file. When I run the code below [from PHP - A Beginner's
Guide], to which I have added a second form, it freezes. Without the
goto statements, it runs. When it does run, it displays both forms
on one Web screen. What I desire is for the first form to be
displayed, the data entered and then the second form displayed. In
an actual, not test program like this one, the data in the second
form would be dependent on the first form.

What did I do wrong?

Thanks in advance.

Here is the code:

================
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Project 4-4: Age Calculator</title>
</head>
<body>
<h2>Project 4-4: Age Calculator</h2>
<?php
// if form not yet submitted
// display form

$ender = 0;
begin:

if($ender == 1)
exit();
if (!isset($_POST['dob']))
{
start1:

echo " <form method=\"post\" action=\"agecalc2.php\">";
echo " Enter your date of birth, in mm/dd/yyyy format:
";
echo " <input type=\"text\" name=\"dob\" />";
echo " <p>";
echo " <input type=\"submit\" name=\"submit\" value=\"Submit\" />";
echo " </form>";

goto begin;
// if form submitted
// process form input
}
else
{
starter:
if (isset($_POST['cat']))
goto purr;
// split date value into components
$dateArr = explode('/', $_POST['dob']);

// calculate timestamp corresponding to date value
$dateTs = strtotime($_POST['dob']);

// calculate timestamp corresponding to 'today'
$now = strtotime('today');

// check that the value entered is in the correct format
if (sizeof($dateArr) != 3) {
die('ERROR: Please enter a valid date of birth');
}

// check that the value entered is a valid date
if (!checkdate($dateArr[0], $dateArr[1], $dateArr[2])) {
die('ERROR: Please enter a valid date of birth');
}

// check that the date entered is earlier than 'today'
if ($dateTs >= $now) {
die('ERROR: Please enter a date of birth earlier than today');
}

// calculate difference between date of birth and today in days
// convert to years
// convert remaining days to months
// print output
$ageDays = floor(($now - $dateTs) / 86400);
$ageYears = floor($ageDays / 365);
$ageMonths = floor(($ageDays - ($ageYears * 365)) / 30);
echo "You are approximately $ageYears years and $ageMonths months
old.";
goto meow;
}

meow:
if (!isset($_POST['dob']))
goto begin;
if (!isset($_POST['cat']))
{


echo " <form method=\"post\" action=\"agecalc2.php\">";
echo "

Enter your kitten's name:
";
echo " <input type=\"text\" name=\"cat\" />";
echo " <p>";
echo " <input type=\"submit\" name=\"submit\" value=\"Submit
Kitten\" />";
echo " </form>";

}
else
{
purr:
$name_cat = $_POST['cat'];

echo "Your Kitten is $name_cat";
$ender = 1;
}
if ($ender == 0)
goto begin;
first_step:
?>

</body>
</html>

============

Ethan

MySQL 5.1 PHP 5 Linux [Debian (sid)]



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

_____

No virus found in this message.
Checked by AVG - www.avg.com
Version: 10.0.1170 / Virus Database: 1435/3323 - Release Date: 12/18/10


------=_NextPart_000_002A_01CB9EEC.1E44B1C0--

Report this message

#12: Re: Problems w/ goto

Posted on 2010-12-18 22:51:27 by David Hutto

On Sat, Dec 18, 2010 at 12:45 PM, Geoffrey Bernardo Van Wyk
<geoffrey.van.wyk@gmail.com> wrote:
> Ethan,
>
> I tried to test your code, but I get this error next to the labels and go=
to
> statements:

As a 'professional' programmer, working for an entity, we deal with
these problems as we go. As novices, we deal with it on a daily
basis. As computer scientists, we think of it as a problem already
solved, but in need of translation. Understand, buddy pal.


>
> Language feature not compatible with PHP version indicated in project
> settings
>
> I have PHP 5.3.0.
>
> Geoffrey
>
> =A0_____
>
> From: Ethan Rosenberg [mailto:ethros@earthlink.net]
> Sent: 17 December 2010 06:39 PM
> To: php-db-lists.php.net; php-general@lists.php.net
> Subject: [PHP] Problems w/ goto
>
>
>
> Dear List -
>
> I am sending this again since it does not seem to have posted.
>
> Ethan
> +++++++
> Dear List -
>
> Thank you with your excellent help in the past. =A0Here is another puzzle=
r....
>
>
> I am trying to write a program that can have two(2) independent forms
> in one PHP file. =A0When I run the code below [from PHP - A Beginner's
> Guide], to which I have added a second form, it freezes. =A0Without the
> goto statements, it runs. =A0When it does run, it displays both forms
> on one Web screen. What I desire is for the first form to be
> displayed, the data entered and then the second form displayed. =A0In
> an actual, not test program like this one, the data in the second
> form would be dependent on the first form.
>
> What did I do wrong?
>
> Thanks in advance.
>
> Here is the code:
>
> ================
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
> =A0 =A0"DTD/xhtml1-transitional.dtd">
> <html xmlns=3D"http://www.w3.org/1999/xhtml" xml:lang=3D"en" lang=3D"en">
> =A0 <head>
> =A0 =A0 <title>Project 4-4: Age Calculator</title>
> =A0 </head>
> =A0 <body>
> =A0 =A0 <h2>Project 4-4: Age Calculator</h2>
> <?php
> =A0 =A0 // if form not yet submitted
> =A0 =A0 // display form
>
> $ender =3D 0;
> begin:
>
> =A0 =A0 =A0 =A0 if($ender == 1)
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 exit();
> =A0 =A0 if (!isset($_POST['dob']))
> =A0 =A0 {
> start1:
>
> echo " =A0<form method=3D\"post\" action=3D\"agecalc2.php\">";
> echo " =A0Enter your date of birth, in mm/dd/yyyy format:
";
> echo " =A0<input type=3D\"text\" name=3D\"dob\" />";
> echo " =A0 =A0 =A0<p>";
> echo " =A0<input type=3D\"submit\" name=3D\"submit\" value=3D\"Submit\" /=
>";
> echo " =A0</form>";
>
> goto begin;
> =A0 =A0 // if form submitted
> =A0 =A0 // process form input
> =A0 =A0 }
> else
> =A0 =A0 {
> starter:
> if (isset($_POST['cat']))
> =A0 =A0 =A0 =A0 goto purr;
> =A0 =A0 =A0 // split date value into components
> =A0 =A0 =A0 $dateArr =3D explode('/', $_POST['dob']);
>
> =A0 =A0 =A0 // calculate timestamp corresponding to date value
> =A0 =A0 =A0 $dateTs =3D strtotime($_POST['dob']);
>
> =A0 =A0 =A0 // calculate timestamp corresponding to 'today'
> =A0 =A0 =A0 $now =3D strtotime('today');
>
> =A0 =A0 =A0 // check that the value entered is in the correct format
> =A0 =A0 =A0 if (sizeof($dateArr) !=3D 3) {
> =A0 =A0 =A0 =A0 die('ERROR: Please enter a valid date of birth');
> =A0 =A0 =A0 }
>
> =A0 =A0 =A0 // check that the value entered is a valid date
> =A0 =A0 =A0 if (!checkdate($dateArr[0], $dateArr[1], $dateArr[2])) {
> =A0 =A0 =A0 =A0 die('ERROR: Please enter a valid date of birth');
> =A0 =A0 =A0 }
>
> =A0 =A0 =A0 // check that the date entered is earlier than 'today'
> =A0 =A0 =A0 if ($dateTs >=3D $now) {
> =A0 =A0 =A0 =A0 die('ERROR: Please enter a date of birth earlier than tod=
ay');
> =A0 =A0 =A0 }
>
> =A0 =A0 =A0 // calculate difference between date of birth and today in da=
ys
> =A0 =A0 =A0 // convert to years
> =A0 =A0 =A0 // convert remaining days to months
> =A0 =A0 =A0 // print output
> =A0 =A0 =A0 $ageDays =3D floor(($now - $dateTs) / 86400);
> =A0 =A0 =A0 $ageYears =3D floor($ageDays / 365);
> =A0 =A0 =A0 $ageMonths =3D floor(($ageDays - ($ageYears * 365)) / 30);
> =A0 =A0 =A0 echo "You are approximately $ageYears years and $ageMonths mo=
nths
> old.";
> =A0 =A0 =A0 goto meow;
> =A0}
>
> meow:
> =A0 =A0 =A0 =A0 if (!isset($_POST['dob']))
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 goto begin;
> =A0 =A0 if (!isset($_POST['cat']))
> =A0 =A0 {
>
>
> echo " =A0<form method=3D\"post\" action=3D\"agecalc2.php\">";
> echo " =A0

Enter your kitten's name:
";
> echo " =A0<input type=3D\"text\" name=3D\"cat\" />";
> echo " =A0<p>";
> echo " =A0 =A0 =A0<input type=3D\"submit\" name=3D\"submit\" value=3D\"Su=
bmit
> Kitten\" />";
> echo " =A0 =A0</form>";
>
> }
> else
> {
> purr:
> =A0 =A0 =A0 =A0 $name_cat =3D $_POST['cat'];
>
> =A0 =A0 =A0 =A0 echo "Your Kitten is $name_cat";
> =A0 =A0 =A0 =A0 $ender =3D 1;
> }
> if ($ender == 0)
> =A0 =A0 =A0 =A0 goto begin;
> first_step:
> ?>
>
> =A0 </body>
> </html>
>
> ============
>
> Ethan
>
> MySQL 5.1 =A0PHP 5 =A0Linux [Debian (sid)]
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
> =A0_____
>
> No virus found in this message.
> Checked by AVG - www.avg.com
> Version: 10.0.1170 / Virus Database: 1435/3323 - Release Date: 12/18/10
>
>

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Report this message

#13: Re: Problems w/ goto

Posted on 2010-12-18 23:00:13 by David Hutto

You approved all of us, no matter the peer review, when you signed up
or the list. The accumulation of knowledge,
is insurmountable when delivered as a whole, but devourable if you
need satiation of appetite.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Report this message

#14: Re: Problems w/ goto

Posted on 2010-12-18 23:02:02 by David Hutto

or maybe it's saturday morning and i'm drunk?

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Report this message

#15: Re: Problems w/ goto

Posted on 2010-12-18 23:08:53 by David Hutto

check out my new sig.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Report this message

#16: Re: Re: [PHP] Problems w/ goto

Posted on 2010-12-20 13:37:19 by Daniel Brown

On Sat, Dec 18, 2010 at 17:02, David Hutto <smokefloat@gmail.com> wrote:
> or maybe it's saturday morning and i'm drunk?

This seems to be the most likely, and considering how all messages
are permanently and independently archived and propagate throughout
the Internet, it might be a good reason not to go nuts in sending
unrelated and unintelligible messages of this nature in the future.

--
</Daniel P. Brown>
Network Infrastructure Manager
Documentation, Webmaster Teams
http://www.php.net/

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Report this message

#17: Re: Re: [PHP] Problems w/ goto

Posted on 2010-12-20 15:11:31 by David Hutto

On Mon, Dec 20, 2010 at 7:37 AM, Daniel Brown <danbrown@php.net> wrote:
> On Sat, Dec 18, 2010 at 17:02, David Hutto <smokefloat@gmail.com> wrote:
>> or maybe it's saturday morning and i'm drunk?
>
> =A0 =A0This seems to be the most likely, and considering how all messages
> are permanently and independently archived and propagate throughout
> the Internet, it might be a good reason not to go nuts in sending
> unrelated and unintelligible messages of this nature in the future.

Yeah, that hindsights 20/20 ain't it?

>
> --
> </Daniel P. Brown>
> Network Infrastructure Manager
> Documentation, Webmaster Teams
> http://www.php.net/
>



--=20
They're installing the breathalyzer on my email account next week.

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Report this message