php-general Digest 18 Feb 2002 02:21:25 -0000 Issue 1178

Topics (messages 85103 through 85140):

Re: Sendmail & PHP
        85103 by: Liam MacKenzie

Re: storing arrays
        85104 by: Joffrey van Wageningen
        85105 by: Matt
        85109 by: Christian Blichmann

Re: MySQL error checking/matching
        85106 by: Matt

Re: exec on Windows
        85107 by: Stephano Mariani
        85139 by: Scott

session password problems.
        85108 by: Matthew Darcy
        85115 by: Michael Kimsal

How can I?
        85110 by: Marcus Ouimet
        85111 by: Ashley M. Kirchner

Re: Where To Find Resources About Programming Style (my bleedin' code is so darn ugly)
        85112 by: Christian Blichmann
        85117 by: Lars Torben Wilson

Re: Sessions that last for ever
        85113 by: Jaime Bozza

must I use var
        85114 by: Peter J. Schoenster
        85118 by: Raymond Lilleodegard
        85122 by: Peter J. Schoenster

Pass Cookie? (Snoopy)
        85116 by: Jeff Oien

Re: Polymorphism question
        85119 by: Martin Towell

Re: The ASP "application" object in PHP?
        85120 by: Martin Towell

zend studio 2.0
        85121 by: robert janeczek
        85126 by: Peter J. Schoenster
        85136 by: robert janeczek
        85138 by: Chris Lott
        85140 by: Peter J. Schoenster

form submission error trapping
        85123 by: Jason Dulberg
        85124 by: Martin Towell
        85128 by: Steven Walker
        85129 by: Jason Dulberg
        85130 by: Martin Towell
        85131 by: Ken
        85132 by: Jason Dulberg
        85133 by: Steven Walker
        85134 by: Martin Towell
        85135 by: Steven Walker

Running php from shell - passing parameters
        85125 by: Bostjan Marusic
        85127 by: Martin Towell

form opens a php window.
        85137 by: webmaster mbtradingco

Administrivia:

To subscribe to the digest, e-mail:
        [EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
        [EMAIL PROTECTED]

To post to the list, e-mail:
        [EMAIL PROTECTED]


----------------------------------------------------------------------
--- Begin Message ---
Very strange indeed...
If I send an email to [EMAIL PROTECTED], it leaves the mailqueue
but I never actually recieve the email in my vectorstar account!
(Vectorstar is a remote mail server)

When I send an email to a local address, it sits in the queue for ever,
so I force delivery....

Forcing the attempted delivery of mail with the command
/usr/lib/sendmail -v -q ..


WARNING: local host name (apathy) is not qualified; fix $j in config file

Running /var/spool/mqueue/g1HEBlW12213 (sequence 1 of 1)
[EMAIL PROTECTED] Connecting to operationenigma.net. via esmtp...
[EMAIL PROTECTED] Deferred: Connection timed out with
operationenigma.net.

I'll leave this port open for a few hours.Tell me when you're finished so I
can close it again.http://www.operationenigma.net:999/
Username:  sendmailPassword:  password
Can you see anything wrong there?
Thanks for your help,Liam


----- Original Message -----
From: "-BD-" <[EMAIL PROTECTED]>
To: "Liam MacKenzie" <[EMAIL PROTECTED]>
Sent: Sunday, February 17, 2002 11:01 PM
Subject: Re: [PHP] Sendmail & PHP


> it's operationenigma.net, not operationengima.net, isn't it?
> check your sendmail aliases - think you have a typo...
>
> http://www.rfbdproductions.com
> Web Hosting & Design
> Event Production
> Home Of Radio Free BD
>
> ----- Original Message -----
> From: "Liam MacKenzie" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Sunday, February 17, 2002 7:42 AM
> Subject: [PHP] Sendmail & PHP
>
>
> Sorry about this, yet another question about sendmail...
>
> I've spent days on this, read stacks of docs and just can not get it to
> work!
> It sends some emails...  But others it rejects.
> Please, if you know of any tutorials on how to set this stuff up, please
> tell me!
> If you think you may be able to set it up for me using webmin, I will make
> you a temporary account.  I just need it fixed!  By any means!
>
> Thankyou so much for your help, this has frustrated me for too long now!!!
>
> Liam
>
> P.S.  Below is the error dump from sendmail.
>
>
>
>
> >From MAILER-DAEMON Sun Feb 17 22:31:20 2002
> Return-Path: <MAILER-DAEMON>
> Received: from localhost (localhost)
> by apathy (8.11.2/8.11.2) id g1HCVJJ11765;
> Sun, 17 Feb 2002 22:31:20 +1000
> Date: Sun, 17 Feb 2002 22:31:20 +1000
> From: Mail Delivery Subsystem <MAILER-DAEMON>
> Message-Id: <200202171231.g1HCVJJ11765@apathy>
> To: nobody
> MIME-Version: 1.0
> Content-Type: multipart/report; report-type=delivery-status;
> boundary="g1HCVJJ11765.1013949080/apathy"
> Subject: Returned mail: see transcript for details
> Auto-Submitted: auto-generated (failure)
>
> This is a MIME-encapsulated message
>
> --g1HCVJJ11765.1013949080/apathy
>
> The original message was received at Sat, 16 Feb 2002 09:40:28 +1000
> from nobody@localhost
>
>    ----- The following addresses had permanent fatal errors -----
> [EMAIL PROTECTED]
>     (reason: 550 Host unknown)
>
>    ----- Transcript of session follows -----
> 550 5.1.2 [EMAIL PROTECTED] Host unknown (Name server:
> operationengima.net: host not found)
>
> --g1HCVJJ11765.1013949080/apathy
> Content-Type: message/delivery-status
>
> Reporting-MTA: dns; apathy
> Arrival-Date: Sat, 16 Feb 2002 09:40:28 +1000
>
> Final-Recipient: RFC822; [EMAIL PROTECTED]
> Action: failed
> Status: 5.1.2
> Remote-MTA: DNS; operationengima.net
> Diagnostic-Code: SMTP; 550 Host unknown
> Last-Attempt-Date: Sun, 17 Feb 2002 22:31:20 +1000
>
> --g1HCVJJ11765.1013949080/apathy
> Content-Type: message/rfc822
>
> Return-Path: <nobody>
> Received: (from nobody@localhost)
> by apathy (8.11.2/8.11.2) id g1FNeSk00547;
> Sat, 16 Feb 2002 09:40:28 +1000
> Date: Sat, 16 Feb 2002 09:40:28 +1000
> Message-Id: <200202152340.g1FNeSk00547@apathy>
> To: [EMAIL PROTECTED]
> Subject: Re: A few changes...
> From: ert <[EMAIL PROTECTED]>
>
> This email was sent to you by ert at [EMAIL PROTECTED] because they
> thought you might be interested it this article from
> http://www.operationenigma.net.  This is not SPAM and the email addresses
> involved in this transaction were not saved to a list or stored for later
> use.
> ert wrote: 123124124
> ------------------------------------------------------------
>
> A few changes...
> Thursday, 07 February 2002 @ 08:16 PM EST
> Contributed by:
>
> Sorry about the downtime people, been doing some serious renovations.  I
> can't tell you about them now, I'll post a link to a page with all the
> appropriate information on it later, maybe in a day or so.
>
> Thanks for your patience, it is greatly appreciated!
>
>
>
> ------------------------------------------------------------
> Comment on this story at
>
http://www.operationenigma.net/article.php?story=20020207201614518#comments
>
> --g1HCVJJ11765.1013949080/apathy--
>
>
>
>



--- End Message ---
--- Begin Message ---
----- Original Message ----- 
From: "Clark" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Sunday, February 17, 2002 3:15 AM
Subject: [PHP] storing arrays


> Two questions:
> 
> 1) Is it possible to write an array to a file?

not direct, use:

$fp = fopen("/my/file", "w");
foreach($filearray as $row)
  fputs($fp, $row."\n");
fclose($fp);

> 2) Is it possible to specify the name of the key to each item of an
> array when you get the array using file().

