[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

6.6

save values and show it back on the form

Asked by syedasimmeesaq in PHP Scripting Language, PHP and Databases, PHP for Windows

I 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
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
206:
207:
208:
209:
210:
211:
212:
213:
214:
215:
216:
217:
218:
219:
220:
221:
222:
223:
224:
225:
226:
227:
228:
229:
230:
231:
232:
233:
234:
235:
236:
237:
238:
239:
240:
241:
242:
243:
<?php
// make sure the user is authenticated
@session_start();
if ((isset($_SESSION['user'])) && (isset($_SESSION['pass'])))
{
	require_once('connect_info.php');
	$result = @mysql_query("
	SELECT username, userpassword 
	FROM users 
	WHERE username='".mysql_real_escape_string($_SESSION['user'])."' 
	AND userpassword='".mysql_real_escape_string($_SESSION['pass'])."' 
	AND userlevel=1");
 
// if a record was not found, which means the user is not authenticated
if (@mysql_num_rows($result) == 0) 
{
	header("location: ../index.php");
}
	
}
else // else, the user is not authenticated
{
	header("location: ../index.php");
}
 
 
 
// default vars
$m_a = '';
$d = '';
$a_v_d = '';
$a = '';
$nc = '';
$cr = '';
$m_as = '';
$message = '';
 
if (isset($_POST['submit']))
{
    $m_a = $_POST['m_a'];
	$d = $_POST['d'];
	$a_v_d = $_POST['a_v_d'];
	$a = $_POST['areatext'];
	$nc = $_POST['nc'];
	$cr = $_POST['cr']; 
	$adminuser = $_SESSION['user'];
	$caseno = $_POST['caseno'];
	$FinalDate = $_POST['FinalDate'];
        
        
                $message = "";
        
    if (empty($m_a)) { $message .= '<font color=red>*Error 1<br></font>'; }
	if (empty($d)) { $message .= '<font color=red>*Error 2<br></font>'; }
	if (empty($a_v_d)) { $message .= '<font color=red>*Error 3<br></font>'; }
	if (empty($a)) { $message .= '<font color=red>*Error 4<br></font>'; }
	if (empty($nc)) { $message .= '<font color=red>*Error 5<br></font>'; }
	if (empty($cr)) { $message .= '<font color=red>*Error 6<br></font><br>'; }
        
        if(empty($message)) {
		session_start();
		$_SESSION['setd'] = $d;
                        
                        $result = @mysql_query("
	INSERT INTO compform
	(
		d, 
		a_v_d, 
		mas, 
		nc,
		cr, 
		user,
		area,
		caseno,
		FinalDate
	) 
	VALUES 
	(
		'".mysql_real_escape_string($d)."', 
		'".mysql_real_escape_string($a_v_d)."', 
		'".mysql_real_escape_string($m_a)."', 
		'".mysql_real_escape_string($nc)."',
		'".mysql_real_escape_string($cr)."',  
		'".mysql_real_escape_string($adminuser)."',
		'".mysql_real_escape_string($a)."',
		'".mysql_real_escape_string($caseno)."',
		'".mysql_real_escape_string($FinalDate)."'
	)") or die(mysql_error());
  		$id = mysql_insert_id();
        }
        
        if ($result && empty($message)) // if the query was successfull
        {
		
        $message .= "Successfully inserted new record<br> <a href=\"../../../../form2.php?idre=$id\" target=\"_blank\"></a>";
		
		
		
		
		$m_a = '';
		$d = '';
		$a_v_d = '';
		$nc = '';
		$cr = '';
		$m_as = '';
                
 
        }
        else // else if the query was not successfull
        {
               $message .= '*Error New<br>';
				
        }
       	
 @session_start();
$_SESSION["msg"]  = $message;
header("Location: " . $_SERVER['PHP_SELF']);
exit();
 
        
}
 else {
 
@session_start();
if(isset($_SESSION["msg"]))
{
   $message = $_SESSION['msg'];
   $_SESSION['msg'] = ''; // reset the message after using it
}
else
{
   $message="";
}
 
}
// create a drop down box code in an appendable php variable
$m_as = '<select name="m_a">';
$m_as .= '<option value="">-Select-</option>';
 
// query the database and return a list of options for the select box
$result = @mysql_query("SELECT mid, mas FROM m_as_c");
// check to see if a result was returned - this is good error prevention
if (@mysql_num_rows($result) > 0)
{
	// now, loop through the result set and build the html options tags
	while($nt = mysql_fetch_array($result))
	{
		if ($monitoring_area == $nt['mid'])
		{
			$m_as .= '<option value="'.$nt['mas'].'" selected>"'.$nt['mas'].'"</option>';
		}
		else
		{
			$m_as .= '<option value="'.$nt['mas'].'">"'.$nt['mas'].'"</option>';
		}
	}
}
else // else if the above query fails, then display it as an option
{
	$m_as .= '<option value="">No Options Available</option>';
}
 
 
?>
<html>
<head>
<script language="javascript" type="text/javascript" src="datetimepicker.js"></script>
<style type="text/css">
<!--
.style1 {color: #FFFFFF}
-->
</style>
</head>
<body>
<style type="text/css">
<!--
.txtBlack14 {
	font-family: Arial, Helvetica, sans-serif;
	font-size: 14px;
}
-->
</style>
 
<form name="form1" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<table width="654" border="0">
  <tr>
    <td width="233" class="txtBlack14">User: &nbsp;&nbsp;<b><?php echo $_SESSION['user']; ?></b><br><br></td>
    <td width="1" class="txtBlack14">&nbsp;</td>
    <td class="txtBlack14">&nbsp;</td>
  </tr>
  <tr>
    <td colspan="3" class="txtBlack14"><center><?php echo $message; ?>&nbsp;</td>
    </tr>
  <tr>
    <td colspan="2">D:</td>
    <td><select name="d" id="d">
          <option>2001</option>
          <option>2002</option>
          
    </select></td>
  </tr>
  <tr>
    <td colspan="2">CNo:</td>
    <td><input name="cno" type="text" id="cno" size="32" value="<?php echo  strval($_REQUEST['cno']);  ?>"></td>
  </tr>
  
  <tr> 
    <td colspan="2"></td>
    <td><?php echo $m_as; ?>&nbsp;</td>
  </tr>
  <tr>
    <td colspan="2">&nbsp;</td>
    <td rowspan="3"><textarea name="nc" id="nc" cols="55" rows="4"><?php echo $nc; ?></textarea></td>
  </tr>
  <tr>
    <td colspan="2"></td>
    </tr>
  <tr>
    <td colspan="2">&nbsp;</td>
    </tr>
  <tr>
    <td colspan="2">&nbsp;</td>
    <td rowspan="3"><textarea name="cr" id="cr" cols="55" rows="4"><?php echo $cr; ?></textarea></td>
  </tr>
  <tr>
    <td colspan="2"> </td>
    </tr>
  <tr>
    <td colspan="2">&nbsp;</td>
    </tr>
  <tr>
    <td colspan="2"></td>
    <td width="406"><input name="areatext" type="text" id="atext" size="32"></td>
  </tr>
  </tr>
  <tr>
    <td colspan="2">&nbsp;</td>
    <td><input type="submit" name="submit" id="submit1" value="Submit"/></td>
  </tr>
</table>
</form>
</body>
</html>
 
Related Solutions
 
Loading Advertisement...
 
[+][-]10/08/08 02:28 PM, ID: 22673666Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10/08/08 02:28 PM, ID: 22673673Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10/08/08 02:31 PM, ID: 22673704Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10/08/08 02:32 PM, ID: 22673712Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10/08/08 02:35 PM, ID: 22673731Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10/08/08 02:41 PM, ID: 22673790Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10/08/08 02:54 PM, ID: 22673889Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10/08/08 03:22 PM, ID: 22674101Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10/08/08 05:04 PM, ID: 22674525Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10/08/08 08:25 PM, ID: 22675470Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10/09/08 09:50 AM, ID: 22680224Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10/09/08 10:14 AM, ID: 22680432Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zones: PHP Scripting Language, PHP and Databases, PHP for Windows
Sign Up Now!
Solution Provided By: hielo
Participating Experts: 3
Solution Grade: A
 
[+][-]10/09/08 10:24 AM, ID: 22680513Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10/09/08 10:43 AM, ID: 22680685Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10/09/08 09:59 PM, ID: 22684417Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091111-EE-VQP-89 / EE_QW_2_20070628