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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T11:15:49+00:00 2026-06-02T11:15:49+00:00

I have faced a problem in all of my php projects is that since

  • 0

I have faced a problem in all of my php projects is that since i used OOP is that if there is a user submitting a form

when it goes to processing it and if it has an error i save a message in the session and redirect them to the same page

this is a sample and of course when it redirects it wipes all the fields that was there

like let’s say i have a register form that had

<?php if(!empty($message)) { echo $message } ?>
<form action ="forms/register.php">
first name: <input type="text" name="first_name" />
username:<input type="text" name="username" />
<input type="submit" value = "submit" />
</form>

and this is what the code in forms/register.php

  if(isset($_POST['submit'])) {
    $first_name = $_POST['first_name'];
    $username = $_POST['username'];

 if(empty($first_name) || empty($username) {
    $session -> message("please fill in all the fields");
    redirect("../register.php");
 } else {
    // do something else like insert query
 }

 }

my problem is if first_name or user_name is empty and it redirects to register.php

and it echos the error message no problem in that

but the fields are empty the first_name and the user_name are empty

so the user has to fill it all again

so one of my friends suggested to save it in the session or something

so i would like to know if that is possible then how and what i mean by how so nobody would get it wrong, i mean the way not the code to just copy it and paste it

Thanks in advance

and sorry for being long and annoying

  • 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-02T11:15:50+00:00Added an answer on June 2, 2026 at 11:15 am

    You can store whatever values you want to keep persisted in the form after the page redirects in session variables, then retrieve those values on the form page and echo them in the value attribute of the form elements.

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

Sidebar

Related Questions

We've faced strange problem. We have log on service, that authenticates user, adds auth
I have a problem that I have not faced before: It seems that the
I am faced with a problem where I have to calculate intersections between all
I have faced the same problem many times. The Same Problem was With This
I faced an interesting problem today. I have 4 strings which I need to
Today I faced a strange problem in C#. I have an ASP.NET page where
I have designed a custom section handler before but I'm faced with a problem
So I have this php script that output an html table with data about
According to the PHP Documentation PDO::prepare() adds quotes to all your parameters so that
Today I faced a strange problem. I have an application which is the same

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.