Well, for instance. I don't like forms that submit to the same page where
it is located. Separating them helps to maintain the code (usually). I don't
like html inside <?php so 99% of the times I escape with ?>.

  Btw, you should start with <?php and not <?.

  Your input is missing the /, newer versions of HTML (or XHTML) recommend
to finish tags that explicitily don't have a finishing term, with /. So

<input type="text" name="data" />

  And if $submitdata is expected to come from a form, check it:

if ($_SERVER['HTTP_REFERER'] == 'somepage.php') {
    if (isset($_POST['submitdata'])) {

  I also don't like to exit(); programs, but I don't know your whole
situation, so your mileage may vary.... And sometimes use a } else { on
expected values with some nasty error messages (just in case someone is
trying to 'crack' your app).


Julio Nobrega.

Um dia eu chego lá:

Ajudei? Salvei? Que tal um presentinho?

"James Taylor" <[EMAIL PROTECTED]> wrote in message
> Can someone recommend a better method for doing something like the
> All of my programs are written like this, but it's really poor form
> considering I'm not predeclaring my variables, etc.   Only thing I can
> think of is to assign a value in the form a number like 1 or something,
> do a if $value == 1 {do something} but that seems kinda hokey. Here's an
> example of something I'd do:
> <?
>    if ($submitdata) {
>       dosomething;
>       exit;
>     }
>    echo "<form name=\"form\" action=\"$PHP_SELF?\">\n";
>    echo "  <input type=\"text\" name=\"data\">\n";
>    echo "  <input type=\"submit\" name=\"submitdata\" value=\" Submit
>    echo "</form>\n</body>\n</html>";
> ?>

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

Reply via email to