QUOTE(aviansuicide @ Mar 26 2005, 11:58 PM)
Code?
[right][snapback]25303[/snapback][/right]
PHP
<?php
$viewPointID = $HTTP_GET_VARS['viewPointID'];
$nodeID = $HTTP_GET_VARS['nodeID'];
$modelID = $HTTP_GET_VARS['modelID'];
require_once('includes/DbConnector.php');
// Create an instance of DbConnector
$connector = new DbConnector();
require_once('includes/Validator.php');
// Create an instance of Validator
$validator = new Validator();
if ($viewPointID != '') {
$validator->validateNumber($viewPointID,'Selected View Point');
$validator->validateNumber($nodeID,'Selected Node');
if ( $validator->foundErrors() ){
echo 'There was a problem with the '.$validator->listErrors('<br />'); // Show the errors, with a line between each
echo("<br /><a href='mainframe.php?modelID=".$modelID."'>Return to the model</a>");
}else{
// echo("Passed Validation<br />");
$fromNameVPA = $connector->query("SELECT * FROM viewpoint_node WHERE d_nodeID = '".$nodeID."' AND s_viewPointID = '".$viewPointID."'");
$fromNameVPArray = $connector->fetchArray($fromNameVPA);
if ($fromNameVPArray['s_viewPointID'] != '') {
// Node already exists in viewpoint so delete it
$connector->query("DELETE FROM viewpoint_node WHERE d_nodeID = '".$nodeID."' AND s_viewPointID = '".$viewPointID."'");
// echo("Link Deleted<br />");
} else {
// Node does not exist in view point so add it
$insertQuery = "INSERT INTO viewpoint_node (s_viewPointID, d_nodeID) VALUES ('".$viewPointID."', '".$nodeID."')";
$resultInsert = $connector->query($insertQuery);
// echo("Link Added<br />");
}
header("Location: mainframe.php?modelID=".$modelID);
}
}
?>
Its from the same site as the other thread lol. The DB connector and validator do exactly what they say on the tin! The code here doesn't work (well it doesn't throw any errors and redirects) but take out the header line and it works fine!