Actually, print would require the parentheses (it's a function).
'echo' would be the appropriate construct.  And don't forget to throw
in an htmlentities() call for security (thanks Chris Shiflett!).
Example:
<form method="post" action="<?php echo
htmlentities($_SERVER['PHP_SELF']); ?>">

Alternatively, you don't have to put anything in the action
attribute.  The browser will automatically assume you want to submit
to the current page.
Example:
<form method="post" action="">
Note:  I know this works in IE6, IE7 and FF1.5+, not sure about other
browsers.

On Oct 31, 8:05 am, "Mike Alsup" <[EMAIL PROTECTED]> wrote:
> Yes, I know what that code is *supposed* to do.  But did you
> view-source on the generated HTML to see if it worked correctly?  See
> resetstudio's post above.
>
> On Oct 31, 2007 8:47 AM, freebox <[EMAIL PROTECTED]> wrote:
>
>
>
> > Thanks for your awnser Mike!
>
> > <?php $_SERVER["PHP_SELF"] ?>  is the self php script.
> > My script login is loginform.php
>
> > I can replace this <?php $_SERVER["PHP_SELF"] ?> for loginform.php
>
> >   <form method="POST" action="loginform.php">
>
> > You understand? This will post to the self script.
>
> > Thanks
>
> > On 31 out, 08:20, "Mike Alsup" <[EMAIL PROTECTED]> wrote:
> > > What is <?php $_SERVER["PHP_SELF"] ?> resolving to?  Did you do a view
> > > source to see?  Is it blank?
>
> > > On Oct 31, 2007 6:31 AM, freebox <[EMAIL PROTECTED]> wrote:
>
> > > > Hello to all!
>
> > > > I'm new here, and I have an question =)
>
> > > > I cant bind an form when i'm posting to self?
>
> > > > I can't get the  alert("Thank you for your comment!");
>
> > > > Look This very, very simple script:
>
> > > >http://pastemonkey.org/paste/7
>
> > > > Or Here directly:
>
> > > > <?php
> > > > require("include/conexao.php");
>
> > > > /* Testa se o form foi enviado */
> > > > if(isset($_POST['submit'])){
>
> > > > } else {
> > > > ?>
> > > > <html>
> > > >         <head>
> > > >                 <!--PARTE DO AJAX -->
> > > >                 <script type="text/javascript" 
> > > > src="script/jquery.js"></script>
> > > >     <script type="text/javascript" src="script/jquery.form.js"></
> > > > script>
>
> > > >     <script type="text/javascript">
> > > >         $(document).ready(function() {
> > > >             $('#loginform').ajaxForm(function() {
> > > >                 alert("Thank you for your comment!");
> > > >             });
> > > >         });
>
> > > >     </script>
> > > >         </head>
> > > >         <body>
> > > >                 <form method="POST" action="<?php $_SERVER["PHP_SELF"] 
> > > > ?>"
> > > > name="loginform" id="loginform" />
> > > >                         Usuário<br />
> > > >                         <input type="text" /><br />
> > > >                         Senha<br />
> > > >                         <input type="password" /><br />
> > > >                         <input type="submit" value="enviar" 
> > > > name="submit" />
> > > >                 </form>
> > > >         </body>
> > > > </html>
>
> > > > <?php  } ?>

Reply via email to