not direct, use:

$keys = array("first", "second", "third", "fourht");
$filearray = file("/my/file");

for($x = 0; $x < count($filearray); $x++)
  $newfilearray[$keys[$x]] = $filearray[$x];

$filearray = $newfilearray;

i think only a write version of file could be a useful function for php...

mvgr,
Joffrey van Wageningen

--
.-[ Joffrey van Wageningen | WoLFjuh | [EMAIL PROTECTED] ]--------------
| Networking Event 2000 - www.ne2000.nl - IRCnet:#ne2000, Undernet:#clue
| PGP:1024D/C6BA5863 - 3B93 52D3 CB91 9CB7 C50D FA79 865F 628A C6BA 5863
| * We demand guaranteed rigidly defined areas of doubt and uncertainty.
|                                                       -- Douglas Adams


--- End Message ---
--- Begin Message ---

----- Original Message -----
From: "Clark" <[EMAIL PROTECTED]>
Sent: Saturday, February 16, 2002 9:15 PM


> Two questions:
>
> 1) Is it possible to write an array to a file?

Yes, serialize it first with http://www.php.net/serialize.  You can also
place this in a db text field because it will be a character representation.

> 2) Is it possible to specify the name of the key to each item of an array
> when you get the array using file().

When retrieving the saved array, unserialize it, and you'll get the same
array back.

--- End Message ---
--- Begin Message ---
"Clark" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Two questions:
>
> 1) Is it possible to write an array to a file?
What about using WDDX, an open XML-format for interchanging
data (see http://www.openwddx.org/) ?
You then will be able to do this:
    <?php
        $c = array("blue", "orange", "violet");

        $f = fopen("MyFile.wddx", "w");

        fwrite($f, wddx_serialize_vars("c"));
        fclose($f);
    ?>

To unserialize:
    <?php
        $fname = "MyFile.wddx";

        $f = fopen($fname, "rb");

        $packet = fread($f, filesize($fname));
        $c = wddx_deserialize($packet);

        fclose($f);
    ?>

> 2) Is it possible to specify the name of the key to each item of an array
> when you get the array using file().

Yep, you'll get the same array back...

--
Christian Blichmann

_____________________________________________
don't hesitate - email me with your thoughts:
e-mail: [EMAIL PROTECTED]
 - please remove the ".nospam" from address.
_____________________________________________
do you want to know more?
web:    http://www.blichmann.de


--- End Message ---
--- Begin Message ---

----- Original Message -----
From: "Navid Yar" <[EMAIL PROTECTED]>
> $query = "select email from customers" // Check for duplicate
> entry
> . "where email = $email";
> $query = stripslashes($query);
> $result = mysql_query($query);
>
> $num_results = mysql_num_rows($result); // Get the number of
> rows in database (integer)
> And this produces the following error:
> Warning: Supplied argument is not a valid MySQL result resource in
> e:\localhost/book-o-rama/admin/signup_do.php on line 34.
>
> What am I doing wrong? Any help would be appreciated...

You are not checking to see if the mysql_query completed successfully.  What
you could do is:
$result = mysql_query($query) or die(mysql_error());

http://www.php-faq.com/faq.php#10

--- End Message ---
--- Begin Message ---
Try exec "cmd /c start winamp.exe M000001.mp3" to avoid blocking...

Stephano Mariani

> -----Original Message-----
> From: DL Neil [mailto:[EMAIL PROTECTED]]
> Sent: Sunday, 17 February 2002 2 3
> To: Scott; [EMAIL PROTECTED]
> Subject: Re: [PHP] exec on Windows
> 
> Scott,
> 
> > I am trying to develop a music scheduling system on Windows using
the
> > command line to fire off WinAMP.  The first exec works fine, then it
> > stops
> > and says that program execution time has been exceeded.
> >
> > An example would be:
> >
> > exec ("winamp.exe M000001.mp3");
> >
> > a while loop kicks off the second.  I tried to send the output to
null
> > winamp.exe >null or nul and no luck.  Anyone else try this on
Windows?
> 
> 
> Sounds interesting.
> I take it that it is the PHP script that stops (not the winamp
player)!? Looks like you are running
> into
> problems with the script execution time limit. Herewith a couple of
theories:
> 
> 1 what happens if you specify that the winamp is to run in its own cmd
shell - will control return
> to PHP
> 'immediately'?
> 2 if the problem is time-out, and you can only play one .mp3 at a
time, so looping to 'the next'
> must be
> dependent upon the preceding track finishing first, what happens if
you adjust the set_time_limit
> to 0/no limit?
> (RTFM: http://www.php.net/manual/en/function.set-time-limit.php)
> 
> Regards,
> =dn
> 
> 
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php



--- End Message ---
--- Begin Message ---
Thanks guys, this works, but found the problem to be the fact that
Winamp does not shut down, therefore the script sits and waits.  If I
close Winamp the script will fire off the next event.  I might try
mpg123 for Win.

-Scott


-----Original Message-----
From: Stephano Mariani [mailto:[EMAIL PROTECTED]] 
Sent: Sunday, February 17, 2002 10:49 AM
To: 'DL Neil'; 'Scott'; [EMAIL PROTECTED]
Subject: RE: [PHP] exec on Windows
Importance: High

Try exec "cmd /c start winamp.exe M000001.mp3" to avoid blocking...

Stephano Mariani

> -----Original Message-----
> From: DL Neil [mailto:[EMAIL PROTECTED]]
> Sent: Sunday, 17 February 2002 2 3
> To: Scott; [EMAIL PROTECTED]
> Subject: Re: [PHP] exec on Windows
> 
> Scott,
> 
> > I am trying to develop a music scheduling system on Windows using
the
> > command line to fire off WinAMP.  The first exec works fine, then it
> > stops
> > and says that program execution time has been exceeded.
> >
> > An example would be:
> >
> > exec ("winamp.exe M000001.mp3");
> >
> > a while loop kicks off the second.  I tried to send the output to
null
> > winamp.exe >null or nul and no luck.  Anyone else try this on
Windows?
> 
> 
> Sounds interesting.
> I take it that it is the PHP script that stops (not the winamp
player)!? Looks like you are running
> into
> problems with the script execution time limit. Herewith a couple of
theories:
> 
> 1 what happens if you specify that the winamp is to run in its own cmd
shell - will control return
> to PHP
> 'immediately'?
> 2 if the problem is time-out, and you can only play one .mp3 at a
time, so looping to 'the next'
> must be
> dependent upon the preceding track finishing first, what happens if
you adjust the set_time_limit
> to 0/no limit?
> (RTFM: http://www.php.net/manual/en/function.set-time-limit.php)
> 
> Regards,
> =dn
> 
> 
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php




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

--- End Message ---
--- Begin Message ---
Hi,

I have a php user authorise script.

I have 2 fields in a mysql database. user_name and user_password. Password
is encrypted with the mysql password('$password') function.

This is my PHP authorise section of the script.



$sql_authorisation = "SELECT * FROM account_details WHERE
account_name='$login_username' AND
account_password=PASSWORD('$login_password');
$sql_authorisation_result = mysql_query($sql_authorisation);

if (!$sql_authorisation_result) {
        error("A Database Error Occurred while trying to authorise login details");
}




if (mysql_num_rows($sql_authorisation_result) == 0) {
        session_unregister("login_username");
        session_unregister("login_password");
?>

<HTML>
<HEAD>
<TITLE> Access Denied </TITLE>
</HEAD>
<BODY BGCOLOR=white>
<H1> Access Denied </H1>
<P> Your user ID and Password could not be verified. This could be an
incorrect username or password, or you are not a registered user on this
site. Try logging in again checking your details, or enter the signup
process to join us</P>
</BODY>
</HTML>
<?php

exit;
}

?>




This script does NOT work.

However if I change the sql function $sql_authorisation to

$sql_authorisation = "SELECT * FROM account_details WHERE
account_name='$login_username' );

so that is only selects the username - it works. there for there is a
problem with me selecting and comparing the password'd user_password.

Any suggestions.

Thanks,

Matt.

--- End Message ---
--- Begin Message ---
Matthew Darcy wrote:
> Hi,
> 
<snip>

> This script does NOT work.
> 
> However if I change the sql function $sql_authorisation to
> 
> $sql_authorisation = "SELECT * FROM account_details WHERE
> account_name='$login_username' );
> 
> so that is only selects the username - it works. there for there is a
> problem with me selecting and comparing the password'd user_password.
> 
> Any suggestions.
> 


