Best implementation forms entry

I have a forms.php to get contact data, name, address, etc. Last field is a status line of 72 bytes.
with submit, reset & cancel buttons.
action=update.php method=POST

update.php inserts the data into mysql table, and on success header(Location: www.what.com?status='Record inserted');

the first thing forms does is check if status defined or isset? loads $_POST('status) and if Record inserted clears all data.

try and capture logic goes and gets db error and does similar but leaves data.

Is this the way to do it??? Thanks in advance.

where did the BestShop stuff come from.
header(Location:url?status="

I added markdown single back-ticks around the line in your post that the forum thinks looks like markup so that it won’t get parsed by the forum software.

Cannot tell from the description what the implementation is. Post the form and form processing code needed to reproduce the operation to get specific comments.

The redirect upon successful completion of the post method form processing code should be to the exact same URL of the current page to cause a get request for that page. This prevents the browser from trying to resubmit the form data should that page get browsed back to or reloaded.

You should NOT pass values on the end of the URL that determine what result message gets displayed on a page, as this opens your site to phishing attacks.

How would you pass the status?

What php variable contains current page?
is header the way to go, or is there something better.
Thanks in advance!!!

Where is the status value coming from, since you are inserting new records?

This is why you need to post the code. Your description does not convey the implementation details.

// redirect to the exact same URL of the current page to cause a get request - Post, Redirect, Get (PRG)
die(header(Refresh:0));

success of db insert. “Thank you for your time to share your infomation”

also if dup row, then push “ERROR: Duplicate Row”

will do so. But how do you prevent from being convulted. What are the tags to use?

I finally figured out what you are communicating.

To display a one-time success message, either store the message text or a flag value in a session variable, before you perform the redirect, then test for this session variable, display the success message, and clear the session variable at the appropriate location in the html document.

For user/validation errors, you should store them in an array using the field name as the array index. At the end of the form processing code, if there are no errors (the array is empty), perform the redirect. If there are errors the code will continue on to (re)display the html document, where you can test for and display the user/validation errors, either all at once or individually adjacent to the field they correspond to, then redisplay the form, populating the field values with the submitted form data, so that the user just needs to correct any errors and can resubmit the form.

Many years ago, more that I want to admit, did the exact same kind of thing with CICS.
firsttime display, and gather the data.
then either success or display errors.

If you are not old like I am: FYI
IBM CICS** (Customer Information Control System)

So now my vscode has become totally screwed up. Is there help for xdebug? anywhere?

The session_start is done in the first index.php.

I saw that it has to be the very first thing in the php file.

I am using a cms and the session_start is not.

Do I need the session start in later scripts? again?

Sponsor our Newsletter | Privacy Policy | Terms of Service