|
[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. |
||
| 07/03/2009 at 04:27PM PDT, ID: 24543237 |
|
[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.
Your Input Matters 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! |
||
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: |
########HTML FORM#############
<form action="rate.php" method="post">
Professor name:
<br>
<input type="text" name="prof_name">
<br>
School/University:
<br>
<input type="text" name="school_name">
<br>
Department:
<br>
<input type="text" name="dept">
<br>
rate 1-5:
<select name="rate">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>
<br><br>
Your comments:<BR>
<TEXTAREA NAME="comment" COLS=40 ROWS=6></TEXTAREA>
<br><br>
<input type="submit" value="Submit">
<input type="reset" value="Reset">
</form>
______________________PHP __________________________________
<?php
include 'config.php';
include 'opendb.php';
/* Check all form inputs using check_input function */
$prof_name = check_input($_POST['prof_name'], "hey you..... Enter professor name.");
$school_name = check_input($_POST['school_name'], "Enter your school name.");
$dept = check_input($_POST['dept'], "Enter the department.");
$rate = check_input($_POST['rate']);
$comment = check_input($_POST['comment'], "Enter your comment.");
$RSCount = mysql_query("SELECT COUNT(*) AS TotalRecords FROM prof WHERE prof_name = '{$_POST['prof_name']}'");
$CountRow = mysql_fetch_object($RSCount);
if ($CountRow->TotalRecords > 0)
{
$RSProf = mysql_query("SELECT prof_id FROM prof WHERE prof_name = '{$_POST['prof_name']}'");
$ProfRow = mysql_fetch_object($RSProf);
$ProfIDToUpdate = $ProfRow->prof_id;
$updateQuery = "UPDATE prof_rating SET rating = '{$_POST['rate']}' WHERE prof_id = '{$ProfIDToUpdate}'";
@mysql_query($updateQuery) or die(mysql_error());
$updateQuery = "UPDATE prof SET dept = '{$_POST['dept']}', school_id = '{$_POST['school_name']}' WHERE prof_id = '{$ProfIDToUpdate}'";
@mysql_query($updateQuery) or die(mysql_error());
}
else
{
$data= "INSERT INTO prof VALUES ('', '{$_POST['school_name']}', '{$_POST['dept']}', '{$_POST['prof_name']}')";
@mysql_query($data) or die(mysql_error());
$prof_id = mysql_insert_id();
$todata= "INSERT INTO prof_rating VALUES ('', '{$prof_id}', '{$_POST['rate']}', '{$_POST['comment']}')";
@mysql_query($todata) or die(mysql_error());
}
echo "<TD valign='top'><br /><center><b>You successed!";
echo "<br>";
/* Functions we used */
function check_input($data, $problem='')
{
$data = trim($data);
$data = stripslashes($data);
/*$data = htmlspecialchars($data);*/
if ($problem && strlen($data) == 0)
{
show_error($problem);
}
return $data;
}
function show_error($myError)
{
?>
<html>
<body>
<b>Please correct the following error:</b><br />
<?php echo $myError; ?>
</body>
</html>
<?php
exit();
}
?>
|
Advertisement