By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,434 Members | 2,963 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,434 IT Pros & Developers. It's quick & easy.

message box

P: 47
hi sir.. i had a problem.... i want to make my page friendly user.... i had change my databse table with unique so that when user reclick the save button will came out warning sign... it work..! but how can i get the warning sign if there is duplicate entry, came out message box..?? if no duplicate entry it will save into database... so that means there had 2 message box... one if duplicate entry it will alert the user.. if no duplicate entry,will display message box that say data successfully save
Jul 30 '08 #1
Share this Question
Share on Google+
5 Replies


acoder
Expert Mod 15k+
P: 16,027
Show your code so far and what you've attempted.
Jul 30 '08 #2

P: 47
[HTML]<!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=iso-8859-1" />
<title>PBL Group Registration | Medic Assessment System</title>
<link href="css/lgblue.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
.style1 {font-family: Arial, Helvetica, sans-serif}
.style23 {color: #000000}
.style19 {
font-size: 12px
}
.style2 {color: #FFFFFF}
.style3 {color: #333333; }
#form1 { background-color: #FFFFFF;
}
.style24 {color: #000000; font-weight: bold; }
.style25 {font-family: Arial, Helvetica, sans-serif; font-weight: bold; }
.style27 {font-size: 12px; font-weight: bold; }
body {
background-color: #FFFFFF;
}
.style28 { font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
font-weight: bold;
}
-->
</style>
<script type="text/javascript">
<!--
function MM_popupMsg(msg) { //v1.0
alert(msg);
}
function MM_setTextOfTextfield(objId,x,newText) { //v9.0
with (document){ if (getElementById){
var obj = getElementById(objId);} if (obj) obj.value = newText;
}
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
if (restore) selObj.selectedIndex=0;
}
//-->
</script>
</head>
<body>
<form name="form1" method="post" action="" >
<div align="left" class="style28">
<table width="500" border="1" align="center">
<tr>
<td height="33" colspan="4"><div align="center" class="style24">Medic Assessment System</div></td>
</tr>
<tr>
<td height="26" colspan="4"><div align="center" class="style25 style23"> Group Registration</div></td>
</tr>
<tr>
<td width="99" class="style1"><div align="right" class="style3 style19"><strong>Year </strong>:</div></td>
<td width="128" class="style1">
<div align="left">
<select name="value" id="year" onChange="MM_jumpMenu('parent',this,0)">
<option value="#">Please select</option>
<option value="?value=1 block 1&group=<? echo $_GET['group'] ?>" <?php if($_GET['value']=='1 block 1'){echo"selected=\"selected\"";} ?>>1 block 1</option>
<option value="?value=1 block 2&group=<? echo $_GET['group'] ?>" <?php if($_GET['value']=='1 block 2'){echo"selected=\"selected\"";} ?>>1 block 2</option>
<option value="?value=1 block 3&group=<? echo $_GET['group'] ?>" <?php if($_GET['value']=='1 block 3'){echo"selected=\"selected\"";} ?>>1 block 3</option>
<option value="?value=1 block 4&group=<? echo $_GET['group'] ?>" <?php if($_GET['value']=='1 block 4'){echo"selected=\"selected\"";} ?>>1 block 4</option>
<option value=" "> </option>
<option value="?value=2 block 1&group=<? echo $_GET['group'] ?>" <?php if($_GET['value']=='2 block 1'){echo"selected=\"selected\"";} ?>>2 block 1</option>
<option value="?value=2 block 2&group=<? echo $_GET['group'] ?>" <?php if($_GET['value']=='2 block 2'){echo"selected=\"selected\"";} ?>>2 block 2</option>
<option value="?value=2 block 3&group=<? echo $_GET['group'] ?>" <?php if($_GET['value']=='2 block 3'){echo"selected=\"selected\"";} ?>>2 block 3</option>
<option value="?value=2 block 4&group=<? echo $_GET['group'] ?>" <?php if($_GET['value']=='2 block 4'){echo"selected=\"selected\"";} ?>>2 block 4</option>
<option value=" "> </option>
<option value="?value=3 block 1&group=<? echo $_GET['group'] ?>" <?php if($_GET['value']=='3 block 1'){echo"selected=\"selected\"";} ?>>3 block 1</option>
<option value="?value=3 block 2&group=<? echo $_GET['group'] ?>" <?php if($_GET['value']=='3 block 2'){echo"selected=\"selected\"";} ?>>3 block 2</option>
<option value="?value=3 block 3&group=<? echo $_GET['group'] ?>" <?php if($_GET['value']=='3 block 3'){echo"selected=\"selected\"";} ?>>3 block 3</option>
<option value="?value=3 block 4&group=<? echo $_GET['group'] ?>" <?php if($_GET['value']=='3 block 4'){echo"selected=\"selected\"";} ?>>3 block 4</option>
<option value=" "> </option>
<option value="?value=4 block 1&group=<? echo $_GET['group'] ?>" <?php if($_GET['value']=='4 block 1'){echo"selected=\"selected\"";} ?>>4 block 1</option>
<option value="?value=4 block 2&group=<? echo $_GET['group'] ?>" <?php if($_GET['value']=='4 block 2'){echo"selected=\"selected\"";} ?>>4 block 2</option>
<option value="?value=4 block 3&group=<? echo $_GET['group'] ?>" <?php if($_GET['value']=='4 block 3'){echo"selected=\"selected\"";} ?>>4 block 3</option>
<option value="?value=4 block 4&group=<? echo $_GET['group'] ?>" <?php if($_GET['value']=='4 block 4'){echo"selected=\"selected\"";} ?>>4 block 4</option>
</select>
</div></td>
<td width="89" class="style1"><div align="right" class="style3"><span class="style27">Session </span>:</div></td>
<td width="156" class="style1"><div align="left" class="style3">
<label>
<input name="sessi" type="text" id="sessi" size="15" maxlength="15" value="2008/2009"/>
</label>
</div></td>
</tr>
<tr>
<td class="style1"><div align="right" class="style3"><span class="style27">PBL Group</span> :</div></td>
<td class="style1"><div align="left" class="style3">
<label>
<select name="group" size="1" id="group" onChange="MM_jumpMenu('parent',this,0)">
<option value="#">Please select</option>
<option value="?value=<? echo $_GET['value']?>&group=1" <?php if($_GET['group']=='1'){echo "selected=\"selected\"";} ?>>1</option>
<option value="?value=<? echo $_GET['value']?>&group=2" <?php if($_GET['group']=='2'){echo "selected=\"selected\"";} ?>>2</option>
<option value="?value=<? echo $_GET['value']?>&group=3" <?php if($_GET['group']=='3'){echo "selected=\"selected\"";} ?>>3</option>
<option value="?value=<? echo $_GET['value']?>&group=4" <?php if($_GET['group']=='4'){echo "selected=\"selected\"";} ?>>4</option>
<option value="?value=<? echo $_GET['value']?>&group=5" <?php if($_GET['group']=='5'){echo "selected=\"selected\"";} ?>>5</option>
<option value="?value=<? echo $_GET['value']?>&group=6" <?php if($_GET['group']=='6'){echo "selected=\"selected\"";} ?>>6</option>
<option value="?value=<? echo $_GET['value']?>&group=7" <?php if($_GET['group']=='7'){echo "selected=\"selected\"";} ?>>7</option>
<option value="?value=<? echo $_GET['value']?>&group=8" <?php if($_GET['group']=='8'){echo "selected=\"selected\"";} ?>>8</option>
<option value="?value=<? echo $_GET['value']?>&group=9" <?php if($_GET['group']=='9'){echo "selected=\"selected\"";} ?>>9</option>
<option value="?value=<? echo $_GET['value']?>&group=10" <?php if($_GET['group']=='10'){echo "selected=\"selected\"";} ?>>10</option>
<option value="?value=<? echo $_GET['value']?>&group=11" <?php if($_GET['group']=='11'){echo "selected=\"selected\"";} ?>>11</option>
<option value="?value=<? echo $_GET['value']?>&group=12" <?php if($_GET['group']=='12'){echo "selected=\"selected\"";} ?>>12</option>
</select>
</label>
</div></td>
<td class="style1"><div align="right"><span class="style3"></span></div></td>
<td class="style1"><div align="left"><span class="style3"></span></div></td>
</tr>
</table>

<div align="center"></div>
<div align="center"></div>
<div align="left"></div>
<div align="left">
<p>&nbsp;</p>
<table width="416" height="70" border="1" align="center">
<tr>
<td width="87" height="33"><span class="style23"><strong>Matric No</strong></span> </td>
<td width="7"><div align="center">:</div></td>
<td width="300"><input name="matric" type="text" class="style28" id="matric" value="<?php echo $row_viewer['matric_no']; ?>" size="15" maxlength="15" /></td>
</tr>
<tr>
<td height="29" bgcolor="#FFFFFF"><span class="style23"><strong>Name</strong></span></td>
<td><div align="center">:</div></td>
<td><input name="name" type="text" class="style28" id="name" value="<?php echo $row_viewer['name']; ?>" size="50" maxlength="50"/></td>

</tr>
</table>
</div>
</div>
<p>&nbsp;</p>
<div align="left">
<input type="hidden" name="MM_insert" value="form1" />
</div>
<p>
<form action="" method="post" name="form3">
<blockquote>
<blockquote>
<blockquote>
<p align="center">
<input name="saved" type="submit" class="style28" id="saved" value="Save" onclick="alert('duplicate entry!'),return confirm('successfully saved')"/>
<input name="reset" type="reset" class="style28" id="reset" value="Reset" />
</p>
</blockquote>
</blockquote>
</blockquote>
</form>
</p>
<p>&nbsp;</p>
</form>
<form name="form2" method="post" action="">
<tr>
<td height="307" bordercolor="#000000" bgcolor="#000000" border="0"><p>&nbsp;</p>
<p>&nbsp;</p>
<table width="696" height="60" border="1" align="center" bordercolor="#000000">
<tr>
<td width="92" height="28" class="style3"><div align="center" class="style28"><strong>Matric_No</strong></div></td>
<td width="216" class="style3"><div align="center" class="style28"><strong>Name</strong></div></td>
<td width="71" class="style3"><div align="center" class="style28"><strong>Sessi</strong></div></td>
<td width="75" class="style3"><div align="center" class="style28"><strong>Year</strong></div></td>
<td width="67" class="style3"><div align="center" class="style28"><strong>Group</strong></div></td>
<td width="66" class="style3"><div align="center" class="style28"><strong> Status </strong></div></td>
<td width="63" class="style3"><div align="center" class="style28"><strong>Delete</strong></div></td>
</tr>

<?php do { ?>
<tr>
<td height="24" class="style3 style2 style4"><div align="left" class="style28">
<div align="center"><?php echo $row_all['matric_no']; ?></div>
</div></td>
<td class="style3 style2 style4"><div align="left" class="style28"><?php echo $row_all['name']; ?></div></td>
<td class="style3 style2 style4"><div align="center" class="style28"><?php echo $row_all['sessi']; ?></div></td>
<td class="style3 style2 style4"><div align="center" class="style28"><?php echo $row_all['year']; ?></div></td>
<td class="style3 style2 style4"><div align="center" class="style28"><?php echo $row_all['group']; ?></div></td>
<td class="style3 style2 style4"><div align="center" class="style28"><?php echo $row_all['status']; ?></div>
<td class="style3 style2 style4"><div align="center">
<input name="del_id[]" type="checkbox" class="style28" value="<?php echo $row_all['matric_no']; ?>" />
</div>
<?php } while ($row_all = mysql_fetch_assoc($all)); ?></table>
<p align="right" class="style2 style4">
<label></label>
</p>
<div align="center"></div>
<blockquote>
<blockquote>
<blockquote>
<blockquote>
<blockquote>
<blockquote>
<blockquote>
<blockquote>
<blockquote>
<blockquote>
<blockquote>
<blockquote>
<blockquote>
<blockquote>
<blockquote>
<blockquote>
<blockquote>
<blockquote>
<blockquote>
<blockquote>
<p align="left" class="style2 style4">


<input name="button" type="submit" class="style28" id="button" onclick="return confirm('Are you sure you wish to delete the selected rows?')" value="Delete" />
</p>
</blockquote>
</blockquote>
</blockquote>
</blockquote>
</blockquote>
</blockquote>
</blockquote>
</blockquote>
</blockquote>
</blockquote>
</blockquote>
</blockquote>
</blockquote>
</blockquote>
</blockquote>
</blockquote>
</blockquote>
</blockquote>
</blockquote>
</blockquote>
<p align="center" class="style23"><a href="menu_individu.php">Back </a> | <a href="main.php">Module Menu</a> | <a href="<?php echo $logoutAction ?>" onclick="MM_popupMsg('You\'re successfully logout from this system...')">Logout</a></span></p>

<p class="style2 style4">&nbsp;</p></td>
<input type="hidden" name="value" id="value" value="<? echo $_GET['value'] ?>" />
<input type="hidden" name="group" id="group" value="<? echo $_GET['group'] ?>" />
</form>
<embed name="CS1210559072500" src="Windows Notify.wav" loop="false" autostart="false" hidden="true" width="0" height="0" enablejavascript="true"></embed>
</body>
</html>
<?php
if ((isset($_POST["name"])) && ($_POST["name"] == "")) {
mysql_free_result($viewer);

mysql_free_result($all);
}
?>
[/HTML]
Jul 30 '08 #3

acoder
Expert Mod 15k+
P: 16,027
To check for a duplicate entry, make an Ajax request to a PHP script which checks for duplicate entries. Call this function from the save button onclick (line 148 in your code).
Jul 30 '08 #4

P: 47
got it!! thank you sir!!
Jul 31 '08 #5

acoder
Expert Mod 15k+
P: 16,027
You're welcome. Glad to help :)
Jul 31 '08 #6

Post your reply

Sign in to post your reply or Sign up for a free account.