Jump to content

Recommended Posts

Hi guys,

 

The supervisor of my system wants to modify my customer details if something incorrect inserted into the database. The process of the system is looked like this. The user enters customer data and and it stores in the customer table.

customer(customer_id, nic, full_name, name_with_initials, address, contact_number, gender)

 

Then when supervisor logged in he wants to approve or modify the details based on my the accuracy of data. When he types the customer ID and clicks on search button ( customer page) the relevant record details have been displayed. That part is worked properly.(approve_account.php)

 

Then in that same page there is a button called "Modify Account" which is linked to modify_form.php

But it does not work. This is that page.Can anyone correct myself...

 

The error message is saying undefined nic, full_name etc......

      <?php
  
   
      $connect=mysql_connect("localhost","root","");
      mysql_select_db("bank",$connect) or die ("could not select database");
   
                 
			  
                $nic =$_POST['nic'];
                $full_name =$_POST['full_name'];
                $name_with_initials =$_POST['name_with_initials'];
                $address =$_POST['address'];
                $contact_number =$_POST['contact_number'];
                $gender =$_POST['gender'];
  

                 if(isset($_POST['customer_id'])) {
                 $customer_id=(int)$_POST['customer_id'];

                
				   
		$result = mysql_query("UPDATE * from customer SET nic = '$nic', full_name = '$full_name', name_with_initials =                                     '$name_with_initials', address = '$address', contact_number = '$contact_number', gender  = '$gender'") ;                  

               if($result){
                  echo "Your information has been successfully added to the database.";
              }else{
                 echo "Failed";
              }	   
				   

}
	   
	   
  ?>

 

Thanks,

Heshan

Try doing this first. I always works for me.

 

1: create a test page for each query;

2: echo" each $variable onto the screen so you can see it work ( when ever is it used or modified).";

3: run the query Directly onto the database changing all the $varlables to valid values to see the $result;

 

4:I'm not sure Update * from customer will work do step3. if you dont get a valid responce try Step 5

UPDATE  (((* from ))) customerSET nic = '$nic', full_name = '$full_name', name_with_initials =  '$name_with_initials', address = '$address', contact_number = '$contact_number', gender  = '$gender'") ;                  

 

5: try this Directly onto the database replacing all the $variables with Valid Values (int's varchar's ect).

UPDATE  customer SET nic = '$nic', full_name = '$full_name', name_with_initials =  '$name_with_initials', address = '$address', contact_number = '$contact_number', gender  = '$gender'") ;                  

 

gooduck

@ andyjcurtis, that coding seems to be not working. i try both... :(

 

@Shp0ngl3, this is my approve_account.php page

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

<!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">
<!--
#apDiv4 {
position:absolute;
width:772px;
height:495px;
z-index:3;
left: 206px;
top: 300px;
}
#form1 {
font-size: 18px;
font-weight: bold;
}
body,td,th {
font-size: 18px;
}
-->
</style>
</head>

