Jump to content

HELP, TO DELETE RECORD


angelshuin

Recommended Posts

:'( I need help.... I can't pop up the message box if there is no data to delete in database. please help me....

 

here the code that i make :

 

 

 

 

<?php require_once('Connections/Registration_Vehicles_UPSI.php'); ?>

 

<?php

function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")

{

$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;

 

switch ($theType) {

    case "text":

      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";

      break;   

    case "long":

    case "int":

      $theValue = ($theValue != "") ? intval($theValue) : "NULL";

      break;

    case "double":

      $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";

      break;

    case "date":

      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";

      break;

    case "defined":

      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;

      break;

  }

  return $theValue;

}

 

 

if (isset($_POST['Form_delete'])) {

 

$data=($_POST['Form_delete']);

 

if(strlen($data) == ""){ echo("<SCRIPT LANGUAGE='JavaScript'>

window.alert('Please enter the vehicle identification number.')

</SCRIPT>");

}

 

else if ((isset($_POST["MM_delete"])) && ($_POST["MM_delete"] == "form1")) {

 

  $deleteSQL = sprintf("DELETE FROM data WHERE Vehicle_Identification_Number=%s",

                      GetSQLValueString($_POST['Form_delete'], "text"));

 

  if (!$deleteSQL) { echo("<SCRIPT LANGUAGE='JavaScript'>

window.alert('Invalid vehicle identification number.')

</SCRIPT>");

}

 

  mysql_select_db($database_Registration_Vehicles_UPSI, $Registration_Vehicles_UPSI);

  $Result1 = mysql_query($deleteSQL, $Registration_Vehicles_UPSI) or die(mysql_error());

 

if (!$Result1) { echo("<SCRIPT LANGUAGE='JavaScript'>

window.alert('Invalid vehicle identification number.')

</SCRIPT>");

}

 

else {

 

  $deleteGoTo = "SaveDelete.php";

  if (isset($_SERVER['QUERY_STRING'])) {

    $deleteGoTo .= (strpos($deleteGoTo, '?')) ? "&" : "?";

    $deleteGoTo .= $_SERVER['QUERY_STRING'];

  }

  header(sprintf("Location: %s", $deleteGoTo));

  }

 

}

}

?>

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"

              "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-gb" lang="en-gb">

<head>

<title>Delete</title>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<meta http-equiv="imagetoolbar" content="false" />

<style type="text/css">

<!--

@import url("c/code.css");

-->

</style>

</head>

<body id="registration_vehicles.com" class="homepage">

<div id="wrapper-a"></div>

<div id="wrapper-b">

<div id="heading">

<p id="heading-intro"><strong>REGISTRATION VEHICLES</strong> in Sultan Idris Education University <strong></strong>.</p>

<p id="heading-skipnav"><a href="#content">Skip site navigation and move to main content of page.</a></p>

<ul id="nav-a">

<li id="nav-a-registration"><a href="Registration.php" title="Registration vehicles in UPSI">Registration</a></li>

<li id="nav-a-database"><a href="Management.php" title="Information about vehicles in UPSI">Database</a></li>

<li id="nav-a-report"><a href="Report.php" title="To see the report in database.">Report</a></li>

</ul>

</div>

<div id="content">

<div id="content-a-inner">

<h2 id="pageheader7">Delete</h2>

<br>

 

<center><form action="Management.php" name="theForm">

<input type="image" name="submit" class="imagesubmit" src="i/BackButton.png" onClick="document.theForm.action='Management.php'"/>

</form></center>

<br>

 

<form name="form1" id="form_registration" method="POST">

<center><table border="0" style="background-color:#000000" cellspacing="0" cellpadding="0">

<tbody>

 

<tr><td width="406" colspan="2"><br><br><h3 style="color:#FF3300;"><strong><center>DELETE</center></strong></h3></td></tr>

 

<tr><td colspan="2"><center><label for="Form_Vehicle_ID_No">Vehicle Identification Number: <span>required</span></label>

<input name="Form_delete" type="text" id="Form" /></center></td></tr>

 

<tr><td colspan="2"><center><input type="image" name="delete" class="imagesubmit" src="i/GM11_form_submit.jpg" /></center><br></td></tr>

<input type="hidden" name="MM_delete" value="form1">

</tbody></table></center>

</form>

 

<img src="i/untitled.bmp" width="10" height="200">

 

</div>

</div>

<div id="content-c">

<div id="content-c-inner">

<ul id="nav-b">

<li id="totop"><a href="#" title="Jump back to the top of the document.">Top</a></li>

<li id="tonavigation"><a href="#nav-a" title="Jump back to the main site navigation.">Navigation</a></li>

</ul>

</div>

</div>

<div id="footer">

<p id="copyright">© 2009 <a href="#" title="More information about the author.">NAZMI IZYAN BINTI AZMI</a>. All rights reserved.</p>

<p></p>

<p>SULTAN IDRIS EDUCATION UNIVERSITY</p>

</div>

</div>

</div>

</body>

</html>

 

Link to comment
https://forums.phpfreaks.com/topic/177287-help-to-delete-record/
Share on other sites

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.