0

I have already searched an answer here and with google, but I don't found something. Because I'm having trouble ask the right question to find something.

What is the best way for this problem:

My Page: edit_data.php
I have a form (method="post" action="save.php"). On submit I store the data in a MySQL table.

In save.php:
MySQL insert (return the new id of dataset)
if success I call edit_data.php?id=<new_id>
if error I call error.php?msg=<error message>

The problem is that I lose the data on error.

This is what I want:
- go back to edit_data.php
- show the error directly there
- and I want that all fields contains their original data

I cannot take $_GET, because the data are too big.

Does anyone have an easy solution for me?

Thank you

Thomas K.
  • 65
  • 1
  • 6

2 Answers2

0

If $_GET is to big, you can edit your php.ini file.

Please note that PHP setups with the suhosin patch installed will have a default limit of 512 characters for get parameters. Although bad practice, most browsers (including IE) supports URLs up to around 2000 characters, while Apache has a default of 8000.

To add support for long parameters with suhosin, add suhosin.get.max_value_length = in php.ini

http://www.php.net/manual/en/reserved.variables.get.php#101469

Max size of URL parameters in _GET

Community
  • 1
  • 1
nicolae-stelian
  • 344
  • 3
  • 12
0

Is there any reason you can't use $_SESSION? That way, all your data will be saved for the duration of the session, or until you delete it.

Make sure that every PHP document contains session_start(); before any headers are output, this also goes for any blank space before your <?php tag.

To put all your $_POST data in a $_SESSION['POST'] you could do something like,

<?php
  session_start();
  foreach($_POST as $key=>$val) {
    $_SESSION['POST'][$key] = $val;
 } ?>

Then you can access your previous POST variables by accessing $_SESSION['POST']['KEYNAMEHERE']

PS: $_GET and $_POST are interchangeable here

Steviewevie
  • 189
  • 1
  • 13