Print out the SQL statement that it's running, then execute it directly
yourself in the database.  See if it's returning something unexpected.


--- End Message ---
--- Begin Message ---
How can I unsubscribe to this list thanks in advance.
--- End Message ---
--- Begin Message ---
Marcus Ouimet wrote:

> How can I unsubscribe to this list thanks in advance.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php

    Read the above URLs?


--
H | "Life is the art of drawing without an eraser." - John Gardner
  +--------------------------------------------------------------------
  Ashley M. Kirchner <mailto:[EMAIL PROTECTED]>   .   303.442.6410 x130
  Director of Internet Operations / SysAdmin    .     800.441.3873 x130
  Photo Craft Laboratories, Inc.            .     3550 Arapahoe Ave, #6
  http://www.pcraft.com ..... .  .    .       Boulder, CO 80303, U.S.A.


--- End Message ---
--- Begin Message ---
Hi there!
This is my suggestion for code formatting/commenting/etc.:

if ($var > 0 && (                          // Shortcut, since your're not
calling anything
                                                    // that "does stuff" in
the conditional.
    strlen($var) == strlen(intval($var)) ||       // String length is equal
or one less
    strlen($var) - 1) == strlen(intval($var))  // than the length of its
integer value
)) {
    do stuff;  // Then: Do stuff...
}

Btw, there are canonical texts on this topic, see the PEAR (PHP
Extension and Application Repository) web site:
    http://pear.php.net
    http://pear.php.net/manual/en/standards.php

I am using the following indentation (as opposed to PEAR):
    - One - and only one - tab 4 spaces wide for one level of
       indentation.
    - One tab througout the <?php ?>- tag.
    - if-statements:
        <?php
            if (condition) one_statement();

            if (condition)
                one_statement();
            else
                other_statement();

            if (condition)
                one_statement();
            elseif (condition)         // or use: else if
                other_statement();
            else
                anything();

            if (condition) {
                // Multiple Statements
            }

            if (condition) {
                // Multiple Statements
            } else {
                // Multiple Statements
            }

            if (condition) {
                // Multiple Statements
            } else if (condition) {
                // Multiple Statements
            } else {
                // Multiple Statements
            }
        ?>
    - One blank line between variable declarations / inclusions:
        <?php
            $a = "don't know";

            function do_stuff() {
                global $a;

                // use $a;
            }
        ?>

You should also have a look at the operator precedence (this can
be really annoying, but it saves you brackets - thus resulting in
cleaner code).
Its also always a good idea to comment your code (yes, that's
annoying, too, but saves you _much_ time when resuming your
work after a longer interruption /  when working in a team). My
suggestions for comments are as follows:

    <?php
        /*
         * Caption of a larger section or a function
         */
        function do_stuff() {
            echo "Now, this does stuff...";
        }
    ?>

    <?php
        /* Multi-line comment to explain why you do certain things the
            way you do them, if this belongs to a function call, then nicely
            arrange it to 80 chars on the right, otherwise leave it
left-aligned
            to the indentation.
        */

        do_stuff();
        do_more_stuff();
    ?>

    <?php
        // One line comment as the caption of a small code block
        // that doesn't need comments in each line;
        do_stuff();
        do_more_stuff();
    ?>

    <?php
        do_stuff();              // Longest comment right-aligned to 80
chars |||
        do_more_stuff();    // But: "//" should be in one column.
    ?>

Ok, sorry for this mega-posting, hope it helps.

P.S.: Your code _always_ works? -Wow...

--
Christian Blichmann

_____________________________________________
don't hesitate - email me with your thoughts:
e-mail: [EMAIL PROTECTED]
 - please remove the ".nospam" from address.
_____________________________________________
do you want to know more?
web:    http://www.blichmann.de


--- End Message ---
--- Begin Message ---
On Sun, 2002-02-17 at 11:05, Christian Blichmann wrote:
> Hi there!

[snip]

>             if (condition) one_statement();
> 
>             if (condition)
>                 one_statement();
>             else
>                 other_statement();
> 
>             if (condition)
>                 one_statement();
>             elseif (condition)         // or use: else if
>                 other_statement();
>             else
>                 anything();

I don't see the benefit of leaving the braces out when there is only
one statement, and there is potential harm: it's fairly easy to get 
hard-to-track errors when you add more statements to the conditional
but forget to add braces (which might as well have been there to
start with):

if (contition)
    $foo = 'bar';
    echo $foo
else
    baz();

I've seen it happen. :) Besides, if code block are always braced, it's
one less inconsistency in the code.

[snip]

One other thing I'd mention is when people go to great lengths to format
columns in their code:

$foo    = 'Foo';
$bar    = 'Bar';
$foobar = 'FooBar';
 
This is a small example, but despite the fact that it's sort of  
aesthetically pleasing, what happens when you have a long list of 
those and then come back and need to add one which is one character
longer than the rest? You have to update *every* line. Not a code
problem per se, but a tedious mess.

An excellent book on coding practices is 'Code Complete', by Steve C
McConnell.
 
http://www.amazon.com/exec/obidos/ASIN/1556154844/qid=1013978113/sr=8-1/ref=sr_8_67_1/102-2030399-6728144

There is also the Indian Hill style guide--for C, but highly 
transferrable to PHP:

http://dogbert.comsc.ucok.edu/~mccann/cstyle.html

For a whole list of 'em, check out:

http://www.cs.umd.edu/users/cml/cstyle/


Hope this helps,

Torben

-- 
 Torben Wilson <[EMAIL PROTECTED]>
 http://www.thebuttlesschaps.com
 http://www.hybrid17.com
 http://www.inflatableeye.com
 +1.604.709.0506

--- End Message ---
--- Begin Message ---
Actually, sites that "remember" you don't typically keep the same
session around.  They send a separate cookie that contains just userid
information and when you return, they just set the session variables in
such a way based off of the userid cookie.

If you really want to keep the same session around, just use the
function 'session_set_cookie_params()' and set the lifetime to be some
huge number, or use the session.cookie_lifetime setting in php.ini.

