HI all,
I have a small problem regarding my php project.
There is a page called open_account.php. It contains all customer data such as NIC, full_name, date of birth, gender etc. When a user fills all the fields in that form it redirects to another page called new_account.php.
There are various account types in the bank. (Ex: A,B,C) I want to do something like this. When a user selects account B it has to show an error message saying " A male person cannot open a B account". Because it only allows women to open B account.
At the same time when a particular user selects an account say A, a message should be appeared as "Account number 1 has been successfully created"
I want your suggestions regarding how can i do these thing? I have attached all the php files
Database structure
customer(account_number,nic, full_name, name_with_initials, phone_number, address, gender, date_of_birth)
open_account.php
<hr />
<!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>
<script src="datetimepicker_css.js">
</script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
<!--
#apDiv1 {
position:absolute;
width:177px;
height:55px;
z-index:1;
left: 12px;
top: 171px;
}
-->
</style>
</head>
<body>
<h2><img src="../images/image 1.jpg" alt="" width="118" height="89" /> <img src="../images/logo-default.jpg" alt="" width="350" height="89" /> <img src="../images/image 2.jpg" alt="" width="100" height="89" /></h2>
<h2> </h2>
<h2> </h2>
<h2>Accounts Opening Form </h2>
<p> </p>
<form name="form1" method="post" action="account.php" >
<fieldset>
<legend class="cap">Customer details</legend>
<table width="75%" border="0" cellspacing="0" cellpadding="5" align="center">
<tr>
<td> </td>
<td class="title02"> </td>
<td> </td>
<td> </td>
</tr>
<tr height="30">
<td width="10%"> </td>
<td width="25%" class="title02" align="left">NIC</td>
<td width="55%" class="attribute1" align="left"><label>
<input type="text" name="nic" id="textfield" />
</label></td>
<td width="10%"> </td>
</tr>
<tr height="30">
<td> </td>
<td width="25%" class="title02" align="left">Full name</td>
<td width="55%" class="attribute1" align="left"><label>
<input type="text" name="full_name" class="attribute1" />
</label></td>
<td width="10%"> </td>
</tr>
<tr height="30">
<td> </td>
<td class="title02" align="left">Name with initials</td>
<td class="attribute1" align="left"><input type="text" name="name_with_initials" class="attribute1" /></td>
</tr>
<tr height="30">
<td width="10%"> </td>
<td width="25%" class="title02" align="left">Phone Number</td>
<td width="55%" class="attribute1" align="left"><label>
<input type="text" name="phone_number" class="attribute1" />
</label></td>
<td width="10%"> </td>
</tr>
<tr height="30">
<td width="10%"> </td>
<td width="25%" class="title02" align="left">Address</td>
<td width="55%" class="attribute1" align="left"><label>
<textarea name="address" id="textarea" cols="45" rows="5"></textarea>
</label></td>
<td width="10%"> </td>
<tr height="30">
<td> </td>
<td class="title02" align="left">Gender</td>
<td class="attribute1" align="left"><label>
<select name="gender" id="select">
<option>Male</option>
<option>Female</option>
<option selected="selected"></option>
</select>
</label></td>
<tr height="30">
<td> </td>
<td class="title02" align="left">Date of birth</td>
<td class="attribute1" align="left"><input type="Text" id="demo3" name="date_of_birth" maxlength="25" size="25"/><img src="../images/cal.gif" onClick="javascript:NewCssCal('demo3','yyyyMMdd')" style="cursor:pointer"/> </td>
</tr>
</table>
<p align="center">
<input type="submit" name="submit" value="Submit" class="attribute1" onClick="return Validate();"/>
<input type="reset" name="reset" value="Reset" class="attribute1" />
</p>
</fieldset>
</td>
<td width="5%"> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td align="center"> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td><font color=red size="1" ></font></td>
<td> </td>
</tr>
</table>
</form>
<script language = "Javascript">
function Validate()
{
if (document.form1.nic.value == '')
{
alert('Please fill in nic!');
return false;
}
if (document.form1.full_name.value == '')
{
alert('Please fill in full name!');
return false;
}
if (document.form1.name_with_initials.value == '')
{
alert('Please fill in name with initials!');
return false;
}
if (document.form1.phone_number.value == '')
{
alert('Please fill in phone number!');
return false;
}
if (document.form1.address.value == '')
{
alert('Please fill in address!');
return false;
}
if (document.form1.gender.value == '')
{
alert('Please fill in gender!');
return false;
}
if (document.form1.date_of_birth.value == '')
{
alert('Please fill in date_of_birth!');
return false;
}
return true;
}
</script>
</body>
</html>
account.php
<?php
$connect=mysql_connect('localhost','root','');
mysql_select_db('bank',$connect);
$nic=$_POST['nic'];
$full_name=$_POST['full_name'];
$name_with_initials=$_POST['name_with_initials'];
$phone_number= $_POST['phone_number'];
$address=$_POST['address'];
$gender=$_POST['gender'];
$date_of_birth=$_POST['date_of_birth'];
$insert_query = 'insert into customer (
nic,
full_name,
name_with_initials,
phone_number,
address,
gender,
date_of_birth
)
values
(
"' . $_POST['nic'] . '",
"' . $_POST['full_name'] . '",
"' . $_POST['name_with_initials'] . '",
"' . $_POST['phone_number'] . '",
"' . $_POST['address'] . '",
"' . $_POST['gender'] . '",
"' . $_POST['date_of_birth'] . '"
)';
$r = mysql_query($insert_query);
if($r)
{
echo "<p> You are successfully entered customer details
<p><a href=new_account.php>Click here</a> to open a new account.";
}
//because until the processing is done successfully you don't know if registration is successful or not right?
?>
new_account.php
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<script LANGUAGE="JavaScript">
function fd_show(val){
if(val=="fd"){
document.getElementById("fd_box").style.visibility = 'visible';
}else{
document.getElementById("fd_box").style.visibility = 'hidden';
}
}
</script>
<script type="text/javascript">
<!--
function MM_jumpMenu(targ,selObj,restore){ //v3.0
eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
if (restore) selObj.selectedIndex=0;
}
//-->
</script>
<style type="text/css">
<!--
body,td,th {
font-size: 18px;
font-weight: bold;
}
-->
</style>
<style type="text/css">
<!--
body,td,th {
font-size: 18px;
font-weight: bold;
}
-->
</style>
</head>
<body>
<p><img src="../images/image 1.jpg" alt="" width="118" height="89" /> <img src="../images/logo-default.jpg" alt="" width="350" height="89" /> <img src="../images/image 2.jpg" alt="" width="100" height="89" /></p>
<form id="form1" name="form1" method="post" action="">
<label>
<input type="submit" name="button" id="button" value="Logout" />
</label>
</form>
<p> </p>
<form action="new_account.php" method="post" name="form2" id="form2" onSubmit="return Validate();">
<fieldset>
<legend class="cap">Create an Account</legend>
<table width="75%" border="0" cellspacing="0" cellpadding="5" align="center">
<tr>
<td> </td>
<td class="title02"> </td>
<td> </td>
<td> </td>
</tr>
<tr height="30">
<td> </td>
<td width="25%" class="title02" align="left">Account Type</td>
<td width="55%" align="left" bgcolor="#FFFFFF" class="attribute1">
<select name="account_type" onChange="fd_show(this.value)">
<option selected="selected"></option>
<option value="savings_investment">Savings Investment</option>
<option value="shakthi" >Shakthi</option>
<option value="surathal">Surathal</option>
<option value="abhimani_plus">Abhimani Plus</option>
<option value="yasasa">Yasasa Certificates</option>
<option value="fd">Fixed Deposits</option>
</select> </td>
<tr height="30">
<td colspan="4">
<div id="fd_box" style="visibility: hidden;">
<table width="100%" border="0" cellspacing="0" cellpadding="5" align="center">
<tr height="30">
<td width="10%"> </td>
<td width="25%" class="title02" align="left">FD balance</td>
<td width="55%" class="attribute1" align="left"><input type="text" name="balance" class="attribute1" /></td>
<td width="10%"> </td>
</tr>
<tr height="30">
<td width="10%"> </td>
<td width="25%" class="title02" align="left">FD period</td>
<td width="55%" class="attribute1" align="left"><select name="period">
<option selected="selected"></option>
<option value="< 1">less than 1 year</option>
<option value="1-3 years" >1-3 years</option>
<option value="> 3">more than 3 years</option>
<option value="il">immediate loan</option>
</select></td>
<td width="10%"> </td>
</tr>
</table>
</div>
</td>
</tr>
</table>
<p align="center"> </p>
<p align="center">
<input type="submit" onClick="return Validate();" name="submit" value="Submit" class="attribute1" />
<input type="reset" name="reset" value="Reset" class="attribute1" />
<label>
<input type="submit" name="button2" id="button2" value="Help" />
</label>
</p>
</fieldset>
</td>
<td width="5%"> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td align="center"> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td><font color="red" size="1" ></font></td>
<td> </td>
</tr>
</table>
</form>
<p> </p>
<script language = "Javascript">
function Validate()
{
/* if (document.form2.account_number.value == '')
{
alert('Please enter the valid account number!');
return false;
}*/
else if ( document.form2.account_type.selectedIndex == '' )
{
alert ( "Please select an account type!." );
return false;
}
return true;
}
</script>
</body>
</html>