<body>


   
<div id="apDiv4">
  <form action="" method="post" name="form1" id="form1">
    <fieldset>
      <legend class="cap"> Customer Details</legend>
      <table width="85%" height="350" border="0" align="center" cellpadding="5" cellspacing="0">
      <?php
  
   
      
     //initilize variables
                 $var_nic = '';
                 $var_full_name = '';
                 $var_name_with_initials = '';
                 $var_address = '';
                 $var_contact_number = '';
                 $var_gender = '';

                 if(isset($_POST['customer_id'])) {
                 $customer_id=(int)$_POST['customer_id'];

                 $query = "select * from customer where customer_id=$customer_id LIMIT 1";
                 $result = mysql_query($query) or die(mysql_error());
                 if(mysql_num_rows($result) < 1) {
                       echo 'The record could not be found.';
                       }else {
				   $row=mysql_fetch_array($result);
				   
			// replace blank variables with variables from the database	   
                $var_nic = $row['nic'];
                $var_full_name = $row['full_name'];
                $var_name_with_initials = $row['name_with_initials'];
                $var_address = $row['address'];
                $var_contact_number = $row['contact_number'];
                $var_gender = $row['gender'];
  }
}
	   
	   
  ?>
      
        <tr>
          <td> </td>
          <td class="title02"> </td>
          <td> </td>
          <td> </td>
        </tr>
        <tr height="30">
          <td width="2%" height="35"> </td>
          <td width="46%" class="title02" align="left">National ID</td>
          <td width="50%" class="attribute1" align="left"><input type="text" name="nic" size="30"   class="attribute1" value="<?php echo $var_nic; ?>"></td>
          <td width="2%"> </td>
        </tr>
        <tr height="30">
        <td height="33"> </td>
        <td width="46%" class="title02" align="left">Full Name</td>
        <td width="50%" class="attribute1" align="left"><input type="text" name="full_name" size="30"   class="attribute1" value="<?php echo $var_full_name; ?>"></td>
          <td width="2%"> </td>
        </tr>
        <tr height="30">
          <td height="34"> </td>
          <td class="title02" align="left">Name With Initials</td>
          <td width="50%" class="attribute1" align="left"><input type="text" name="name_with_initials" size="30"   class="attribute1" value="<?php echo $var_name_with_initials; ?>"></td>
        </tr>
        <tr height="30">
          <td width="2%"> </td>
          <td width="46%" class="title02" align="left">Address</td>
          <td width="50%" class="attribute1" align="left"><label>
            <textarea name="address" id="textarea" cols="45" rows="5"><?php echo $var_address; ?></textarea>
          </label></td>
          <td width="2%"> </td>
        </tr>
        <tr height="30">
          <td width="2%"> </td>
          <td width="46%" class="title02" align="left">Contact Number</td>
          <td width="50%" class="attribute1" align="left"><input type="text" name="contact_number" size="30" class="attribute1" value="<?php echo $var_contact_number; ?>"></td>
          <td width="2%"> </td>
        </tr>
        <tr height="30">
          <td width="2%"> </td>
          <td width="46%" class="title02" align="left">Sex</td>
          <td width="50%" class="attribute1" align="left"><p>
	   <select name="gender" id="jumpMenu" >
          <option selected="selected"><?php echo $var_gender; ?></option>
            
            <option>Male</option>
            <option>Female</option>
          </select>          
          <td width="50%" class="attribute1" align="left"> </td>
            
            <br />
          </p></td>
          <td width="2%"> </td>
        </tr>
        
      </table>
      <p align="center"> </p>
      <p align="center">
        <label>      </label>
        <label>
          <input name="button" type="submit" id="button"  value="Approve Account"  />   
          <label><a href="modify_form.php">
          <input name="button2" type="submit" id="button2"  value="Modify Account"  />
          </a></label>
            
        <label> <a href="accsup_help.php">
          <input name="button" type="submit"  id="button"   value="Help"  />
        </a></label>
        </td>
      </p>
    </fieldset>
    <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>
</div>
<img src="../images/mahapitiya 1.jpg" width="1024" height="139" />
</body>
</html>

 

 

try this if the code recieves the data and procces it?

 


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

                $nic =$_get['nic'];
                $full_name =$_get['full_name'];
                $name_with_initials =$_get['name_with_initials'];
                $address =$_get['address'];
                $contact_number =$_get['contact_number'];
                $gender =$_get['gender'];

                 if(isset($_get['customer_id'])) {
                 $customer_id=(int)$_get['customer_id'];

$result = mysql_query("UPDATE  customer SET nic = '$nic', full_name = '$full_name', name_with_initials =  '$name_with_initials', address = '$address', contact_number = '$contact_number', gender  = '$gender'") ;                  

               if($result){
                  echo "Your information has been successfully added to the database.";
              }else{
                 echo "Failed";
              }
}
  ?>

An error message occurred......

 

Notice: Undefined index: nic in C:\wamp\www\php files\modify_form.php on line 40

 

Notice: Undefined index: full_name in C:\wamp\www\php files\modify_form.php on line 41

 

Notice: Undefined index: name_with_initials in C:\wamp\www\php files\modify_form.php on line 42

 

Notice: Undefined index: address in C:\wamp\www\php files\modify_form.php on line 43

 

Notice: Undefined index: contact_number in C:\wamp\www\php files\modify_form.php on line 44

 

Notice: Undefined index: gender in C:\wamp\www\php files\modify_form.php on line 45

Using a link like:

<a href="modify_form.php">
          <input name="button2" type="submit" id="button2"  value="Modify Account"  />
          </a>

inside of a form, will not submit the data to that page.  It will only link to that page.

 

Forms will only submit the data to that page in the action attribute.

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.