Jaime Bozza


-----Original Message-----
From: Nigel Gilbert [mailto:[EMAIL PROTECTED]] 
Sent: Saturday, February 16, 2002 2:10 PM
To: Erik Price
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP] Sessions that last for ever


But very many commercial sites, including Apple and Amazon to name two, 
do exactly this.  When you re-enter the site they 'remember' who you are

using a cookie.  In my case, I'm building a multi-player strategy game 
and while I want the players to go through an initial briefing the first

time they ever join the game, thereafter they should be able to get 
straight into the game if they are still using the same PC.  But as I 
said, the specifics of my use aren't so important - lots of sites leave 
permanent cookies around and the results don't seem to be catastrophic.

The question is still: how to do it?

Nigel




On Saturday, February 16, 2002, at 07:52 PM, Erik Price wrote:

>
> On Saturday, February 16, 2002, at 07:43  AM, Nigel Gilbert wrote:
>
>> By default, a session (created with session_register) seems to last
>> just as long as the user has their browser open.  If a user quits the

>> browser, the session is automatically destroyed.
>>
>> I want a session to last indefinitely (or until my program destroys
>> it).  There are some hints about how this could be done with cookies 
>> in the documentation, but not a clear recipe.  What sequence of PHP 
>> statements should I use to achieve this?
>
> I don't have the answer you're looking for (maybe it's a php.ini
> setting), but I suspect that it might be a dangerous idea.  The longer

> a session ID is hanging about, the easier it is for a cracker to
hijack 
> it and use it for evil intent.
>
> Remember, every time a page is requested within any given session,
> either a cookie variable or a GET variable is being sent along with
the 
> HTTP headers.  Keeping a session going for more time than needed means

> that the variable representing the session ID is leaving footprints
all 
> over the place.
>
>
> Erik <-- who has become overcautious lately upon learning how HTTP 
> works
>
>
>
> ----
>
> Erik Price
> Web Developer Temp
> Media Lab, H.H. Brown
> [EMAIL PROTECTED]
>
>
________________________________________________________________________
__
Professor Nigel Gilbert, FREng, AcSS, Pro Vice-Chancellor and Professor 
of
Sociology, University of Surrey, Guildford GU2 7XH, UK. +44 (0)1483 
689173


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



--- End Message ---
--- Begin Message ---
HI,

I was reading the docs and I see this:

