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 8966929
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T17:07:43+00:00 2026-06-15T17:07:43+00:00

A php die function question. when I use die(), it clean all page elements.

  • 0

A php die function question.
when I use die(), it clean all page elements.
Is any way to echo error message and not clean all page, It looks like jump to another page when I use die() to stop code and call out the message.

Here are my code

    <?PHP
$message="";
if(isset($_POST['submit'])){

    $name=$_POST['name'];
    $password=$_POST['password'];

    //Field check
    if($name && $password){$message=$name . $password;}
    else{die($message="please enter name and password");}

    //Check name    
    if($name=="alex" && $password==123){$message="Welcome ". $name;}    
    else{$message="wrong user or password";}
    }
?>

<html>
<p>SIGN UP</p>
    <form action="testing.php" method="POST">
            <input type="text" name="name" placeholder="Enter Name" />
            <input type="password" name="password" placeholder="Enter Password"/>
            <input type="submit" name="submit" value="Sign up"/>
    </form>
    <div><?PHP echo $message?></div>
</html>
  • 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-15T17:07:44+00:00Added an answer on June 15, 2026 at 5:07 pm

    You should read your script for top to bottom, including anything outside of <?php ?>. When using die() your script stops then and there.

    <?php $a = "something"; ?>
    <html>
      <p><?php echo $a?></p>
      <?php die(); ?>
      <p>Never here</p>
    </html>
    

    Would output

    <html>
      <p>something</p>
    

    In your case do

    <?php
    if(isset($_POST['submit'])){
    
        $name=$_POST['name'];
        $password=$_POST['password'];
    
        //Field check
        if(!$name || !$password) {
           $message="please enter name and password");
    
        //Check name and password    
        } elseif ($name=="alex" && $password=="alex1") {
           $message="Welcome ". $name;
    
        } else {
           $message="Username or password incorrect"
        }
    ?>
    <html>
    <p>SIGN UP</p>
        <form action="testing.php" method="POST">
                <input type="text" name="name" placeholder="Enter Name" />
                <input type="password" name="password" placeholder="Enter Password"/>
                <input type="submit" name="submit" value="Sign up"/>
        </form>
        <div><?php echo $message?></div>
    </html>
    

    Also note that I’m using ‘==’ to compare, not ‘=’.

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

Sidebar

Related Questions

Is there a way to use the die() function to stop executing PHP statements
Is there a way to style the output of php's die(); message? I want
I come across this:- PHP Error handling: die() Vs trigger_error() Vs throw Exception and
there have been hundreds if not thousands of posts concerning the use of PHP's
PHP function mysql_connect returns an existing connection, if not setting the forth parameter '$new_link'
This question: Best way to return status flag and message from a method in
Is there a way to call a MySQL stored function (not procedure) in Zend
The code chokes at fopen(): <?php ini_set('display_errors',1); error_reporting(E_ALL); $fp = fopen(/path/to/file/some_file.txt,a) or die(can't open
Here is my code- <?php $con = mysql_connect('db', 'table', 'p/w'); if (!$con) { die('Could
PHP code: echo date(c); //out put like this 2012-06-19T20:37:44+05:30 echo date(d M, Y); //out

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.