Jump to content

Reloading a page, without losing the form input content.


suttercain

Recommended Posts

Hi guys,

 

I am open to new ideas, but here is what I am doing now and how I have it set up:

 

I have a form in my custom admin panel where I can submit news articles and a picture to accompany it. The problem lies in the picture field. Right now I can select the image via a drop-down menu and select from that list of pictures that are already on the server or I can click the link, which opens a new window, and upload the picture. If I upload a picture and close that upload browser, that picture will not appear in that drop down list until I reload (or refresh) the page. If I refresh the page, I lose all the content. I have entered in the form fields. I currently have the form fields echoing sessions, which works when I need to go back to the submit_news page from the preview_news page, just doesn't work for reload.

 

Anyone have any ideas how to fix this or any other suggestions?

 

Thanks.

 

SC

use this

 

value="<?php if(isset($var)){ echo $var;}?>"

 

adding the if(isset($var)) will keep you from getting undefind variable when the page loads and the variable isnt set.

 

if i understand your post, you can change the $var to $_SESSION['var'] to echo the session data

hmm......dunno

 

i just know when i use it like that i get an undefined variable error if i dont set the variable equal to blank.

 

EDIT:

 

i use an error handler file that sends me an email with the undefind variable and outputs a server warning if i dont use the if statement.

 

]
<?php
$live = TRUE;

$emailaddy = '[email protected]';

function my_error_handler($e_number, $e_message, $e_file, $e_line, $e_vars)
{
global $live, $emailaddy;

$message = "An error occurred in script '$e_file' on line $e_line: $e_message\n";

$message .= print_r($e_vars, 1);

if($live)
{
	error_log($message, 1, $emailaddy); // Send email about error
	echo '<div class="error" align="center">A system error occurred.  We appologize for the inconvenience.  Please check back at a later time.</div><br />';
}
else 
{
	echo '<div class="error" align="center">' . $message . '</div><br />';
}
}

set_error_handler('my_error_handler');
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.