Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8777995
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T19:25:00+00:00 2026-06-13T19:25:00+00:00

I have my long PHP script with some JavaScript at the end. In the

  • 0

I have my long PHP script with some JavaScript at the end. In the middle of the script if an ‘if’ statement is true then is their a way to stop the rest of the PHP script and output the rest of the HTML part of the page. Here’s a little snippet:

... more code ...
        case 2:
            $e=$_POST['email'];
            $n=$_POST['name'];
            mysql_connect($dbloc,$dbuser,$dbpass);
            mysql_select_db($dbname)or die(mysql_error());
                $query="SELECT * FROM users WHERE email='$e'";
            $re=mysql_query($query);
            $numm=mysql_numrows($re);
            if($numm>=1){
                $js="alert('Sorry but your email is currently in use. Please try again with a different email address.');";
                $url="./";
                exit();
            }
            else{
                $_SESSION['rEmail']=$e;
                $_SESSION['rName']=$n;
            }
        break;
... more code...

<html goes here />

I originally thought exit() would end just the PHP portion but still give back the rest of the page but that does not seem to be the case.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T19:25:02+00:00Added an answer on June 13, 2026 at 7:25 pm

    exit() is performing what it was maid to do. It is exiting the your PHP code right from the point where it is called.

    Your concept that it’ll print the remaining of HTML is wrong. The whole of PHP code is taken as a PHP script, with all your logic/PHP functions tagged inside <?php and ?> and the text outside is just like documentation, and is outputted as it is.

    With the exit inside the if statement, the code/text after it isn’t processed at all. I’d suggest that you use a break statement instead.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a long running PHP script. I am making the database connection at
I have a php script that gets user input (some text and a link),
I have a php script which is responsible for reading some request parameters from
Possible Duplicate: Show progress for PHP long script I have a PHP script that
I have a PHP script running on a cron that can take a long
I have a PHP process that takes a long time to run. I don't
I have the following piece of code which outputs a long article: <?php the_content();
I have gone through this page... http://www.php.net/manual/en/function.hash.php MD5 is 32 characters long while sha1
I have implement the exact same concept for my project- http://blog.perplexedlabs.com/2009/05/04/php-jquery-ajax-javascript-long-polling/ My question is,
Apple have long blocked mobile Safari from playing sounds – the usual JavaScript commands

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.