Hi all,

Here i have a serious problem. I want to sought it out using PHP and MySQL only.
I have a form includes fields of customer id and Account type( stored in a jump menu and includes 6 different types of accounts)

<style type="text/css">
<!--
body,td,th {
	font-size: 18px;
	font-weight: bold;
}
-->
</style>
<p><img src="../images/mahapitiya 1.jpg" width="1024" height="139" /></p>
<form id="form1" name="form1" method="post" action="">
  <label>
    <input type="submit" name="button" id="button" value="Logout" />
  </label>
</form>
<p>&nbsp;</p>
<form action="" 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>&nbsp;</td>
        <td class="title02">&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
      <tr height="30">
        <td width="10%">&nbsp;</td>
        <td width="25%" class="title02" align="left">Customer ID</td>
        <td width="55%" class="attribute1" align="left"><input type="text" name="customer_id" class="attribute1" /></td>
        <td width="10%">&nbsp;</td>
      </tr>
      <tr height="30">
        <td>&nbsp;</td>
        <td width="25%" class="title02" align="left">Account Type</td>
        <td width="55%" align="left" bgcolor="#FFFFFF" class="attribute1"><select name="account_type" id="jumpMenu" >
            <option selected="selected"></option>
            <option>Savings Investment</option>
            <option>Shakthi</option>
            <option>Surathal</option>
            <option>Abhimani Plus</option>
            <option>Yasasa Certificates</option>
            <option>Fixed Deposits</option>
          </select>&nbsp;</td>
        
        <td width="10%">&nbsp;</td>
      </tr>
    </table>
    <p align="center">&nbsp;</p>
    <p align="center">
      <input type="submit" onclick="return Validate();" name="submit" value="Submit" class="attribute1" />
      &nbsp;&nbsp;
      <input type="reset" name="reset" value="Reset" class="attribute1" />
      &nbsp;&nbsp;
      <label>
        <input type="submit" name="button2" id="button2" value="Help" />
      </label>
    </p>
  </fieldset>
  </td>
  <td width="5%">&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td align="center">&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td><font color="red" size="1" ></font></td>
    <td>&nbsp;</td>
  </tr>
  </table>
</form>
<p>&nbsp;</p>

<script language = "Javascript">
  
function Validate()
{
    if (document.form2.customer_id.value == '') 
    {
        alert('Please enter the valid customer id!');
        return false;
	}
	else if ( document.form2.account_type.selectedIndex == '' )
    {
        alert ( "Please select an account type!." );
        return false;
    }
	return true;
}
</script>

There are 6 different types of tables exist in my database representing 6 different types of accounts.Each and every table there is a field called "account number" which is auto incremented.When user clicks on submit button i want account number to be opened based on selected account type.

How this could be done?

Thanks,
Heshan.

Recommended Answers

All 3 Replies

Hi guys,

I would be more specific. After user clicks on submit button the information should be sent to the "new_account.php" page. It should looks like this..

<!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>
</head>

<body>

<?php
$connect=mysql_connect("localhost","root","");
mysql_select_db("bank",$connect) or die ("could not select database");

if(isset($_POST['submit'])){
      $query="INSERT INTO ".$_POST['account_type']." (`si_number`) VALUES('".$_POST['account_type']."')";
      mysql_query($query) or die(mysql_error());
}
   echo "A new account with number ".mysql_insert_id()." has been created successfully.";

?>
</body>
</html>

When a user select on specific account type the message should be displayed like " A new........(name of the account) account has been successfully opened".

A typical table in the database includes includes fields such as si_number, si_balance, si_interest and account_type. This is for the savings investment account type. The other tables also similar to this one.

The above code would generate account number(si_number) if user select on savings investment as the account type.

But how can this be generalized to all types of accounts?? For an example if a user selects on shakthi account the shakthi number would be created.

Thanks,
Heshan

Are these account numbers unique to the whole system, or is it acceptable that in each of those 6 tables the AI will start at 1?

Each of these 6 tables the AI will start at 1.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.