Jump to content

Alert doesn't pop up


emilcarlo

Recommended Posts

Hi, can anybody check on this code? I don't have any errors in it, except that the supposedly alert after I deleted an information is not working. Thank you very much.

 

**This is a modified code provided by a friend. It worked originally (I just lost the original file since I sold my old computer xD

 

Here's the code:

 

<?php
include("dbconnection.php");



if(mysql_num_rows($result) > 0)
{
$query = "SELECT * FROM records WHERE id = '".$_GET["id"]."'";
$result = mysql_query($query, $connection);

$status = mysql_result($result, 0, "status");
$territory = mysql_result($result, 0, "territory");
$job_title = mysql_result($result, 0, "job_title");
$area_of_work = mysql_result($result, 0, "area_of_work");
$employer = mysql_result($result, 0, "employer");
$department = mysql_result($result, 0, "department");
$location = mysql_result($result, 0, "location");
$date_posted = mysql_result($result, 0, "date_posted");
$closing_date = mysql_result($result, 0, "closing_date");
$gender = mysql_result($result, 0, "gender");
$first_name = mysql_result($result, 0, "first_name");
$last_name = mysql_result($result, 0, "last_name");
$telephone_number = mysql_result($result, 0, "telephone_number");
$title = mysql_result($result, 0, "title");
$address_1 = mysql_result($result, 0, "address_1");
$address_2 = mysql_result($result, 0, "address_2");
$address_3 = mysql_result($result, 0, "address_3");
$city = mysql_result($result, 0, "city");
$country = mysql_result($result, 0, "country");
$postal_code = mysql_result($result, 0, "postal_code");
$website = mysql_result($result, 0, "website");
$email_address = mysql_result($result, 0, "email_address");
$cg_comment = mysql_result($result, 0, "cg_comment");
$date_emailed = mysql_result($result, 0, "date_emailed");
$mailing_comments= mysql_result($result, 0, "mailing_comments");
$telesales_comments= mysql_result($result, 0, "telesales_comments");	
}

if(isset($_POST["btnSubmit"]))
{
$id = $_POST["id"];

$query = "DELETE FROM records WHERE id = '".$id."'";
mysql_query($query) or die(mysql_error());

echo "<script>
	alert('You have successfully deleted a record');
	window.location = 'view_client.php';
</script>";

}

?>

Link to comment
Share on other sites

Hi schilly, thanks for the response :) Here's the whole code:

 

<?php
include("dbconnection.php");



if(mysql_num_rows($result) > 0)
{
$query = "SELECT * FROM records WHERE id = '".$_GET["id"]."'";
$result = mysql_query($query, $connection);

$status = mysql_result($result, 0, "status");
$territory = mysql_result($result, 0, "territory");
$job_title = mysql_result($result, 0, "job_title");
$area_of_work = mysql_result($result, 0, "area_of_work");
$employer = mysql_result($result, 0, "employer");
$department = mysql_result($result, 0, "department");
$location = mysql_result($result, 0, "location");
$date_posted = mysql_result($result, 0, "date_posted");
$closing_date = mysql_result($result, 0, "closing_date");
$gender = mysql_result($result, 0, "gender");
$first_name = mysql_result($result, 0, "first_name");
$last_name = mysql_result($result, 0, "last_name");
$telephone_number = mysql_result($result, 0, "telephone_number");
$title = mysql_result($result, 0, "title");
$address_1 = mysql_result($result, 0, "address_1");
$address_2 = mysql_result($result, 0, "address_2");
$address_3 = mysql_result($result, 0, "address_3");
$city = mysql_result($result, 0, "city");
$country = mysql_result($result, 0, "country");
$postal_code = mysql_result($result, 0, "postal_code");
$website = mysql_result($result, 0, "website");
$email_address = mysql_result($result, 0, "email_address");
$cg_comment = mysql_result($result, 0, "cg_comment");
$date_emailed = mysql_result($result, 0, "date_emailed");
$mailing_comments= mysql_result($result, 0, "mailing_comments");
$telesales_comments= mysql_result($result, 0, "telesales_comments");	
}

if(isset($_POST["btnSubmit"]))
{
$id = $_POST["id"];

$query = "DELETE FROM records WHERE id = '".$id."'";
mysql_query($query) or die(mysql_error());

echo "<script>
	alert('You have successfully deleted a record');
	window.location = 'view_client.php';
</script>";

}

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
<!--
body,td,th {
font-family: Tahoma, Geneva, sans-serif;
font-size: 12px;
}
-->
</style></head>