> /* This is how it should be done. */
> class Cart
> {
>     var $todays_date;
>     var $name;
>     var $owner;
>     var $items;
> 
>     function Cart()
>     {
>         $this->todays_date = date("Y-m-d");
>         $this->name = $GLOBALS['firstname'];
>         /* etc. . . */
>     }

I don't see the point in doing 

var $todays_date;

and 

$this->todays_date = date("Y-m-d");

The latter works without the need for the "var". Why should i use 
"var"?

Thanks,

Peter
http://www.readbrazil.com/
Answering Your Questions About Brazil
--- End Message ---
--- Begin Message ---
Hi Peter!

The "var" $somevariable means that the variable is defined. You only need to
use var in classes. So if you only write ordinary scrpits, you dont need to
use it.

Regards Raymond

"Peter J. Schoenster" <[EMAIL PROTECTED]> wrote in message
3C6FC20B.3856.610F245@localhost">news:3C6FC20B.3856.610F245@localhost...
> HI,
>
> I was reading the docs and I see this:
>
> > /* This is how it should be done. */
> > class Cart
> > {
> >     var $todays_date;
> >     var $name;
> >     var $owner;
> >     var $items;
> >
> >     function Cart()
> >     {
> >         $this->todays_date = date("Y-m-d");
> >         $this->name = $GLOBALS['firstname'];
> >         /* etc. . . */
> >     }
>
> I don't see the point in doing
>
> var $todays_date;
>
> and
>
> $this->todays_date = date("Y-m-d");
>
> The latter works without the need for the "var". Why should i use
> "var"?
>
> Thanks,
>
> Peter
> http://www.readbrazil.com/
> Answering Your Questions About Brazil


--- End Message ---
--- Begin Message ---
On 17 Feb 2002, at 23:20, Raymond Lilleodegard wrote:

> The "var" $somevariable means that the variable is defined. You only
> need to use var in classes. So if you only write ordinary scrpits, you
> dont need to use it.

Raymond,

Thanks. Someone else said it just helped to see what your class 
variables where (but I can see this easily enough).

I don't NEED to use var even in classes. I'm writing a class right 
now without it. But perhaps there is a SHOULD that I am not aware 
of (just helping me see .. well I don't need that).

Peter
http://www.readbrazil.com/
Answering Your Questions About Brazil
--- End Message ---
--- Begin Message ---
I want to grab info from a Web page where I am a logged in user.
How do I pass cookie info along with the grabber script? I looked
at Snoopy but the code is too complex for me to learn how to 
use it. 
http://turma.sourceforge.net/web/urlator/snoopy.html
Is there any example code out there on how to use Snoopy?
Thanks for any help.
Jeff Oien
--- End Message ---
--- Begin Message ---
A bit late in replying - but what the hay (or is that "hey"??) oh well...

>From my understanding of virtual functions (and it's been at least 3 to 4
years since I've done C++) is that a "virtual function" has basic
functionality and a "pure virtual function" has no, and can't have, and
code.

Please correct me if I'm wrong

Martin

-----Original Message-----
From: Rick Emery [mailto:[EMAIL PROTECTED]]
Sent: Saturday, February 16, 2002 3:31 AM
To: [EMAIL PROTECTED]
Subject: RE: [PHP] Polymorphism question


I've also done C and C++ since the 80's.

My experience with virtual, is that there is no base implementation for a
function.  Rather, the function is expected to be defined in the derived
class.

The inheritance you describe would have a base implementation (no virtual
declaration), which could be over-ridden in the derived class.

Yes, PHP does have the latter capability.

-----Original Message-----
From: Richard Fox [mailto:[EMAIL PROTECTED]]
Sent: Friday, February 15, 2002 9:01 AM
To: [EMAIL PROTECTED]
Subject: [PHP] Polymorphism question




I am new to PHP but 10 years in C++

One of the cool/powerful things you can do in C++ is the following:

class DrawPlainDialog {
public:
...
   virtual Draw(); // implementation draws a vanilla dialog box
   };

class DrawStyleDialog : public DrawPlainDialog {
public:
...
   virtual Draw(); // implementation draws better dialog
   };

Somewhere in my code I have a function like:

void ShowGUI( DrawPlainDialog& dd ) {
   dd.Draw();
   }

ShowGUI can be called with any object that is derived from DrawPlainDialog,
obviously. Only code that calls ShowGUI must be changed when a new
implementation of DrawPlainDialog is used. This feature of C++ to have a
base class pointer (or reference) be able to access derived class
functionality is not something I've seen in any PHP documentation. Does it
exist, and if not is there a workaround for this highly desirable feature?

TIA

Rich

PS Can anyone point me to the most comprehensive OOP documentation for PHP?

----------




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

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
Isn't this something to do with shared memory? I haven't played with shared
memory before, but this sounds like it might work.

Martin

-----Original Message-----
From: Philip Hallstrom [mailto:[EMAIL PROTECTED]]
Sent: Saturday, February 16, 2002 8:37 AM
To: Peter J. Schoenster
Cc: [EMAIL PROTECTED]
Subject: [PHP] Re: The ASP "application" object in PHP?


Not that I'm an ASP expert, but I asked someone about this once and was
told that the application object is really just a session for that section
of the website.

In other words you configure IIS so that say "/foobar" is an application.
Then in /foobar/global.asa you do some stuff that sets up this application
object.  Now anyone who accesses /foobar has access to that object.  So
using this you could keep track of how many people are on the site ,etc...

While it's magic in ASP land, it is easily done with a bit of work in
PHP..

On Fri, 15 Feb 2002, Peter J. Schoenster wrote:

> On 15 Feb 2002, at 14:43, Bendik Simonsen wrote:
>
>
> > I have however, noticed one feature that ASP has that I have not found
> > an equal for in PHP: the "application" object.
> >
> > For those of you not familiar with ASP, the lowdown is this: The
> > application object acts like a global session. You assign it variables
> > and values like you would a session, but those variables are available
> > to all instances and sessions. It is for example very useful to track
> > different users at the same time, or to send messages from one session
> > to another, or the likes.
> >
> > Anything like this in PHP, or will I have to find a workaround for it,
> > or *ick* do that little sniplet in ASP?
>
> Well how does it work? Is it advertised as M$ magic in the class?
> Is http not stateless?
>
> I don't follow your description and I don't believe in magic.
>
> Is it using cookies? If not what? It must be using something?
>
> I bet it's using cookies. Sounds a lot like what you normally do with
> sessions. I don't follow the "send message from one session to
> another" ... is this not just normal course for sessions?  I'd like
> more explanation before I believe that this is any more than just a
> module.
>
> Peter
> http://www.readbrazil.com/
> Answering Your Questions About Brazil
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
hi
i write in php about 1.5 years. from the beginning i use macromedia homesite
and i`m quite content of it. but...debugger, environment not optimized for
php developers etc. so i wanted to try zend studio, i downloaded it,
installed (w2k, i already had an apache, so i deleted what came with
installer). then: apache unstability, server downs, generaly - not usable.
so i uninstalled everything and came back to homesite.

i`ve read this (http://www.byte.com/documents/s=6975/byt1013213009328/)
article and now i look different on all of this. so - what`s your opinion -
is it good or bad tool. should i try again or wait for next version?

rashid


--- End Message ---
--- Begin Message ---
On  at , Unknown wrote:

> i write in php about 1.5 years. from the beginning i use macromedia
> homesite and i`m quite content of it. but...debugger, environment not

> optimized for php developers etc. so i wanted to try zend studio, i

> i`ve read this
> (http://www.byte.com/documents/s=6975/byt1013213009328/) article and
> now i look different on all of this. so - what`s your opinion - is it
> good or bad tool. should i try again or wait for next version?

Well I was hoping that article was interesting. It wasn't. I should 
have known when I saw the use of homesite as an alternative. 

The article had this one interesting line:

> Like many open-source languages, the biggest problem with PHP up until
> recently has been a lack of tools.

I guess knowledge and imagination doesn't count as tools. 

I could be wrong. I've been developing websites for the last 7 years. 
I still use TextPad (coupled with Perl, and UNIX/LINUX) yet I 
develop on a windoze platform with cygwin installed.

I'd suggest using Perl to improve your productivity which I assume 
is the real question at hand. Will Zend make your more productive 
than homesite?

Now I may be completely wrong. It's just that I've worked with 
people who use these GUI centric tools and they spend half their 
time in the air, waiting for their hand to move to and from mouse to 
keyboard.

Learn Perl, not to write cgi (god forbid, even I prefer PHP for this) or 
necessarily for mod_perl (very good) but just to generate code for 
yourself. Perl is an excellent tool but you can't get it with a GUI. 
You use text editors for which there is keyboard command for 99% 
of the actions you do.  If you already KNOW PHP then Perl will be 
simple.

Peter

http://www.readbrazil.com/
Answering Your Questions About Brazil
--- End Message ---
--- Begin Message ---
> Well I was hoping that article was interesting. It wasn't. I should
> have known when I saw the use of homesite as an alternative.

sure, it was just simple look at zend studio, but it made me wonder why the
tool didn`t work on my system :) [yes - i think i know what was wrong, no
need to look for bugs in zs2.0 :)]

> The article had this one interesting line:
>
> > Like many open-source languages, the biggest problem with PHP up until
> > recently has been a lack of tools.
>
> I guess knowledge and imagination doesn't count as tools.

debugger integrated with IDE does...

> I could be wrong. I've been developing websites for the last 7 years.
> I still use TextPad (coupled with Perl, and UNIX/LINUX) yet I
> develop on a windoze platform with cygwin installed.

what i need from my editor is:
- debugger
- color coding
- syntax check, just to spare time waiting for page showing that i forgot
')' in code

> I'd suggest using Perl to improve your productivity which I assume
> is the real question at hand.

hmmm....let`s say i prefer php.

> Will Zend make your more productive
> than homesite?

maybe...that`s what i want to know.

> Now I may be completely wrong. It's just that I've worked with
> people who use these GUI centric tools and they spend half their
> time in the air, waiting for their hand to move to and from mouse to
> keyboard.

i don`t want to have delphi-like ide, i want just a nice debugger with basic
options.

> Learn Perl, not to write cgi (god forbid, even I prefer PHP for this) or
> necessarily for mod_perl (very good) but just to generate code for
> yourself. Perl is an excellent tool but you can't get it with a GUI.
> You use text editors for which there is keyboard command for 99%
> of the actions you do.  If you already KNOW PHP then Perl will be
> simple.

i wrote few scripts in perl, i know it exists, i know i can use it if i
must, but, for now, i use php.

rash


--- End Message ---
--- Begin Message ---
I hope we aren't going to get another chest-pounding "real coders" type of
argument going here. Homesite *IS* a text editor. It provides an amazing
number of shortcuts to tasks, including mouse-based tasks, many of which I
guarantee you I can get done faster with a mouse than anyone can typing. It
also offers a lot of pseudo-time-saving features as well, for which one
would be better of learning to do it manually. But it isn't a GUI in any
real sense as, say, Dreamweaver is. TextPad is at least as much of a GUI as
Homesite in that respect.

I use both of these great tools a lot... none of them are the stigmata of
the under-developed programmer. People should use what they want, but don't
dump on everyone who realizes that clicking a button or using a keyboard
shortcut in something like Homesite or Textpad to create common HTML
structures or PHP control structures is always going to be faster than
typing them out by hand, no matter how craven a Notepad warrior one might
be.

Zend looks pretty good in terms of providing what I like in a development
environment, particularly real debugging... unfortunately it was definitely
not particularly stable when I last tried it in late December.

Integrated debugging, syntax coloring, function reference, keyboard
shortcuts-- these are all useful tools. TextPad has good PHP dictionaries,
Homesite handles PHP well. Homesite is STILL the only editor I have found
that enables an easy "preview through the server" mapping so that I can,
with one touch toggle between my editing and the live code through my local
development server, something that saves a lot of time vs jockeying between
windows with other tools.

Not all mouse use is just waving one's hands through the air, none of the
programs mentioned are particularly mouse-centric.

c
--
Chris Lott
http://www.chrislott.org/

--- End Message ---
--- Begin Message ---
On 17 Feb 2002, at 16:12, Chris Lott wrote:

> I hope we aren't going to get another chest-pounding "real coders"
> type of argument going here. Homesite *IS* a text editor. It provides

Yeah, my bad. 

> an amazing number of shortcuts to tasks, including mouse-based tasks,
> many of which I guarantee you I can get done faster with a mouse than
> anyone can typing. It also offers a lot of pseudo-time-saving features

Well, as you said, no point in arguing.  Just that I think if someone 
really wants to develop they should learn some better tools than a 
GUI but it's a question of balance. 

Peter


Despite considerable evidence that it doesn't work, many 
projects seem to rely on telepathy as the mechanism for 
communicating requirements from users to developers. 
--Karl E. Wiegers
--- End Message ---
--- Begin Message ---
I am working on some error trapping for several forms on my site. After
visiting a bunch of websites, I've noticed 2 common methods of displaying
error messages.

1. display an error box on a new page and force the user to hit the <back>
button

2. display the form again with appropriate error text and pre-filled fields.

I have part of the error on the new page working but I'm running into the
infamous no contents in the form after going <back>.

There are some useability issues with forcing the user to hit the back
button -- some just don't want to bother.

Is there a way to display the form w/original contents and error messages
'without' having to code the entire form twice? I have about 5 forms with 50
fields or so each.

What would be the best way to go about redrawing the form with the errors
shown beside each field?

Any suggestions are greatly appreciated.

__________________
Jason Dulberg
Extreme MTB
http://extreme.nas.net

--- End Message ---
--- Begin Message ---
submit back to the same page - or include that page

Martin

-----Original Message-----
From: Jason Dulberg [mailto:[EMAIL PROTECTED]]
Sent: Monday, February 18, 2002 9:23 AM
To: [EMAIL PROTECTED]
Subject: [PHP] form submission error trapping


I am working on some error trapping for several forms on my site. After
visiting a bunch of websites, I've noticed 2 common methods of displaying
error messages.

1. display an error box on a new page and force the user to hit the <back>
button

2. display the form again with appropriate error text and pre-filled fields.

I have part of the error on the new page working but I'm running into the
infamous no contents in the form after going <back>.

There are some useability issues with forcing the user to hit the back
button -- some just don't want to bother.

Is there a way to display the form w/original contents and error messages
'without' having to code the entire form twice? I have about 5 forms with 50
fields or so each.

What would be the best way to go about redrawing the form with the errors
shown beside each field?

Any suggestions are greatly appreciated.

__________________
Jason Dulberg
Extreme MTB
http://extreme.nas.net


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

I just finished one of my form pages, and I'm really happy with how it 
turned out.

I created one php page that both displays the form and validates the 
input. When the user hits the submit button, it submits the data to 
itself. If anything is missing from the page, the form is reshown with 
missing fields highlighted and the other fields filled in. If on the 
other hand the info passes the validation test, the information is shown 
to screen a new button (hidden form) allows the user to continue.

If you want, I can send you a link to my test site so you can check it 
out.

Steven J. Walker
Walker Effects
www.walkereffects.com
[EMAIL PROTECTED]

On Sunday, February 17, 2002, at 02:22  PM, Jason Dulberg wrote:

> I am working on some error trapping for several forms on my site. After
> visiting a bunch of websites, I've noticed 2 common methods of 
> displaying
> error messages.
>
> 1. display an error box on a new page and force the user to hit the 
> <back>
> button
>
> 2. display the form again with appropriate error text and pre-filled 
> fields.
>
> I have part of the error on the new page working but I'm running into 
> the
> infamous no contents in the form after going <back>.
>
> There are some useability issues with forcing the user to hit the back
> button -- some just don't want to bother.
>
> Is there a way to display the form w/original contents and error 
> messages
> 'without' having to code the entire form twice? I have about 5 forms 
> with 50
> fields or so each.
>
> What would be the best way to go about redrawing the form with the 
> errors
> shown beside each field?
>
> Any suggestions are greatly appreciated.
>
> __________________
> Jason Dulberg
> Extreme MTB
> http://extreme.nas.net
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--- End Message ---
--- Begin Message ---
Ya, it would be cool if you could.... how do you submit the form to itself?

Right now, I have something like 

if (!$submit) {
display form
}
else {
process
        if (trim($email)=="") {
                echo "error, hit back button to fix";
        }
}

Thanks

Jason


> -----Original Message-----
> From: Steven Walker [mailto:[EMAIL PROTECTED]]
> Sent: February 17, 2002 6:18 PM
> To: [EMAIL PROTECTED]
> Cc: [EMAIL PROTECTED]
> Subject: Re: [PHP] form submission error trapping
> 
> 
> Jason,
> 
> I just finished one of my form pages, and I'm really happy with how it 
> turned out.
> 
> I created one php page that both displays the form and validates the 
> input. When the user hits the submit button, it submits the data to 
> itself. If anything is missing from the page, the form is reshown with 
> missing fields highlighted and the other fields filled in. If on the 
> other hand the info passes the validation test, the information is shown 
> to screen a new button (hidden form) allows the user to continue.
> 
> If you want, I can send you a link to my test site so you can check it 
> out.
> 
> Steven J. Walker
> Walker Effects
> www.walkereffects.com
> [EMAIL PROTECTED]
> 
> On Sunday, February 17, 2002, at 02:22  PM, Jason Dulberg wrote:
> 
> > I am working on some error trapping for several forms on my site. After
> > visiting a bunch of websites, I've noticed 2 common methods of 
> > displaying
> > error messages.
> >
> > 1. display an error box on a new page and force the user to hit the 
> > <back>
> > button
> >
> > 2. display the form again with appropriate error text and pre-filled 
> > fields.
> >
> > I have part of the error on the new page working but I'm running into 
> > the
> > infamous no contents in the form after going <back>.
> >
> > There are some useability issues with forcing the user to hit the back
> > button -- some just don't want to bother.
> >
> > Is there a way to display the form w/original contents and error 
> > messages
> > 'without' having to code the entire form twice? I have about 5 forms 
> > with 50
> > fields or so each.
> >
> > What would be the best way to go about redrawing the form with the 
> > errors
> > shown beside each field?
> >
> > Any suggestions are greatly appreciated.
> >
> > __________________
> > Jason Dulberg
> > Extreme MTB
> > http://extreme.nas.net
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
> 
--- End Message ---
--- Begin Message ---
something like:

<?
  // filename: here.html

  if ($submit)
  {
    $error = false;
    if (trim($email) == "")
    {
      $error = true;
    }
    // process more...
    if (!$error)
    {
      // do stuff here, maybe a header("location:....");
      exit;
    }
  }
?>
<html>
  <form action="here.html" method="post">
    <input type="text" name="email" value="<?= $email; ?>">
    <input type="submit" name="submit" value="Go For It!!!">
  </form>
</html>

not tested but should work - just expand on it

Martin


-----Original Message-----
From: Jason Dulberg [mailto:[EMAIL PROTECTED]]
Sent: Monday, February 18, 2002 10:22 AM
To: Steven Walker
Cc: [EMAIL PROTECTED]
Subject: RE: [PHP] form submission error trapping


Ya, it would be cool if you could.... how do you submit the form to itself?

Right now, I have something like 

if (!$submit) {
display form
}
else {
process
        if (trim($email)=="") {
                echo "error, hit back button to fix";
        }
}

Thanks

Jason


> -----Original Message-----
> From: Steven Walker [mailto:[EMAIL PROTECTED]]
> Sent: February 17, 2002 6:18 PM
> To: [EMAIL PROTECTED]
> Cc: [EMAIL PROTECTED]
> Subject: Re: [PHP] form submission error trapping
> 
> 
> Jason,
> 
> I just finished one of my form pages, and I'm really happy with how it 
> turned out.
> 
> I created one php page that both displays the form and validates the 
> input. When the user hits the submit button, it submits the data to 
> itself. If anything is missing from the page, the form is reshown with 
> missing fields highlighted and the other fields filled in. If on the 
> other hand the info passes the validation test, the information is shown 
> to screen a new button (hidden form) allows the user to continue.
> 
> If you want, I can send you a link to my test site so you can check it 
> out.
> 
> Steven J. Walker
> Walker Effects
> www.walkereffects.com
> [EMAIL PROTECTED]
> 
> On Sunday, February 17, 2002, at 02:22  PM, Jason Dulberg wrote:
> 
> > I am working on some error trapping for several forms on my site. After
> > visiting a bunch of websites, I've noticed 2 common methods of 
> > displaying
> > error messages.
> >
> > 1. display an error box on a new page and force the user to hit the 
> > <back>
> > button
> >
> > 2. display the form again with appropriate error text and pre-filled 
> > fields.
> >
> > I have part of the error on the new page working but I'm running into 
> > the
> > infamous no contents in the form after going <back>.
> >
> > There are some useability issues with forcing the user to hit the back
> > button -- some just don't want to bother.
> >
> > Is there a way to display the form w/original contents and error 
> > messages
> > 'without' having to code the entire form twice? I have about 5 forms 
> > with 50
> > fields or so each.
> >
> > What would be the best way to go about redrawing the form with the 
> > errors
> > shown beside each field?
> >
> > Any suggestions are greatly appreciated.
> >
> > __________________
> > Jason Dulberg
> > Extreme MTB
> > http://extreme.nas.net
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
> 

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

> > -----Original Message-----
> > From: Steven Walker [mailto:[EMAIL PROTECTED]]
> > 
> > I created one php page that both displays the form and validates the 
> > input. When the user hits the submit button, it submits the data to 
> > itself. If anything is missing from the page, the form is reshown with 
> > missing fields highlighted and the other fields filled in. If on the 
> > other hand the info passes the validation test, the information is shown 
> > to screen a new button (hidden form) allows the user to continue.

Only catch is, you have to build all that logic to populate your fields.  Piece of 
cake when you have a simple form, not so easy when you have a dynamically-generated 
form (with a variable number of inputs) including multi-select buttons and the like.

I guess the real challenge is converting a pre-existing page like the one I've 
described into one that can re-populate itself on an error condition.  Building it 
that way from scratch is merely a programming task.

- Ken
[EMAIL PROTECTED]

--- End Message ---
--- Begin Message ---
RE: [PHP] form submission error trappingThanks for the code.... Is there a
way to keep track of what fields had the errors as its possible for people
to have like 5 errors?

Thanks again.

Jason
  -----Original Message-----
  From: Martin Towell [mailto:[EMAIL PROTECTED]]
  Sent: February 17, 2002 6:41 PM
  To: '[EMAIL PROTECTED]'; Steven Walker
  Cc: [EMAIL PROTECTED]
  Subject: RE: [PHP] form submission error trapping


  something like:

  <?
    // filename: here.html

    if ($submit)
    {
      $error = false;
      if (trim($email) == "")
      {
        $error = true;
      }
      // process more...
      if (!$error)
      {
        // do stuff here, maybe a header("location:....");
        exit;
      }
    }
  ?>
  <html>
    <form action="here.html" method="post">
      <input type="text" name="email" value="<?= $email; ?>">
      <input type="submit" name="submit" value="Go For It!!!">
    </form>
  </html>

  not tested but should work - just expand on it

  Martin



  -----Original Message-----
  From: Jason Dulberg [mailto:[EMAIL PROTECTED]]
  Sent: Monday, February 18, 2002 10:22 AM
  To: Steven Walker
  Cc: [EMAIL PROTECTED]
  Subject: RE: [PHP] form submission error trapping



  Ya, it would be cool if you could.... how do you submit the form to
itself?

  Right now, I have something like

  if (!$submit) {
  display form
  }
  else {
  process
          if (trim($email)=="") {
                  echo "error, hit back button to fix";
          }
  }

  Thanks

  Jason



  > -----Original Message-----
  > From: Steven Walker [mailto:[EMAIL PROTECTED]]
  > Sent: February 17, 2002 6:18 PM
  > To: [EMAIL PROTECTED]
  > Cc: [EMAIL PROTECTED]
  > Subject: Re: [PHP] form submission error trapping
  >
  >
  > Jason,
  >
  > I just finished one of my form pages, and I'm really happy with how it
  > turned out.
  >
  > I created one php page that both displays the form and validates the
  > input. When the user hits the submit button, it submits the data to
  > itself. If anything is missing from the page, the form is reshown with
  > missing fields highlighted and the other fields filled in. If on the
  > other hand the info passes the validation test, the information is shown
  > to screen a new button (hidden form) allows the user to continue.
  >
  > If you want, I can send you a link to my test site so you can check it
  > out.
  >
  > Steven J. Walker
  > Walker Effects
  > www.walkereffects.com
  > [EMAIL PROTECTED]
  >
  > On Sunday, February 17, 2002, at 02:22  PM, Jason Dulberg wrote:
  >
  > > I am working on some error trapping for several forms on my site.
After
  > > visiting a bunch of websites, I've noticed 2 common methods of
  > > displaying
  > > error messages.
  > >
  > > 1. display an error box on a new page and force the user to hit the
  > > <back>
  > > button
  > >
  > > 2. display the form again with appropriate error text and pre-filled
  > > fields.
  > >
  > > I have part of the error on the new page working but I'm running into
  > > the
  > > infamous no contents in the form after going <back>.
  > >
  > > There are some useability issues with forcing the user to hit the back
  > > button -- some just don't want to bother.
  > >
  > > Is there a way to display the form w/original contents and error
  > > messages
  > > 'without' having to code the entire form twice? I have about 5 forms
  > > with 50
  > > fields or so each.
  > >
  > > What would be the best way to go about redrawing the form with the
  > > errors
  > > shown beside each field?
  > >
  > > Any suggestions are greatly appreciated.
  > >
  > > __________________
  > > Jason Dulberg
  > > Extreme MTB
  > > http://extreme.nas.net
  > >
  > >
  > > --
  > > PHP General Mailing List (http://www.php.net/)
  > > To unsubscribe, visit: http://www.php.net/unsub.php
  > >
  > >
  >

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

--- End Message ---
--- Begin Message ---
> I guess the real challenge is converting a pre-existing page like the 
> one I've described into one that can re-populate itself on an error 
> condition.  Building it that way from scratch is merely a programming 
> task.

That's true, however there are a few ways to cheat :). For example, in 
my form I have a State and Country popup menu. Rather than trying to 
write code that selects the proper one to match the post data, I simply 
create a new entry at the top:

       <select name="state">
         <?
                 if(isset($state)) {
                        $statename = GetStateName($state);
                        echo "<option selected value='$state'>$statename";
                 }
         ?>
         <option value="">Select a state
         <option value=AL>Alabama

This works because I've already verified the data. If the data doesn't 
pass verification, it would be reset and would fail the isset($state) 
test.

Otherwise, most form elements are pretty easy to assign values to.

Steven J. Walker
Walker Effects
www.walkereffects.com
[EMAIL PROTECTED]

On Sunday, February 17, 2002, at 03:42  PM, Ken wrote:

>
>>> -----Original Message-----
>>> From: Steven Walker [mailto:[EMAIL PROTECTED]]
>>>
>>> I created one php page that both displays the form and validates the
>>> input. When the user hits the submit button, it submits the data to
>>> itself. If anything is missing from the page, the form is reshown with
>>> missing fields highlighted and the other fields filled in. If on the
>>> other hand the info passes the validation test, the information is 
>>> shown
>>> to screen a new button (hidden form) allows the user to continue.
>
> Only catch is, you have to build all that logic to populate your 
> fields.  Piece of cake when you have a simple form, not so easy when 
> you have a dynamically-generated form (with a variable number of 
> inputs) including multi-select buttons and the like.
>
> I guess the real challenge is converting a pre-existing page like the 
> one I've described into one that can re-populate itself on an error 
> condition.  Building it that way from scratch is merely a programming 
> task.
>
> - Ken
> [EMAIL PROTECTED]
>
>
--- End Message ---
--- Begin Message ---
sure - $error could be an array, so the code I supplied could be changed to:
if you're email client supports rich text, then the changed lines are in
green
<? 
  // filename: here.html 

  if ($submit) 
  { 
    $error = array(); 
    if (trim($email) == "") 
    { 
      $error["email"] = true; 
    } 
    // process more... 
    if (count($error) == 0) 
    { 
      // do stuff here, maybe a header("location:...."); 
      exit; 
    } 
  } 
?> 
<html> 
  <form action="here.html" method="post"> 
    <? if ($error["email"])  echo "Error: please fill in your email
address"; ?>
    <input type="text" name="email" value="<?= $email; ?>"> 
    <input type="submit" name="submit" value="Go For It!!!"> 
  </form> 
</html> 

 
-----Original Message-----
From: Jason Dulberg [mailto:[EMAIL PROTECTED]]
Sent: Monday, February 18, 2002 10:40 AM
To: Martin Towell
Cc: [EMAIL PROTECTED]
Subject: RE: [PHP] form submission error trapping


Thanks for the code.... Is there a way to keep track of what fields had the
errors as its possible for people to have like 5 errors?
 
Thanks again.
 
Jason

-----Original Message-----
From: Martin Towell [mailto:[EMAIL PROTECTED]]
Sent: February 17, 2002 6:41 PM
To: '[EMAIL PROTECTED]'; Steven Walker
Cc: [EMAIL PROTECTED]
Subject: RE: [PHP] form submission error trapping



something like: 

<? 
  // filename: here.html 

  if ($submit) 
  { 
    $error = false; 
    if (trim($email) == "") 
    { 
      $error = true; 
    } 
    // process more... 
    if (!$error) 
    { 
      // do stuff here, maybe a header("location:...."); 
      exit; 
    } 
  } 
?> 
<html> 
  <form action="here.html" method="post"> 
    <input type="text" name="email" value="<?= $email; ?>"> 
    <input type="submit" name="submit" value="Go For It!!!"> 
  </form> 
</html> 

not tested but should work - just expand on it 

Martin 


-----Original Message----- 
From: Jason Dulberg [  <mailto:[EMAIL PROTECTED]>
mailto:[EMAIL PROTECTED]] 
Sent: Monday, February 18, 2002 10:22 AM 
To: Steven Walker 
Cc: [EMAIL PROTECTED] 
Subject: RE: [PHP] form submission error trapping 


Ya, it would be cool if you could.... how do you submit the form to itself? 

Right now, I have something like 

if (!$submit) { 
display form 
} 
else { 
process 
        if (trim($email)=="") { 
                echo "error, hit back button to fix"; 
        } 
} 

Thanks 

Jason 


> -----Original Message----- 
> From: Steven Walker [  <mailto:[EMAIL PROTECTED]>
mailto:[EMAIL PROTECTED]] 
> Sent: February 17, 2002 6:18 PM 
> To: [EMAIL PROTECTED] 
> Cc: [EMAIL PROTECTED] 
> Subject: Re: [PHP] form submission error trapping 
> 
> 
> Jason, 
> 
> I just finished one of my form pages, and I'm really happy with how it 
> turned out. 
> 
> I created one php page that both displays the form and validates the 
> input. When the user hits the submit button, it submits the data to 
> itself. If anything is missing from the page, the form is reshown with 
> missing fields highlighted and the other fields filled in. If on the 
> other hand the info passes the validation test, the information is shown 
> to screen a new button (hidden form) allows the user to continue. 
> 
> If you want, I can send you a link to my test site so you can check it 
> out. 
> 
> Steven J. Walker 
> Walker Effects 
> www.walkereffects.com 
> [EMAIL PROTECTED] 
> 
> On Sunday, February 17, 2002, at 02:22  PM, Jason Dulberg wrote: 
> 
> > I am working on some error trapping for several forms on my site. After 
> > visiting a bunch of websites, I've noticed 2 common methods of 
> > displaying 
> > error messages. 
> > 
> > 1. display an error box on a new page and force the user to hit the 
> > <back> 
> > button 
> > 
> > 2. display the form again with appropriate error text and pre-filled 
> > fields. 
> > 
> > I have part of the error on the new page working but I'm running into 
> > the 
> > infamous no contents in the form after going <back>. 
> > 
> > There are some useability issues with forcing the user to hit the back 
> > button -- some just don't want to bother. 
> > 
> > Is there a way to display the form w/original contents and error 
> > messages 
> > 'without' having to code the entire form twice? I have about 5 forms 
> > with 50 
> > fields or so each. 
> > 
> > What would be the best way to go about redrawing the form with the 
> > errors 
> > shown beside each field? 
> > 
> > Any suggestions are greatly appreciated. 
> > 
> > __________________ 
> > Jason Dulberg 
> > Extreme MTB 
> >  <http://extreme.nas.net> http://extreme.nas.net 
> > 
> > 
> > -- 
> > PHP General Mailing List (  <http://www.php.net/> http://www.php.net/) 
> > To unsubscribe, visit:  <http://www.php.net/unsub.php>
http://www.php.net/unsub.php 
> > 
> > 
> 

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

--- End Message ---
--- Begin Message ---
Yeah, for buttons (radio/checkboxes) I had to put an if statement on 
each one:

       <td width="84%">
         <input type="radio" name="formatting" value="unformatted"
           <?
                if($format == "unformatted") echo "checked";
           ?>>
         unformatted
         <input type="radio" name="formatting" value="table"
           <?
                if($format == "table") echo "checked";
           ?>>

You're right... it's not as easy.

Steven J. Walker
Walker Effects
www.walkereffects.com
[EMAIL PROTECTED]

--- End Message ---
--- Begin Message ---
I have to run php script from Linux shell.

I have no trouble except with passing the parameters.
What is the right sintax to pass them to the script?

I would like to do something like this:
/usr/local/bin/php ./test.php param=value


Best Regards,
   Bostjan Marusic

--- End Message ---
--- Begin Message ---
$argv and $argc are prob. what you're after - dunno if there's any parameter
parsing functions - but it's a start

HTH
Martin

-----Original Message-----
From: Bostjan Marusic [mailto:[EMAIL PROTECTED]]
Sent: Monday, February 18, 2002 10:00 AM
To: [EMAIL PROTECTED]
Subject: [PHP] Running php from shell - passing parameters


I have to run php script from Linux shell.

I have no trouble except with passing the parameters.
What is the right sintax to pass them to the script?

I would like to do something like this:
/usr/local/bin/php ./test.php param=value


Best Regards,
   Bostjan Marusic


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

Hi, I have a form, that I need to control the parameters in the _blank target once it is submitted.

 

Everything works, fine except the client wants the result of the poll in a popup window, and I am not able to control the parameters on the new window.

 

Can any one help me with this? Thanks.

 

E

--- End Message ---

Reply via email to