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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T07:04:02+00:00 2026-06-10T07:04:02+00:00

I want to remember the value of a specific input after the submit button

  • 0

I want to remember the value of a specific input after the submit button is clicked? Purpose is if during the user registers an account and encounters errors like email exist or password do not match i want to retain the values like name, age and etc. as of the moment here’s my code, what should I do? Any help or suggestion? thanks

<?php
        session_start();
        $errflag = false;
        $errmsg = array();
        if(isset($_SESSION['errmsg'])&&is_array($_SESSION['errmsg'])&&count($_SESSION['errmsg'])>0){
            foreach($_SESSION['errmsg'] as $msg){
                echo $msg;
            }
            unset($_SESSION['errmsg']);
        }
        ?>
        <form method="post">
            <table>
            <tr>
                <td>Last Name:</td><td><input id="txtfield" type="text" name="lname" autofocus="autofocus" required="required"></td>
            </tr>
            <tr>
                <td>First Name:</td><td><input id="txtfield" type="text" name="fname" required="required"></td>
            </tr>
            <tr>
                <td>E-mail:</td><td><input id="txtfield" type="email" name="email" required="required"></td>
            </tr>
            <tr>
                <td>Password:</td><td><input id="txtfield" type="password" name="pass" pattern=".{6,}" required="required"></td>
            </tr>
            <tr>
                <td>Re-type:</td><td><input id="txtfield" type="password" name="rpass" pattern=".{6,}" required="required"></td>
            </tr>
            <tr>
                <td></td><td><input id="btn" type="submit" name="register" value="Register"></td>
            </tr>
            </table>
        </form>
        <?php
        include 'functions/functions.php';
        if(isset($_POST['register'])){
            $result=ValidateEmail($_POST['email']);
            if($result){
                $errmsg[] = '<p id="error"><img src="img/error.png" alt="error">This email address is already in use.</p>';
                $errflag = true;
            }
            if($_POST['pass']!=$_POST['rpass']){
                $errmsg[] = '<p id="error"><img src="img/error.png" alt="error">Passwords does not match.</p>';
                $errflag = true;
            }
            if($errflag){
                session_regenerate_id();
                $_SESSION['errmsg'] = $errmsg;
                session_write_close();
                $errflag = false;
                header('location: register.php');
                exit();
            }
            else {
                $user = array('lname'=>$_POST['lname'],'fname'=>$_POST['fname'],'email'=>$_POST['email'],'pass'=>$_POST['pass']);
                RegisterUser($user);
                session_regenerate_id();
                $errmsg[] = '<p id="success"><img src="img/success.png" alt="success">Your account is now active. You may now login.</p>';
                $_SESSION['errmsg'] = $errmsg;
                session_write_close();
                header('location: index.php');
                exit();
            }
        }
        ?>
  • 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-10T07:04:03+00:00Added an answer on June 10, 2026 at 7:04 am
     <form method="post">
         <input id="txtfield" type="text" name="lname" autofocus="autofocus" required="required" Value=<?php $lname ?>/>
    

    already posts back to the same page. What you can do now is something like:

     $lname = ""; //and all the other fields
     $fname = "";
     if ($_POST['lname'] == "")
     {
        $fname = $_POST['fname'];//and all the other fields
        //put all the variables back into the form and display an error text
     }
     else
     {
        //Lets do the whole form processing and submit here
     } 
    

    In other words, set all your values for your input fields using variables that are blank. If an error happens, set all those variables to their original value.

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

Sidebar

Related Questions

I'm using TestUnit and I want to test the remember me functionality (when user
Typically Remember me on this computer stores a hashed value of user identifier in
I want to use pushViewController but I can't. I remember that I can use
want to open pdf file when a user clicks on hyperlink shown in gridview
want to know why String behaves like value type while using ==. String s1
want to have a Hyperlink-Button in a gridView in which I can display a
I want to call a specific function on my C# application at a specific
suppose I want to calculate average value of a data-set such as class Averager
So I'm starting a service with a putExtra integer value that I want to
I've created a login submit form in HTML but for some reason user/password autocompletion

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.