<body>
<table width="865" height="140" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <th height="69" colspan="2" bgcolor="#38619E" scope="col"><img src="header.gif" width="563" height="100" alt="" /></th>
  </tr>
  <tr>
    <td width="202" valign="top" bgcolor="#A1BDE1" scope="col"><p> </p>
      <table width="200" border="0" cellpadding="0" cellspacing="0">
        <tr>
          <td scope="col"><table width="202" height="150" border="0" cellpadding="0" cellspacing="0">
            <tr>
              <th height="35" colspan="5" scope="col">CONTROL PANEL</th>
            </tr>
            <tr>
              <td height="10"> </td>
              <td height="35"><a href="data_mining.php"><img src="arrow_up.png" alt="" width="30" height="30" border="0"/></a></td>
              <td height="10" align="left"> </td>
              <td height="10" align="left">MAIN PAGE</td>
              <td height="10" align="left"> </td>
            </tr>
            <tr>
              <td width="16"> </td>
              <td width="32" height="35"><a href="view_client.php"><img src="Search-icon.png" alt="" width="30" height="30" border="0"/></a></td>
              <td width="16" height="35" align="left"> </td>
              <td width="119" height="35" align="left">VIEW RECORD</a></td>
              <td width="19" align="left"> </td>
            </tr>
            <tr>
              <td> </td>
              <td height="35"><img src="addez7.png" alt="" width="30" height="30" border="0"/></td>
              <td height="35" align="left"> </td>
              <td height="35" align="left">ADD RECORD</td>
              <td align="left"> </td>
            </tr>
            <tr>
              <td height="10"> </td>
              <td height="10"> </td>
              <td height="10" align="left"> </td>
              <td height="10" align="left"> </td>
              <td height="10" align="left"> </td>
            </tr>
          </table></td>
        </tr>
      </table>
      <p> </p></th>
    <th width="657" height="600" align="center" valign="top" bgcolor="#A1BDE1" scope="col"><p> </p>
      <form action="delete_client.php" method="post" name="form" id="form">
        <table width="560" border="0" cellpadding="1" cellspacing="0">
          <tr>
            <td width="115"> </td>
            <td width="144"><input type="text" name="id" id="id" style="visibility:hidden" value="<?php echo $_GET["id"]; ?>" /></td>
            <td width="36"> </td>
            <th width="111" align="left"> Status</th>
            <th width="144" align="center"><?php echo $status; ?></th>
          </tr>
          <tr>
            <td width="115"> </td>
            <td width="144"> </td>
            <td width="36"> </td>
            <td width="111" align="left"> </td>
            <td width="144"><input name="status" type="text" id="status" style="visibility:hidden" value="<?php echo $status; ?>"/></td>
          </tr>
          <tr>
            <th width="115" align="left">Territory</th>
            <td width="144"><input type="text" name="territory" id="territory" value="<?php echo $territory; ?>" /></td>
            <td width="36"> </td>
            <th width="111" align="left">Location</th>
            <td width="144"><input type="text" name="location" id="location"  value="<?php echo $location; ?>"/></td>
          </tr>
          <tr>
            <th width="115" align="left">Area of Work</th>
            <td width="144"><input type="text" name="area_of_work" id="area_of_work" value="<?php echo $area_of_work; ?>" /></td>
            <td width="36"> </td>
            <th width="111" align="left">Job Title</th>
            <td width="144"><input type="text" name="job_title" id="job_title" value="<?php echo $job_title; ?>" /></td>
          </tr>
          <tr>
            <th width="115" align="left">Employer</th>
            <td width="144"><input type="text" name="employer2" id="employer2" value="<?php echo $employer; ?>" /></td>
            <td width="36"> </td>
            <th width="111" align="left">Department</th>
            <td width="144"><input type="text" name="department" id="department" value="<?php echo $department; ?>"/></td>
          </tr>
          <tr>
            <th align="left">Date Posted</th>
            <td><input type="text" name="date_posted" id="date_posted"  value="<?php echo $date_posted; ?>"/></td>
            <td> </td>
            <th align="left">Closing Date</th>
            <td><input type="text" name="closing_date" id="closing_date"  value="<?php echo $closing_date; ?>"/></td>
          </tr>
          <tr>
            <td colspan="5" align="center"> </td>
          </tr>
        </table>
        <hr width="500" />
        <table width="560" border="0" cellpadding="1" cellspacing="0">
          <tr>
            <th align="left" scope="col"> </th>
            <th scope="col"> </th>
            <th scope="col"> </th>
            <th align="left" scope="col"> </th>
            <th scope="col"> </th>
          </tr>
          <tr>
            <th width="115" align="left" scope="col">Gender</th>
            <th width="144" scope="col"><input name="gender" type="text" id="gender"  value="<?php echo $gender; ?>"/></th>
            <th width="36" scope="col"> </th>
            <th width="111" align="left" scope="col"> </th>
            <th width="144" scope="col"> </th>
          </tr>
          <tr>
            <th align="left" scope="col">First Name</th>
            <th scope="col"><input type="text" name="first_name" id="first_name"  value="<?php echo $first_name; ?>"/></th>
            <th scope="col"> </th>
            <th align="left" scope="col">Last Name</th>
            <th scope="col"><input type="text" name="last_name" id="last_name"  value="<?php echo $last_name; ?>"/></th>
          </tr>
          <tr>
            <th align="left" scope="col">Title</th>
            <th scope="col"><input type="text" name="title" id="title"  value="<?php echo $title; ?>"/></th>
            <th scope="col"> </th>
            <th align="left" scope="col">Telephone</th>
            <th scope="col"><input type="text" name="telephone_number" id="telephone_number"  value="<?php echo $telephone_number; ?>"/></th>
          </tr>
          <tr>
            <th align="left" scope="col"> </th>
            <th scope="col"> </th>
            <th scope="col"> </th>
            <th align="left" scope="col"> </th>
            <th scope="col"> </th>
          </tr>
          <tr>
            <th align="left" scope="col">Address 1</th>
            <th scope="col"><input type="text" name="address_1" id="address_1"  value="<?php echo $address_1; ?>"/></th>
            <th scope="col"> </th>
            <th align="left" scope="col">Address 2</th>
            <th scope="col"><input type="text" name="address_2" id="address_2"  value="<?php echo $address_2; ?>"/></th>
          </tr>
          <tr>
            <th align="left" scope="col">Address 3</th>
            <th scope="col"><input type="text" name="address_3" id="address_3"  value="<?php echo $address_3; ?>"/></th>
            <th scope="col"> </th>
            <th align="left" scope="col">City</th>
            <th scope="col"><input type="text" name="city" id="city"  value="<?php echo $city; ?>"/></th>
          </tr>
          <tr>
            <th align="left" scope="col">Country</th>
            <th scope="col"><input type="text" name="country" id="country"  value="<?php echo $country; ?>"/></th>
            <th scope="col"> </th>
            <th align="left" scope="col">Postal Code</th>
            <th scope="col"><input type="text" name="postal_code" id="postal_code"  value="<?php echo $postal_code; ?>"/></th>
          </tr>
          <tr>
            <th align="left" scope="col"> </th>
            <th scope="col"> </th>
            <th scope="col"> </th>
            <th align="left" scope="col"> </th>
            <th scope="col"> </th>
          </tr>
          <tr>
            <th align="left" scope="col">Website</th>
            <th scope="col"><input type="text" name="website" id="website"  value="<?php echo $website; ?>"/></th>
            <th scope="col"> </th>
            <th align="left" scope="col">Email Address</th>
            <th scope="col"><input type="text" name="email_address" id="email_address"  value="<?php echo $email_address; ?>"/></th>
          </tr>
          <tr>
            <th align="left" scope="col"> </th>
            <th scope="col"> </th>
            <th scope="col"> </th>
            <th align="left" scope="col"> </th>
            <th scope="col"> </th>
          </tr>
          <tr>
            <th align="left" scope="col"> </th>
            <th scope="col"> </th>
            <th scope="col"> </th>
            <th align="left" scope="col"> </th>
            <th scope="col"> </th>
          </tr>
          <tr>
            <th align="left" scope="col">CG Comment</th>
            <th scope="col"><input type="text" name="comment_by_cg" id="cg_comment"  value="<?php echo $cg_comment; ?>"/></th>
            <th scope="col"> </th>
            <th align="left" scope="col">Date Emailed</th>
            <th scope="col"><input type="text" name="date_emailed" id="date_emailed"  value="<?php echo $date_emailed; ?>"/></th>
          </tr>
          <tr>
            <th align="left" scope="col">Mailing Comments</th>
            <th scope="col"><input type="text" name="mailing_comments" id="mailing_comments"  value="<?php echo $mailing_comments; ?>"/></th>
            <th scope="col"> </th>
            <th align="left" scope="col">Telesales Comments</th>
            <th scope="col"><input type="text" name="telesales_comments" id="telesales_comments"  value="<?php echo $telesales_comments; ?>"/></th>
          </tr>
          <tr>
            <th align="left" scope="col"> </th>
            <th scope="col"> </th>
            <th scope="col"> </th>
            <th align="left" scope="col"> </th>
            <th scope="col"> </th>
          </tr>
          <tr>
            <th colspan="5" align="center" scope="col"><a href="view_client.php" style="text-decoration: none">
              <input type="submit" name="btnSubmit" id="btnSubmit" value="Delete Record" />
              <input type="submit" value="      Cancel      " />
            </a></th>
          </tr>
        </table>
      </form>
      <p> </p></th>
  </tr>
</table>
<center>
  <p><strong>Copyright © 2010 Limited. All   rights reserved.</strong>
  </p>
  <p> </p>
  <p> </p>
</center>
</body>
</html>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.