0

hi.............
m inserted records in database successfully but now i want that whenever record added in database a dialog box will be shown on the screen.............. " RECORD ADDED"
m using javascript code for this but it is not working............ plz help me to do this .............

<HTML>
<HEAD>
 <TITLE>Apprentice Ship</TITLE>
    <script type="text/javascript">

function Warn()
 {
 alert("RECORD ADDED!!!!");
}
</script>
</HEAD>
<BODY>
<?
 $acode = $_POST["acode"];
 $aname = $_POST["aname"];
 $agender=$_POST["agender"];
$adob =$_POST["adob"];
//$edobm =$_POST["edobm"];
//$edoby =$_POST["edoby"];

$aedu =$_POST["aedu"];
$af_hname=$_POST["af_hname"];
$af_hoccu=$_POST["af_hoccu"];
$aadd1=$_POST["aadd1"];
$aadd2=$_POST["aadd2"];
$acity=$_POST["acity"];
$asta=$_POST["asta"];
$atel=$_POST["atel"];
$apin=$_POST["apin"];

$con = mysql_connect("localhost","root","root");
 if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
  mysql_select_db("master", $con);

 $query="INSERT INTO app_personal  VALUES  ('$acode','$aname','$agender','$adob','$aedu','$af_hname', '$af_hoccu','$aadd1','$aadd2','$acity','$asta', '$atel','$apin')";
   if (mysql_query($query, $con))
   {

//echo "record added!";
    Warn();

}
else
{
echo "something went wrong";
}
mysql_close($con)
?>
</BODY>
</HTML>

<html>
    <head><title> Contractor Data</title></head>
  <body bgcolor="E6E6FA">
  <form method="POST" action="appinspr.php">
   <h3> <p align="center"> Apprentice Personal Detail </h3>   </p>
      <table <p align="center">
   <tr> <th>Code :</th><td> <input type="text" name="acode" size="20"/></td></tr>
  <tr><th>Name: </th><td><input type="text" name="aname" size="20"/>       </td></tr>
 <tr><th> Qualification:</th><td> <input type="text"  name="aedu" size="20">   </td></tr>
 <tr><th> Gender:</th><td> Male<input type="radio" name="agender" value="Male"></td>
 <td> Female<input type="radio" name="agender" value="female"></td></tr>
  <tr> <th>DOB <td>
  <select size="1" name="adob" value="Year">
   <option>Year</option>
   <option>1980</option>
   <option>1981</option>
   <option>1982</option>
   <option>1982</option>
   <option>1983</option>
   <option>1984</option>
   <option>1985</option>
   <option>1986</option>
   <option>1987</option>
   <option>1988</option>
   <option>1989</option>
   <option>1990</option>
   <option>1991</option>
   <option>1992</option>
   <option>1993</option>
   <option>1994</option>
   <option>1995</option>
   <option>1996</option>
   <option>1997</option>
   <option>1998</option>
   <option>1999</option>
   <option>2000</option>
   <option>2001</option>
   <option>2002</option>
   <option>2003</option>
   <option>2004</option>
   <option>2005</option>
   <option>2006</option>
   <option>2007</option>
   <option>2008</option>
   <option>2009</option>
   <option>2010</option>
</select>
  <select size="1" name="adob" value="month">  </th>
  <option>month</option>
   <option>jan</option>
   <option>feb</option>
   <option>mar</option>
   <option>apr</option>
   <option>may</option>
   <option>june</option>
   <option>july</option>
   <option>Aug</option>
   <option>Sep</option>
   <option>Oct</option>
   <option>Nov</option>
   <option>Dec</option>
</select>
<select size="1" name="adob" value="date">
   <option>date</option>
   <option>1</option>
   <option>2</option>
   <option>3</option>
   <option>4</option>
   <option>5</option>
   <option>6</option>
   <option>7</option>
   <option>8</option>
   <option>9</option>
   <option>10</option>
   <option>11</option>
   <option>12</option>
   <option>13</option>
   <option>14</option>
   <option>15</option>
   <option>16</option>
   <option>17</option>
   <option>18</option>
   <option>19</option>
   <option>20</option>
   <option>21</option>
   <option>22</option>
   <option>23</option>
   <option>24</option>
   <option>25</option>
   <option>26</option>
   <option>27</option>
   <option>28</option>
   <option>29</option>
   <option>30</option>
   <option>31</option>
</select> </td></tr>
<tr><th>Father/Husband Name:</th><td><input type="text" name="af_hname" size="20"></td></tr>
<tr><th>Father/Husband Occu:</th><td><input type="text"  name="af_hoccu" size="20"></td></tr>
<tr><th> Address1:</th><td><textarea rows="2" cols="20" name="aadd1"> </textarea></td></tr>
<tr><th> Adreess2:</th><td><textarea rows="2"  cols="20" name="aadd2" ></textarea></td></tr>
<tr><th> City </th><td><select size="1" name="acity" value=""> <BR>
   <option>none</option>
   <option>Ludhiana</option>
   <option>Chandigarh</option>
   <option>Jalandhar</option>
   <option>Mohali</option>
   <option>Moga</option>
   <option>Ferozpur</option>
   <option>Faridkot</option>
   <option>Samrala</option>
   <option>Ambala</option>
</select></td></tr>
<tr><th> State:</th><td><select size="1" name="asta" value="">
   <option>none</option>
   <option>Punjab</option>
</select></td></tr> <BR>
<tr><th>Pin No:</th> <td> <input type="text" name="apin" size="20">   </td></tr>
<tr><th>Contact No:</th> <td> <input type="text"  name="atel" size="20">   </td></tr>
 </p> </table>
<input type="submit" value="SAVE" onclick="Warn();">
 </form>
 </body>


 </html>

Edited by mike_2000_17: Fixed formatting

4
Contributors
5
Replies
10
Views
7 Years
Discussion Span
Last Post by phpbeginners
0

replace warn() with below script

echo"<script >alert('record added'); </script>";

it will display the alert box.

Edited by rajabhaskar525: n/a

0

Since it is a Javascript function we should not call that function as we are calling in PHP. we need to call that function in echo statement using the javascript tags.

Try the following

if (mysql_query($query, $con))
{
//echo "record added!";
echo "<script type='text/javascript'>Warn();</script>";
}
else
{
echo "something went wrong";
}
0
<?php
$theDeleteUrl = "delete_account.php?";
?>
<script language="JavaScript">
function confirmDelete(userid,usrname){
	var currentURL = '<?=$theDeleteUrl;?>';
	var okToDelete = confirm('Are you sure you want to delete this user?');
	
	if(okToDelete){
		location.href = currentURL + 'id=' + userid.toString() + '&x=' + usrname.toString(); 
	}
}
</script>
0

hi.............. this code is working....... but the page redirect to next blank page ...... i dont want dis

0
hi convert your function to php function.
put this inside.

echo '<script>alert("RECORD ADDED!!!!")</script>';
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.