Re: how to exist within the context?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Thanks for the help.  But I still got:

Please enter your name! Continue processing...

What I want is if no name is entered, only 'Please enter your name!' should be returned.

Bing

David Grant wrote:

Hi,

Try this:

<?php
$submit = $_POST['submit'];
$name = $_POST['yourname'];

if ($submit)
{
   do {
       if ($name=="")
       {
         print "Please enter your name!";
         break;
       }
   } while (0);
}
echo "Continue processing...";
?>

It's a hack, but it works.

Cheers,

David Grant

Bing Du wrote:

Hi,

One webpage has its banner, left menu and footer ect that are controled
by the template.  I want this php script to output the form and
processing result within the page structure.  Without exit, if the
'yourname' field is empty, the script would output 'Please enter your
name!' fine within the page structure (that is, banner, menu and footer
are all there).  But obviously the script does not terminate as it's
supposed to.  With exit, the script terminates fine, but it outputs the
result in a page without banner, menu and footer.  So what's the correct
way to get the script stop and output its results always in the page
structure.

<form method=post>
<input name="yourname" type="text" size="20">
<input name="submit" type="submit" value="submit">
</form>

<?php

$submit = $_POST['submit'];
$name = $_POST['yourname'];

if ($submit)
{
  if ($name=="")
 {
   print "Please enter your name!";
   //exit;
 }
}

echo "Continue processing...";
?>

Thanks in advance,

Bing


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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux