FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Frst foray into PHP _SELF
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: Frst foray into PHP _SELF [message #169978 is a reply to message #169976] Sat, 02 October 2010 17:37 Go to previous messageGo to previous message
Norman Peelman is currently offline  Norman Peelman
Messages: 126
Registered: September 2010
Karma:
Senior Member
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?

No, nothing wrong... a little ugly/hard on the eyes depending on how
much you do it.

> 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?
>

Not a browser issue.

> 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`
>

Rather than close the PHP tag, whynot use the HEREDOC syntax? It's
basically a super-quote around a large chunk of text but you don't leave
the interpreter - all variable expansion works.

---code---

echo <<< DLMTR

all the $html you want with {$variable} expansion, yes even
{$arrays[0][1]["example"]}.

DLMTR;

---end---

Of course DLMTR can be your choice. With this method you can
basically build a template within the script.

--
Norman
Registered Linux user #461062
-Have you been to www.php.net yet?-
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Problems modifying date using regex
Next Topic: Is PHP solution for web scripts?
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Mon Feb 17 16:55:58 GMT 2025

Total time taken to generate the page: 0.03791 seconds