php-general Digest 11 Sep 2010 16:56:50 -0000 Issue 6935
Topics (messages 307945 through 307955):
Re: Broken pipes, time outs, PHP, and mail
307945 by: Dave M G
Re: Standalone WebServer for PHP
307946 by: Per Jessen
Disabling an extension on a perdir basis.
307947 by: Richard Quadling
307948 by: a...@ashleysheridan.co.uk
307955 by: Jim Lucas
Elegance is the goal... Sticky form submit help
307949 by: Jason Pruim
307950 by: a...@ashleysheridan.co.uk
307951 by: tedd
307952 by: Tamara Temple
307953 by: Tamara Temple
How to handle a submitted form with no changes -- best practices sought
307954 by: Tamara Temple
Administrivia:
To subscribe to the digest, e-mail:
php-general-digest-subscr...@lists.php.net
To unsubscribe from the digest, e-mail:
php-general-digest-unsubscr...@lists.php.net
To post to the list, e-mail:
php-gene...@lists.php.net
----------------------------------------------------------------------
--- Begin Message ---
Peter, Bob,
Thank you for replying.
After a few days testing, I set up an error handler for when messages
don't get sent. I started to see an error saying "Language String failed
to load", which seems to be particular to the PHPmailer scripts I am using.
Long story short, after some searching on the web, it looks like the
sending of mails will die if one mail on the list is invalid.
I tried sending a message out to the list, got back a response saying
that the recipient did not exist. So I deleted that user, and then the
mail went through fine on the next attempt.
I'm a little fuzzy on what exactly is happening.
Does the PHP mail() command (and by extension, classes built upon it)
listen for responses from the server it is sending to?
--
Dave M G
--- End Message ---
--- Begin Message ---
Steve Staples wrote:
> Ok, here it goes...
>
> I am building an app, that requires a web interface. I am using PHP
> becuase I am familiar with it. Most of the app's i've been looking
> at, use Python, Cherry.py and stuff, but what I was wondering, is is
> there a way to create a php CLI app, that creates it's own "web
> server" even if apache is installed.
Yep, that's no big deal. A webserver is just some code that listens for
requests on port XX, processes the requests and sends back suitably
formatted responses.
--
Per Jessen, Zürich (12.2°C)
--- End Message ---
--- Begin Message ---
Hi.
Can't seem to see a way to do this.
Is there a way to do this?
--
Richard Quadling
Twitter : EE : Zend
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY
--- End Message ---
--- Begin Message ---
If you want to prevent certain extensions then just flirt then out from the
$_FILES array before you copy them out of the temp directory, as that is where
they should be uploaded ready for your script to process.
Thanks,
Ash
http://www.ashleysheridan.co.uk
----- Reply message -----
From: "Richard Quadling" <rquadl...@gmail.com>
Date: Sat, Sep 11, 2010 11:11
Subject: [PHP] Disabling an extension on a perdir basis.
To: "PHP General list" <php-gene...@lists.php.net>
Hi.
Can't seem to see a way to do this.
Is there a way to do this?
--
Richard Quadling
Twitter : EE : Zend
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
Richard Quadling wrote:
Hi.
Can't seem to see a way to do this.
Is there a way to do this?
Are you talking about a PHP extension or a file extension?
--- End Message ---
--- Begin Message ---
Hey everyone!
Hope you are having a great weekend, and I'm hoping someone might be
coherent enough to help me find a more elegant solution to a problem
that I have...
I have a form for submitting an event to a website, and if the form is
not submitted successfully (such as they didn't fill out a required
field) I want it to redisplay the form with inline errors as to what
happened and display the values they selected...
I have a working solution but was hoping for something a little more
elegant. And something that would work better for a month selector as
well... Here is the relevant code that I have that works:
<?PHP
if ($_POST['hidSubmit'] ==TRUE & $_POST['type'] == "meeting"):
echo <<<HTML
<select name="type" id="type">
<option value="0">-- select type --</option>
<option value="meeting" selected>Meeting</option>
<option value="event" >Event</option>
</select>
HTML;
elseif ($_POST['hidSubmit'] == TRUE & $_POST['type'] == "event"):
//if ($_POST['hidSubmit'] == TRUE & $_POST['type'] == "event") {
echo <<<HTML
<select name="type" id="type">
<option value="0">-- select type --</option>
<option value="meeting">Meeting</option>
<option value="event" selected>Event</option>
</select>
HTML;
else:
//if ($_POST['hidSubmit'] != TRUE):
echo <<<HTML
<select name="type" id="type">
<option value="0" selected>-- select type --</option>
<option value="meeting">Meeting</option>
<option value="event">Event</option>
</select>
HTML;
endif;
?>
which works BUT I don't want to have to have that for a month selector
or a day selector :)
Any ideas what I'm missing?
--- End Message ---
--- Begin Message ---
For a month selector, using a loop to output the months is good, as you can
then within the loop check for that value sent and set the selected html
attribute for that select element.
I should warn you that your code will throw a warning when no data has been
posted to it. Consider using isset() instead to check for posted values rather
than comparing a value (which might not exist) with true.
Thanks,
Ash
http://www.ashleysheridan.co.uk
----- Reply message -----
From: "Jason Pruim" <li...@pruimphotography.com>
Date: Sat, Sep 11, 2010 14:49
Subject: [PHP] Elegance is the goal... Sticky form submit help
To: "PHP-General list" <php-gene...@lists.php.net>
Hey everyone!
Hope you are having a great weekend, and I'm hoping someone might be
coherent enough to help me find a more elegant solution to a problem
that I have...
I have a form for submitting an event to a website, and if the form is
not submitted successfully (such as they didn't fill out a required
field) I want it to redisplay the form with inline errors as to what
happened and display the values they selected...
I have a working solution but was hoping for something a little more
elegant. And something that would work better for a month selector as
well... Here is the relevant code that I have that works:
<?PHP
if ($_POST['hidSubmit'] ==TRUE & $_POST['type'] == "meeting"):
echo <<<HTML
<select name="type" id="type">
<option value="0">-- select type --</option>
<option value="meeting" selected>Meeting</option>
<option value="event" >Event</option>
</select>
HTML;
elseif ($_POST['hidSubmit'] == TRUE & $_POST['type'] == "event"):
//if ($_POST['hidSubmit'] == TRUE & $_POST['type'] == "event") {
echo <<<HTML
<select name="type" id="type">
<option value="0">-- select type --</option>
<option value="meeting">Meeting</option>
<option value="event" selected>Event</option>
</select>
HTML;
else:
//if ($_POST['hidSubmit'] != TRUE):
echo <<<HTML
<select name="type" id="type">
<option value="0" selected>-- select type --</option>
<option value="meeting">Meeting</option>
<option value="event">Event</option>
</select>
HTML;
endif;
?>
which works BUT I don't want to have to have that for a month selector
or a day selector :)
Any ideas what I'm missing?
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
At 9:49 AM -0400 9/11/10, Jason Pruim wrote:
Hey everyone!
Hope you are having a great weekend, and I'm hoping someone might be
coherent enough to help me find a more elegant solution to a problem
that I have...
I have a form for submitting an event to a website, and if the form
is not submitted successfully (such as they didn't fill out a
required field) I want it to redisplay the form with inline errors
as to what happened and display the values they selected...
-snip-
Any ideas what I'm missing?
Jason:
I think what you are missing is that this data collection should be
split between client-side and server-side operations.
For client-side simply use javascript to monitor what they user
enters and then immediately respond to the requirements imposed upon
the user.
After the user fills out the information correctly and clicks submit,
then have your server-side scripts check the data again and respond
accordingly.
Here are a couple of examples:
http://webbytedd.com/c/form-calc/
http://webbytedd.com/c/form-submit/
Cheers,
tedd
--
-------
http://sperling.com/
--- End Message ---
--- Begin Message ---
Rather than repeating all that code, I suggest the following:
<select name="type" id="type>
<option value="0">-- select type --</option>
<option value="meeting" <?php echo (isset($_POST['hidSubmit'] &&
$_POST['hidSubmit'] == TRUE && $_POST['type'] == "meeting") ?
"selected" : '' ?>
<option value="event" <?php echo (isset($_POST['hidSubmit'] &&
$_POST['hidSubmit'] == TRUE && $_POST['type'] == "event") ?
"selected" : '' ?>
</select>
For a month selector, try:
<?php
// assume current month number is in $curr_month
$months = array(1 => "January", "February", "March", "April",
"May", "June", "July", "August", "September", "October", "November",
"December"); // will create an array of month names, with a starting
base of 1 (instead of zero)
echo "<select name=\"month\" id=\"month\">\n";
foreach ($months as $m => $mname) {
echo "<option value=\"$m\"";
if ($curr_month == $m) echo " selected ";
echo ">$mname</option>\n";
}
echo "</select>\n";
?>
There are other possiblities as well. One time, I didn't want to
actually store the month names, perhaps allowing them to be localized.
Instead I used strftime, which will return appropriate names based on
locale:
<?php
// assume current month number is in $curr_month
echo "<select name=\"month\" id=\"month\">\n";
for ($m = 1; $m <= 12; $m++) {
echo "<option value=\"$m\"";
if ($curr_month == $m) echo " selected ";
echo ">";
$mname = strftime("%B", 0,0,0,2010, $m, 1); // time, year and day
don't matter, all we're after is the appropriate month name set in the
locale
echo $mname;
echo "</option>\n";
}
echo "</select>\n";
?>
On Sep 11, 2010, at 8:49 AM, Jason Pruim wrote:
Hey everyone!
Hope you are having a great weekend, and I'm hoping someone might be
coherent enough to help me find a more elegant solution to a problem
that I have...
I have a form for submitting an event to a website, and if the form
is not submitted successfully (such as they didn't fill out a
required field) I want it to redisplay the form with inline errors
as to what happened and display the values they selected...
I have a working solution but was hoping for something a little more
elegant. And something that would work better for a month selector
as well... Here is the relevant code that I have that works:
<?PHP
if ($_POST['hidSubmit'] ==TRUE & $_POST['type'] == "meeting"):
echo <<<HTML
<select name="type" id="type">
<option value="0">-- select type --</option>
<option value="meeting" selected>Meeting</option>
<option value="event" >Event</option>
</select>
HTML;
elseif ($_POST['hidSubmit'] == TRUE & $_POST['type'] == "event"):
//if ($_POST['hidSubmit'] == TRUE & $_POST['type'] == "event") {
echo <<<HTML
<select name="type" id="type">
<option value="0">-- select type --</option>
<option value="meeting">Meeting</option>
<option value="event" selected>Event</option>
</select>
HTML;
else:
//if ($_POST['hidSubmit'] != TRUE):
echo <<<HTML
<select name="type" id="type">
<option value="0" selected>-- select type --</option>
<option value="meeting">Meeting</option>
<option value="event">Event</option>
</select>
HTML;
endif;
?>
which works BUT I don't want to have to have that for a month
selector or a day selector :)
Any ideas what I'm missing?
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
The debate on client-side vs. server-side form validation is ongoing.
Client-side is more responsive, and attempts to keep bad data from
ever reaching your application, but relies on javascript being
enabled. Since this is something easily turned off by users, one can't
always rely on it to do form validation. So server-side validation is
needed as well to allow your full application to gracefully degrade in
the absence of working javascript on the client's side. Coding
defensively helps!
On Sep 11, 2010, at 10:55 AM, tedd wrote:
At 9:49 AM -0400 9/11/10, Jason Pruim wrote:
Hey everyone!
Hope you are having a great weekend, and I'm hoping someone might
be coherent enough to help me find a more elegant solution to a
problem that I have...
I have a form for submitting an event to a website, and if the form
is not submitted successfully (such as they didn't fill out a
required field) I want it to redisplay the form with inline errors
as to what happened and display the values they selected...
-snip-
Any ideas what I'm missing?
Jason:
I think what you are missing is that this data collection should be
split between client-side and server-side operations.
For client-side simply use javascript to monitor what they user
enters and then immediately respond to the requirements imposed upon
the user.
After the user fills out the information correctly and clicks
submit, then have your server-side scripts check the data again and
respond accordingly.
Here are a couple of examples:
http://webbytedd.com/c/form-calc/
http://webbytedd.com/c/form-submit/
Cheers,
tedd
--
-------
http://sperling.com/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
I have a general question and am looking for best practices.
Suppose I present a user with a form for editing an entry in a table,
i.e., the form has filled in values from the existing table entry.
Now, suppose they click on 'submit' without making any changes in the
form. (Perhaps, say, rather than clicking 'Cancel' or 'Return to Main'
or some other option which would get them out of that screen without
submitting the form).
Is it worth the overhead of passing along the previous values in the
table in hidden fields so that fields can be checked to see if they've
been updated or not after the submit? Or is it worth reloading the old
values from the table to check against the newly submitted form? Or is
all that overhead not worth the time because an update that overwrites
existing values with the same values is not that onerous?
(Is that question clear enough?)
--- End Message ---