Re: Frst foray into PHP _SELF [message #169977 is a reply to message #169976] |
Sat, 02 October 2010 17:27 |
Jerry Stuckle
Messages: 2598 Registered: September 2010
Karma:
|
Senior Member |
|
|
On 10/2/2010 1:07 PM, Twayne wrote:
> Hi All,
> Long time no see. Been ill, but back now!
>
> Windows XP SP3+, Local XAMPP with Apache, PHP 5.2.5 .
>
> My query is to find out if the following is OK to do, or could cause
> problems. I created it accidentally and when I looked it over, it looks
> strange (to me) but it worked at first and now won't work. Specifically. The
> original is based on a tutorial but I forget which one now:
> =============
> ...
> if (!isset($_POST['submit'])) { // if page wasn't submitted to itself echo
> the form.
> ?>
>
> <html>
> <head>
> <title>Personal INFO</title>
> </head>
> <body>
>
> <form method="post" action="<?php echo $PHP_SELF;?>">
> ...
> lots of HTML code
> ...
> </form>
> <? php
>
> } else {<---------- My concern is this line considering all the HTML code
> between the earlier if statement and here. ----->
> # Line 55 indication steady when moving any below.;
> echo "Hello, ".$Fname." ".$Lname.".<br />";
> ...
> ?>
> ==================
> In other words, I use close PHP tag, do a lot of HTML work, then jump back
> into PHP and complete the If statement (specifically the ELSE portion). Is
> there anything wrong with doing that?
Sure, nothing wrong with it at all. But what does this question have to
do with PHP_SELF?
> It's my first try at PHP's _SELF for forms.
> It worked a couple times and then just stopped. IE8 and FF's latest. All
> testing was done locally as I've done for years now before uploading to the
> servers. Oh, and yes, I've tried doing a Restart of Windows.
> Why am I doing this? Seems like it would be faster and more efficient.
> Yes?
>
Sure, it's not at all uncommon to have html within a PHP conditional.
If it's not working, enable all error processing and display your
errors. And make sure you display the page source from your browser to
catch any invalid html the browser may not be displaying.
> Please, avoid the temptation to advise me about sanitizing and verifyiing,
> etc.; I purposely wrote this test file without them to follow the KISS
> methodology. Also I'm trying to avoid usiing separate PHP files for doing
> the form input data checks because this seems more efficient and probably
> faster to execute. Seems kinder to the user, too.
>
> Thanks for any comments or corrections needed. I'm also open to better
> methods if there are any. Hope you can understand what I meant above; looks
> clear to me<g>!
>
> Regards,
>
> Twayne`
>
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
|
|
|