Can a PHP page call itself?
Results 1 to 5 of 5

Thread: Can a PHP page call itself?

  1. #1
    Junior Member
    Join Date
    Jul 2003
    Location
    Dallas, TX
    Posts
    24

    Can a PHP page call itself?

    I have written a form on a page.php page (somewhat dynamically) and the action for the form is the page.php page.

    Will this work correctly?
    -Matt
    Grand Master of Computer Wizardry
    www.MattFaus.com

  2. #2
    The Mongoloid ScubaKing22's Avatar
    Join Date
    May 2003
    Posts
    460
    Sure it will:
    PHP Code:
    <? 
    if (isset($_POST['submit']))
    {
     
    //ACTIONS IF PAGE IS SUBMITTED
    }
    else
    {
     
    //ACTIONS IF NOT SUBMITTED
    ?>
    "We can't solve problems by using the same kind of thinking we used when we created them."
    Einstein

  3. #3
    Senior Member
    Join Date
    Nov 2002
    Location
    at work
    Posts
    2,374
    just keep this in mind: if you use

    if (isset($_POST['submit']))

    make sure your submit button looks like this:

    <input type="submit" name="submit" value="Submit This form">

    Where the name attribute is given and matches what you use with the isset() function. Also on your form action, to have php dynamically assign the script name to the form when it is submitted (so the form submits to the same page), you can use $PHP_SELF

    <form method="post" action="<?= $PHP_SELF ?>">

    Cgraz

  4. #4
    Settled 4 red convertible dalecosp's Avatar
    Join Date
    Jul 2002
    Location
    Accelerating Windows at 9.81 m/s....
    Posts
    7,722
    AAMOF, it can call itself as many times as you want to. Many small apps are all one script. Here's a basic layout for a messaging script I have up...the top is a bunch of output functions; the logic is about 20 lines, and basically goes as follows...

    keep in mind that conversion from $_POST array has already been done in variable checking...
    PHP Code:
    if (!$submit) {
      
    // display the original form

    elseif (($submit) && (!($sendmsg)))
      
    // do verification and if succesful, show the message form

    elseif (($submit) && ($sendmsg=="yes"))
       
    // do more verification and send the message 
    /!!\ mysql_ is deprecated --- don't use it! Tell your hosting company you will switch if they don't upgrade! /!!!\ ereg() is deprecated --- don't use it!

    dalecosp "God doesn't play dice." --- Einstein "Perl is hardly a paragon of beautiful syntax." --- Weedpacket

    Getting Help at All --- Collected Solutions to Common Problems --- Debugging 101 --- Unanswered Posts --- OMBE: Office Machines, Business Equipment

  5. #5
    Junior Member
    Join Date
    Jul 2003
    Location
    Dallas, TX
    Posts
    24
    Ok, I would have thought that it wouldn't have been a problem.

    My glitches are coming from somewhere else!

    *marks thread resolved*
    -Matt
    Grand Master of Computer Wizardry
    www.MattFaus.com

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •