oops, take out the @ from in front of mysql_query("
Main Topics
Browse All TopicsI have this form below and the form works fine. But if there is any error, the data the staff enters vanishes. How can I show them the error (which I am right now) but keep what they have entered.
Thanks
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
The easiest solution, but not the most beautifull, is this:
Fill every form value with $_POST values, like this:
<textarea name="nc" id="nc" cols="55" rows="4"><?php echo $_POST['nc'] ?></textarea>
Then, when you load your datafrom the database, set this data in the $_POST array. Like this.
$_POST['nc'] = $nc;
So the first time the page is loaded, $_POST will be filled with data from the database, the second time (when there is an error), it will be filled with data the user submitted, making sure all the forms are always filled.
Quick n dirty :) But no real disadvantages really. Just esthetics.
the post values are being unset by these lines:
$m_a = '';
$d = '';
$a_v_d = '';
$nc = '';
$cr = '';
$m_as = '';
somehow this if statement is not working:
if ($result && empty($message)) // if the query was successfull
so then when you try to fill a textbox like this:
<?php echo $nc; ?>
it is not being filled.
you should try echoing values, like echo the query and echo the post values, and add an echo after the above if statement to see why the variable are being unset. That way you can see what is going wrong.
Also, have you removed all of the session_start() calls after the first one? You only need the first one.
>>If you follow the procedure like i posted it, it will work 100%.
Not on this problem. That will work only when there is posted information. The problem with his code is that he was redirecting back to index.php instead of letting the processing "fall-through". When you redirect, the original contents of the $_POST were being list. The fix was to redirect only when necessary NOT all the time.
>>Thank you!
you are welcome
Business Accounts
Answer for Membership
by: nanharbisonPosted on 2008-10-08 at 14:28:05ID: 22673666
The first thing that is wrong here is that you don't have the session start at the very top of the code t();
/ make sure the user is authenticated
change this:
<?php
// make sure the user is authenticated
@session_star
to this:
<?php
session_start();
/
but then you have session start later on in the code. It has to be at the top of the page.
The second thing is that putting the @ in front of a PHP function suppresses errors, so you are not seeing them. Trying removing that.
Then add the code to show errors at the end of your $result, see below.
Select allOpen in new window