Jump to content

[SOLVED] One day it work the next nothing!


GreenSmurf

Recommended Posts

Hi all,

 

I am very stuck. I can't seem to be able to get this damn thing to work. The UPDATE portion operates properly by editing and updating the information but the INSERT portion fails. I can't seem to find the error- if anyone could help me I would apperciate it. Thank you.

 

<?

include ("include/dbconnect.php");
include ("include/format.inc.php");
include ("include/header.inc.php");
?>
<h1>Edit / add address book entry</h1> 
<?php
if($submit)
{

if(! $read_only)
{
$sql = "INSERT INTO $table (firstname, lastname, address, home, mobile, work, email, email2, bday, bmonth, byear, address2, phone2, accnt) VALUES ('$firstname','$lastname','$address','$home','$mobile','$work','$email','$email2','$bday','$bmonth','$byear','$address2','$phone2','$accnt')";
$result = mysql_query($sql);

$sql = "INSERT INTO address_in_groups SELECT LAST_INSERT_ID() id, group_id FROM group_list WHERE group_name = '".$group_name."'";
$result = mysql_query($sql);

echo "<br><br>Information entered into address book,\n";
echo "<br><a href='edit$page_ext'>add next</a> or return to ";
echo "<a href='index$page_ext'>home page</a>.<br>";

} else
 echo "<br><br>Editing is disabled.\n";

}
else if($update)
{
 if(! $read_only)
 {
$sql="SELECT * FROM $base_from_where AND $table.id=$id";
$result = mysql_query($sql);
$resultsnumber = mysql_numrows($result);

if($resultsnumber > 0)
{
	$sql = "UPDATE $table SET firstname='$firstname',lastname='$lastname',address='$address',home='$home',mobile='$mobile',work='$work',email='$email',email2='$email2',bday='$bday',bmonth='$bmonth',byear='$byear',address2 = '$address2', phone2 = '$phone2', accnt = '$accnt' WHERE id=$id";
	$result = mysql_query($sql);

	// header("Location: view?id=$id");		

	echo "<br>Address book updated.\n";
	echo "<br><a href='index$page_ext'>home page</a>";
} else {
	echo "<br>Invalid ID.\n";
	echo "<br><a href='index$page_ext'>home page</a>";  
}
 } else
   echo "<br><br>Editing is disabled.\n";
}
else if($id)
{
 if(! $read_only)
 {
$result = mysql_query("SELECT * FROM $base_from_where AND $table.id=$id",$db);
$myrow = mysql_fetch_array($result);
?>
 <form method="post" action="edit<? echo $page_ext; ?>">
   
 <table width="380" border="0" cellspacing="1" cellpadding="1">
   <tr> 
     <td> 
       <input type="hidden" name="id" value="<?php echo $myrow["id"]?>">
       Firstname: </td>
     <td> 
       <input type="Text" name="firstname" size="35" value="<?php echo $myrow["firstname"]?>">
     </td>
   </tr>
   <tr> 
     <td>Lastname:</td>
     <td> 
       <input type="Text" name="lastname" size="35" value="<?php echo $myrow["lastname"]?>">
     </td>
   </tr>
   <tr> 
     <td>Address: </td>
     <td> 
       <textarea name="address" rows="5" cols="35"><?php echo $myrow["address"]?></textarea>
     </td>
   </tr>
   <tr> 
     <td>Telephone:</td>
     <td> </td>
   </tr>
   <tr> 
     <td>Home:</td>
     <td> 
       <input type="Text" name="home" value="<?php echo $myrow["home"]?>">
     </td>
   </tr>
   <tr> 
     <td>Mobile:</td>
     <td> 
       <input type="Text" name="mobile" value="<?php echo $myrow["mobile"]?>">
     </td>
   </tr>
   <tr> 
     <td>Work: </td>
     <td> 
       <input type="Text" name="work" value="<?php echo $myrow["work"]?>">
     </td>
   </tr>
   <tr> 
     <td> </td>
     <td> </td>
   </tr>
   <tr> 
     <td>Email:</td>
     <td> 
       <input type="Text" name="email" size="35" value="<?php echo $myrow["email"]?>">
     </td>
   </tr>
   <tr> 
     <td>Email2:</td>
     <td> 
       <input type="Text" name="email2" size="35" value="<?php echo $myrow["email2"]?>">
     </td>
   </tr>
   <tr> 
     <td>Birthday:</td>
     <td> 
       <select name="bday">
<option value="<?php echo $myrow["bday"]?>" selected><?php echo ($myrow["bday"] == 0?"-":$myrow["bday"]) ?></option>
         <option value="0">-</option>
         <option value="1">1</option>
         <option value="2">2</option>
         <option value="3">3</option>
         <option value="4">4</option>
         <option value="5">5</option>
         <option value="6">6</option>
         <option value="7">7</option>
         <option value="8">8</option>
         <option value="9">9</option>
         <option value="10">10</option>
         <option value="11">11</option>
         <option value="12">12</option>
         <option value="13">13</option>
         <option value="14">14</option>
         <option value="15">15</option>
         <option value="16">16</option>
         <option value="17">17</option>
         <option value="18">18</option>
         <option value="19">19</option>
         <option value="20">20</option>
         <option value="21">21</option>
         <option value="22">22</option>
         <option value="23">23</option>
         <option value="24">24</option>
         <option value="25">25</option>
         <option value="26">26</option>
         <option value="27">27</option>
         <option value="28">28</option>
         <option value="29">29</option>
         <option value="30">30</option>
         <option value="31">31</option>
       </select>
       <select name="bmonth">
         <option value="<?php echo $myrow["bmonth"] ?>" selected><?php echo $myrow["bmonth"]?></option>
         <option value="-">-</option>
         <option value="January">January</option>
         <option value="February">February</option>
         <option value="March">March</option>
         <option value="April">April</option>
         <option value="May">May</option>
         <option value="June">June</option>
         <option value="July">July</option>
         <option value="August">August</option>
         <option value="September">September</option>
         <option value="October">October</option>
         <option value="November">November</option>
         <option value="December">December</option>
       </select>
       <input type="text" name="byear" size="4" maxlength="4" value="<?php echo $myrow["byear"]?>">
     </td>
   </tr>
   <tr> 
     <td colspan=2><b><br><br>Secondary</b></td>
   </tr>
   <tr> 
     <td>Address: </td>
     <td> 
       <textarea name="address2" rows="5" cols="35"><?php echo $myrow["address2"]?></textarea>
     </td>
   </tr>
   <tr> 
     <td>Home:</td>
     <td> 
       <input type="Text" name="phone2" value="<?php echo $myrow["phone2"]?>">
     </td>
   </tr>
   <tr> 
     <td colspan=2><b><br><br>Account Info</b></td>
   </tr>
   <tr> 
     <td>Accountant:</td>
     <td> 
       <input type="Text" name="accnt" size="35" value="<?php echo $myrow["accnt"]?>">
     </td>
   </tr>
 </table>
   <br>
   <input type="Submit" name="update" value="Update information">
 </form>
   <br>
 <form method="get" action="delete<? echo $page_ext; ?>">
   <input type="hidden" name="id" value="<?php echo $myrow["id"]?>">
   <input type="Submit" name="update" value="Delete information">
 </form>
 <?

 } else
   echo "<br><br>Editing is disabled.\n";
}
else
{
 if(! $read_only)
 {
?>
 <form method="post" action="edit<? echo $page_ext; ?>">
   
 <table width="380" border="0" cellspacing="1" cellpadding="1">
   <tr> 
     <td> 
       <input type="hidden" name="id" value="<?php echo $myrow["id"]?>">
       Firstname:</td>
     <td> 
       <input type="Text" name="firstname" size="35">
     </td>
   </tr>
   <tr> 
     <td>Lastname: </td>
     <td> 
       <input type="Text" name="lastname" size="35">
     </td>
   </tr>
   <tr> 
     <td>Address: </td>
     <td> 
       <textarea name="address" rows="5" cols="35"></textarea>
     </td>
   </tr>
   <tr> 
     <td>Telephone:</td>
     <td> </td>
   </tr>
   <tr> 
     <td>Home:</td>
     <td> 
       <input type="Text" name="home">
     </td>
   </tr>
   <tr> 
     <td>Mobile: </td>
     <td> 
       <input type="Text" name="mobile">
     </td>
   </tr>
   <tr> 
     <td>Work:</td>
     <td> 
       <input type="Text" name="work">
     </td>
   </tr>
   <tr> 
     <td> </td>
     <td> </td>
   </tr>
   <tr> 
     <td>Email: </td>
     <td> 
       <input type="Text" name="email" size="35">
     </td>
   </tr>
   <tr> 
     <td>Email2: </td>
     <td> 
       <input type="Text" name="email2" size="35">
     </td>
   </tr>
   <tr>
     <td>Birthday:</td>
     <td>
       <select name="bday">
         <option value="0" selected>-</option>
         <option value="1">1</option>
         <option value="2">2</option>
         <option value="3">3</option>
         <option value="4">4</option>
         <option value="5">5</option>
         <option value="6">6</option>
         <option value="7">7</option>
         <option value="8">8</option>
         <option value="9">9</option>
         <option value="10">10</option>
         <option value="11">11</option>
         <option value="12">12</option>
         <option value="13">13</option>
         <option value="14">14</option>
         <option value="15">15</option>
         <option value="16">16</option>
         <option value="17">17</option>
         <option value="18">18</option>
         <option value="19">19</option>
         <option value="20">20</option>
         <option value="21">21</option>
         <option value="22">22</option>
         <option value="23">23</option>
         <option value="24">24</option>
         <option value="25">25</option>
         <option value="26">26</option>
         <option value="27">27</option>
         <option value="28">28</option>
         <option value="29">29</option>
         <option value="30">30</option>
         <option value="31">31</option>
       </select>
       <select name="bmonth">
         <option value="-" selected>-</option>
         <option value="January">January</option>
         <option value="February">February</option>
         <option value="March">March</option>
         <option value="April">April</option>
         <option value="May">May</option>
         <option value="June">June</option>
         <option value="July">July</option>
         <option value="August">August</option>
         <option value="September">September</option>
         <option value="October">October</option>
         <option value="November">November</option>
         <option value="December">December</option>
       </select>
       <input type="Text" name="byear" size="4" maxlength="4">
     </td>
   </tr>
   <tr> 
     <td colspan=2><b><br><br>Secondary</b></td>
   </tr>
   <tr> 
     <td>Address: </td>
     <td> 
       <textarea name="address2" rows="5" cols="35"></textarea>
     </td>
   </tr>
   <tr> 
     <td>Home: </td>
     <td> 
       <input type="Text" name="phone2">
     </td>
   </tr>
   <tr> 
     <td colspan=2><b><br><br>Account Info</b></td>
   </tr>
   <tr> 
     <td>Accountant: </td>
     <td> 
       <input type="Text" name="accnt" size="35">
     </td>
   </tr>
 </table>
   <br>
   <input type="Submit" name="submit" value="Enter information">
 </form>
<?
 } else
   echo "<br><br>Editing is disabled.\n";
}

include ("include/footer.inc.php");
?>

 

-GreenSmurf

 

Link to comment
Share on other sites

then the program is getting in there.  Have you tried printing out the sql to see what the statment looks like??

 

$sql = "INSERT INTO $table (firstname, lastname, address, home, mobile, work, email, email2, bday, bmonth, byear, address2, phone2, accnt) VALUES ('$firstname','$lastname','$address','$home','$mobile','$work','$email','$email2','$bday','$bmonth','$byear','$address2','$phone2','$accnt')";
$result = mysql_query($sql);

print "Insert Statement: $sql";

$sql = "INSERT INTO address_in_groups SELECT LAST_INSERT_ID() id, group_id FROM group_list WHERE group_name = '".$group_name."'";
$result = mysql_query($sql);
print "Insert Into address statement: $sql";

 

-John

 

Link to comment
Share on other sites

INSERT INTO addressbook (firstname, lastname, address, home, mobile, work, email, email2, bday, bmonth, byear, address2, phone2, accnt) VALUES ('asd','asd','','','','','','','0','-','','','','')

INSERT INTO address_in_groups SELECT LAST_INSERT_ID() id, group_id FROM group_list WHERE group_name = ''

 

Here is the outputs for both queries under these if statements:

if($submit)
{

if(! $read_only)
{

 

-GreenSmurf

Link to comment
Share on other sites

Have you tried running that insert in phpMyAdmin or a similar db interface and see if it works there?

 

Are the birthday feilds TEXT type or a date feild.

 

Also I dont see an id feild in that statement it may have to look like this (or something like it)

I added the id feild and '' for the insert

 

INSERT INTO addressbook (id, firstname, lastname, address, home, mobile, work, email, email2, bday, bmonth, byear, address2, phone2, accnt) VALUES ('','asd','asd','','','','','','','0','-','','','','')

 

-John

Link to comment
Share on other sites

Have you tried running that insert in phpMyAdmin or a similar db interface and see if it works there?

 

Are the birthday feilds TEXT type or a date feild.

 

Also I dont see an id feild in that statement it may have to look like this (or something like it)

I added the id feild and '' for the insert

 

INSERT INTO addressbook (id, firstname, lastname, address, home, mobile, work, email, email2, bday, bmonth, byear, address2, phone2, accnt) VALUES ('','asd','asd','','','','','','','0','-','','','','')

 

-John

 

The id should be auto incremental and called by the $myrow line and checked with the if statements. Perhaps the error is within the if statements then.

 

-GreenSmurf

Link to comment
Share on other sites

I doubt it, if it were in the IF statments then you would not have been able to print out the sql.  I know that the ID is auto incremental but for somereason I think that you may need it (although you said it worked before).

 

As I mentioned earlier, if you have phpMyAdmin or QuickAdmin you can test the sql to see if it works in there just to rule it out.

Link to comment
Share on other sites

I changes all the <? tags to <?php considering I have heard this in the past but still nothing. I am open to suggestion at this point because this is only getting more frustrating. I removed all lines and snippets of code with the $accnt, accnt, and Accountant(text in html) involved and it works but not with this code in it. I will post the working version later.

 

-Brandon

Link to comment
Share on other sites

This is the working code.

 

<?

include ("include/dbconnect.php");
include ("include/format.inc.php");
include ("include/header.inc.php");
?>
<h1>Edit / add address book entry</h1> 
<?php
if($submit)
{

if(! $read_only)
{
$sql = "INSERT INTO $table (firstname, lastname, address, home, mobile, work, email, email2, bday, bmonth, byear, address2, phone2) VALUES ('$firstname','$lastname','$address','$home','$mobile','$work','$email','$email2','$bday','$bmonth','$byear', '$address2', '$phone2')";
$result = mysql_query($sql);

$sql = "INSERT INTO address_in_groups SELECT LAST_INSERT_ID() id, group_id FROM group_list WHERE group_name = '".$group_name."'";
$result = mysql_query($sql);

echo "<br><br>Information entered into address book,\n";
echo "<br><a href='edit$page_ext'>add next</a> or return to ";
echo "<a href='index$page_ext'>home page</a>.<br>";

} else
  echo "<br><br>Editing is disabled.\n";

}
else if($update)
{
  if(! $read_only)
  {
$sql="SELECT * FROM $base_from_where AND $table.id=$id";
$result = mysql_query($sql);
$resultsnumber = mysql_numrows($result);

if($resultsnumber > 0)
{
	$sql = "UPDATE $table SET firstname='$firstname',lastname='$lastname',address='$address',home='$home',mobile='$mobile',work='$work',email='$email',email2='$email2',bday='$bday',bmonth='$bmonth',byear='$byear',address2 = '$address2', phone2 = '$phone2' WHERE id=$id";
	$result = mysql_query($sql);

	// header("Location: view?id=$id");		

	echo "<br>Address book updated.\n";
	echo "<br><a href='index$page_ext'>home page</a>";
} else {
	echo "<br>Invalid ID.\n";
	echo "<br><a href='index$page_ext'>home page</a>";  
}
  } else
    echo "<br><br>Editing is disabled.\n";
}
else if($id)
{
  if(! $read_only)
  {
$result = mysql_query("SELECT * FROM $base_from_where AND $table.id=$id",$db);
$myrow = mysql_fetch_array($result);
?>
  <form method="post" action="edit<? echo $page_ext; ?>">
    
  <table width="380" border="0" cellspacing="1" cellpadding="1">
    <tr> 
      <td> 
        <input type="hidden" name="id" value="<?php echo $myrow["id"]?>">
        Firstname: </td>
      <td> 
        <input type="Text" name="firstname" size="35" value="<?php echo $myrow["firstname"]?>">
      </td>
    </tr>
    <tr> 
      <td>Lastname:</td>
      <td> 
        <input type="Text" name="lastname" size="35" value="<?php echo $myrow["lastname"]?>">
      </td>
    </tr>
    <tr> 
      <td>Address: </td>
      <td> 
        <textarea name="address" rows="5" cols="35"><?php echo $myrow["address"]?></textarea>
      </td>
    </tr>
    <tr> 
      <td>Telephone:</td>
      <td> </td>
    </tr>
    <tr> 
      <td>Home:</td>
      <td> 
        <input type="Text" name="home" value="<?php echo $myrow["home"]?>">
      </td>
    </tr>
    <tr> 
      <td>Mobile:</td>
      <td> 
        <input type="Text" name="mobile" value="<?php echo $myrow["mobile"]?>">
      </td>
    </tr>
    <tr> 
      <td>Work: </td>
      <td> 
        <input type="Text" name="work" value="<?php echo $myrow["work"]?>">
      </td>
    </tr>
    <tr> 
      <td> </td>
      <td> </td>
    </tr>
    <tr> 
      <td>Email:</td>
      <td> 
        <input type="Text" name="email" size="35" value="<?php echo $myrow["email"]?>">
      </td>
    </tr>
    <tr> 
      <td>Email2:</td>
      <td> 
        <input type="Text" name="email2" size="35" value="<?php echo $myrow["email2"]?>">
      </td>
    </tr>
    <tr> 
      <td>Birthday:</td>
      <td> 
        <select name="bday">
<option value="<?php echo $myrow["bday"]?>" selected><?php echo ($myrow["bday"] == 0?"-":$myrow["bday"]) ?></option>
          <option value="0">-</option>
          <option value="1">1</option>
          <option value="2">2</option>
          <option value="3">3</option>
          <option value="4">4</option>
          <option value="5">5</option>
          <option value="6">6</option>
          <option value="7">7</option>
          <option value="8">8</option>
          <option value="9">9</option>
          <option value="10">10</option>
          <option value="11">11</option>
          <option value="12">12</option>
          <option value="13">13</option>
          <option value="14">14</option>
          <option value="15">15</option>
          <option value="16">16</option>
          <option value="17">17</option>
          <option value="18">18</option>
          <option value="19">19</option>
          <option value="20">20</option>
          <option value="21">21</option>
          <option value="22">22</option>
          <option value="23">23</option>
          <option value="24">24</option>
          <option value="25">25</option>
          <option value="26">26</option>
          <option value="27">27</option>
          <option value="28">28</option>
          <option value="29">29</option>
          <option value="30">30</option>
          <option value="31">31</option>
        </select>
        <select name="bmonth">
          <option value="<?php echo $myrow["bmonth"] ?>" selected><?php echo $myrow["bmonth"]?></option>
          <option value="-">-</option>
          <option value="January">January</option>
          <option value="February">February</option>
          <option value="March">March</option>
          <option value="April">April</option>
          <option value="May">May</option>
          <option value="June">June</option>
          <option value="July">July</option>
          <option value="August">August</option>
          <option value="September">September</option>
          <option value="October">October</option>
          <option value="November">November</option>
          <option value="December">December</option>
        </select>
        <input type="text" name="byear" size="4" maxlength="4" value="<?php echo $myrow["byear"]?>">
      </td>
    </tr>
    <tr> 
      <td colspan=2><b><br><br>Secondary</b></td>
    </tr>
    <tr> 
      <td>Address: </td>
      <td> 
        <textarea name="address2" rows="5" cols="35"><?php echo $myrow["address2"]?></textarea>
      </td>
    </tr>
    <tr> 
      <td>Home:</td>
      <td> 
        <input type="Text" name="phone2" value="<?php echo $myrow["phone2"]?>">
      </td>
    </tr>
  </table>
    <br>
    <input type="Submit" name="update" value="Update information">
  </form>
    <br>
  <form method="get" action="delete<? echo $page_ext; ?>">
    <input type="hidden" name="id" value="<?php echo $myrow["id"]?>">
    <input type="Submit" name="update" value="Delete information">
  </form>
  <?

  } else
    echo "<br><br>Editing is disabled.\n";
}
else
{
  if(! $read_only)
  {
?>
  <form method="post" action="edit<? echo $page_ext; ?>">
    
  <table width="380" border="0" cellspacing="1" cellpadding="1">
    <tr> 
      <td> 
        <input type="hidden" name="id" value="<?php echo $myrow["id"]?>">
        Firstname:</td>
      <td> 
        <input type="Text" name="firstname" size="35">
      </td>
    </tr>
    <tr> 
      <td>Lastname: </td>
      <td> 
        <input type="Text" name="lastname" size="35">
      </td>
    </tr>
    <tr> 
      <td>Address: </td>
      <td> 
        <textarea name="address" rows="5" cols="35"></textarea>
      </td>
    </tr>
    <tr> 
      <td>Telephone:</td>
      <td> </td>
    </tr>
    <tr> 
      <td>Home:</td>
      <td> 
        <input type="Text" name="home">
      </td>
    </tr>
    <tr> 
      <td>Mobile: </td>
      <td> 
        <input type="Text" name="mobile">
      </td>
    </tr>
    <tr> 
      <td>Work:</td>
      <td> 
        <input type="Text" name="work">
      </td>
    </tr>
    <tr> 
      <td> </td>
      <td> </td>
    </tr>
    <tr> 
      <td>Email: </td>
      <td> 
        <input type="Text" name="email" size="35">
      </td>
    </tr>
    <tr> 
      <td>Email2: </td>
      <td> 
        <input type="Text" name="email2" size="35">
      </td>
    </tr>
    <tr>
      <td>Birthday:</td>
      <td>
        <select name="bday">
          <option value="0" selected>-</option>
          <option value="1">1</option>
          <option value="2">2</option>
          <option value="3">3</option>
          <option value="4">4</option>
          <option value="5">5</option>
          <option value="6">6</option>
          <option value="7">7</option>
          <option value="8">8</option>
          <option value="9">9</option>
          <option value="10">10</option>
          <option value="11">11</option>
          <option value="12">12</option>
          <option value="13">13</option>
          <option value="14">14</option>
          <option value="15">15</option>
          <option value="16">16</option>
          <option value="17">17</option>
          <option value="18">18</option>
          <option value="19">19</option>
          <option value="20">20</option>
          <option value="21">21</option>
          <option value="22">22</option>
          <option value="23">23</option>
          <option value="24">24</option>
          <option value="25">25</option>
          <option value="26">26</option>
          <option value="27">27</option>
          <option value="28">28</option>
          <option value="29">29</option>
          <option value="30">30</option>
          <option value="31">31</option>
        </select>
        <select name="bmonth">
          <option value="-" selected>-</option>
          <option value="January">January</option>
          <option value="February">February</option>
          <option value="March">March</option>
          <option value="April">April</option>
          <option value="May">May</option>
          <option value="June">June</option>
          <option value="July">July</option>
          <option value="August">August</option>
          <option value="September">September</option>
          <option value="October">October</option>
          <option value="November">November</option>
          <option value="December">December</option>
        </select>
        <input type="text" name="byear" size="4" maxlength="4">
      </td>
    </tr>
    <tr> 
      <td colspan=2><b><br><br>Secondary</b></td>
    </tr>
    <tr> 
      <td>Address: </td>
      <td> 
        <textarea name="address2" rows="5" cols="35"></textarea>
      </td>
    </tr>
    <tr> 
      <td>Home:</td>
      <td> 
        <input type="Text" name="phone2">
      </td>
    </tr>
  </table>
    <br>
    <input type="Submit" name="submit" value="Enter information">
  </form>
<?
  } else
    echo "<br><br>Editing is disabled.\n";
}

include ("include/footer.inc.php");
?>

 

Thank you.

 

-Brandon

Link to comment
Share on other sites

Should I post the new code for this topic seeing as how I solved it?

 

-Brandon

 

Decided to post the solution and code. Turns out the db had an extra var field in it and I needed to pass the SELECT sql code with compensation for it. Here is the new and much more complicated code:

<?php

include ("include/dbconnect.php");
include ("include/format.inc.php");
include ("include/header.inc.php");
php?>
<h1>Edit / add address book entry</h1> 
<?php
if($submit)
{

if(! $read_only)
{
$sql = "INSERT INTO $table (firstname, lastname, firstname2, lastname2, clientID, boss, address, home, mobile, work, email, email2, bday, bmonth, byear, address2, phone2, mobile2, work2, ext2, accnt, fax, ext, notes, status, status2, status3, status4, personal, business, payroll, retainer, qb, comment) 
VALUES ('$firstname','$lastname','$firstname2','$lastname2', '$clientID', '$boss', '$address','$home','$mobile','$work','$email','$email2','$bday','$bmonth','$byear','$address2','$phone2', '$mobile2', '$work2', '$ext2','$accnt','$fax','$ext', '$notes', '$status', '$status2', '$status3', '$status4', '$personal', '$business', '$payroll', '$retainer', '$qb', '$comment')";
$result = mysql_query($sql);

echo $sql;
echo "<br><br>";

$sql = "INSERT INTO address_in_groups SELECT LAST_INSERT_ID() id, group_id FROM group_list WHERE group_name = '".$group_name."'";
$result = mysql_query($sql);

echo "<br><br>Information entered into address book,\n";
echo "<br><a href='edit$page_ext'>add next</a> or return to ";
echo "<a href='index$page_ext'>home page</a>.<br>";

} else
  echo "<br><br>Editing is disabled.\n";

}
else if($update)
{
  if(! $read_only)
  {
$sql="SELECT * FROM $base_from_where AND $table.id=$id";
$result = mysql_query($sql);
$resultsnumber = mysql_numrows($result);

if($resultsnumber > 0)
{
	if($newnotes != NULL)
	{
	  $sql = "UPDATE $table SET newnotes = '$newnotes', today = CURDATE() WHERE id=$id";
	  $result = mysql_query($sql);

	  $sql = "UPDATE $table SET firstname='$firstname',lastname='$lastname', firstname2 = '$firstname2', lastname2 = '$lastname2', clientID='$clientID', boss='$boss',address='$address',home='$home',mobile='$mobile',work='$work',email='$email',email2='$email2',bday='$bday',bmonth='$bmonth',byear='$byear',address2 = '$address2', phone2 = '$phone2', accnt = '$accnt', fax = '$fax', ext = '$ext', notes = CONCAT(today,' - ',status,' - ',newnotes,CHAR(13),notes), status ='$status', status2 ='$status2', status3 ='$status3', status4 ='$status4', personal = '$personal', business = '$business', payroll = '$payroll', retainer = '$retainer', qb = '$qb', comment =  '$comment' WHERE id=$id";
	  $result = mysql_query($sql);

	  // header("Location: view?id=$id");		

	  echo "<br>Address book updated.\n";
	  echo "<br><a href='index$page_ext'>home page</a>";
	}

	else
	{
	  $sql = "UPDATE $table SET firstname='$firstname',lastname='$lastname', firstname2 = '$firstname2', lastname2 = '$lastname2', clientID='$clientID', boss='$boss',address='$address',home='$home',mobile='$mobile',work='$work',email='$email',email2='$email2',bday='$bday',bmonth='$bmonth',byear='$byear',address2 = '$address2', phone2 = '$phone2', accnt = '$accnt', fax = '$fax', ext = '$ext', status ='$status', status2 ='$status2', status3 ='$status3', status4 ='$status4', personal = '$personal', business = '$business', payroll = '$payroll', retainer = '$retainer', qb = '$qb', comment =  '$comment' WHERE id=$id";
	  $result = mysql_query($sql);

	echo $sql;
	echo "<br><br>";

	  // header("Location: view?id=$id");		

	  echo "<br>Address book updated.\n";
	  echo "<br><a href='index$page_ext'>home page</a>";
	}
} else {
	echo "<br>Invalid ID.\n";
	echo "<br><a href='index$page_ext'>home page</a>";  
}
  } else
    echo "<br><br>Editing is disabled.\n";
}
else if($id)
{
  if(! $read_only)
  {
$result = mysql_query("SELECT * FROM $base_from_where AND $table.id=$id",$db);
$myrow = mysql_fetch_array($result);
?>
  <form method="post" action="edit<? echo $page_ext; ?>">
    
  <table width="380" border="0" cellspacing="1" cellpadding="1">
    <tr> 
      <td> 
        <input type="hidden" name="id" value="<?php echo $myrow["id"]?>">
        Firstname: </td>
      <td> 
        <input type="Text" name="firstname" size="35" value="<?php echo $myrow["firstname"]?>">
      </td>
      <td>Client ID: </td>
      <td> 
        <input type="Text" name="clientID" size="12" value="<?php echo $myrow["clientID"]?>">
      </td>
    </tr>
    <tr> 
      <td>Lastname: </td>
      <td> 
        <input type="Text" name="lastname" size="35" value="<?php echo $myrow["lastname"]?>">
      </td>
      <td>Business: </td>
      <td> 
        <input type="Text" name="boss" size="35" value="<?php echo $myrow["boss"]?>">
      </td>
    </tr>
    <tr> 
      <td><b><u>Attention</b></u></td>
      <td colspan=3> 
        <input type="Text" name="comment" size="46" value="<?php echo $myrow["comment"]?>">
      </td>
    </tr>
    <tr> 
      <td>Address: </td>
      <td> 
        <textarea name="address" rows="5" cols="35"><?php echo $myrow["address"]?></textarea>
      </td>
    </tr>
  </table>
  <table>
    <tr> 
      <td colspan=3><b>Telephone: </b></td>
    </tr>
    <tr> 
      <td>Home:</td>
      <td> 
        <input type="Text" name="home" value="<?php echo $myrow["home"]?>">
      </td>
      <td>Mobile:</td>
      <td> 
        <input type="Text" name="mobile" value="<?php echo $myrow["mobile"]?>">
      </td>
    </tr>
    <tr> 
      <td>Work: </td>
      <td> 
        <input type="Text" name="work" value="<?php echo $myrow["work"]?>">
      </td>
      <td>Ext:</td>
      <td><input type="Text" name="ext" size="6" value="<?php echo $myrow["ext"]?>"></td>
    </tr>
    <tr> 
      <td>Fax:</td>
      <td><input type="Text" name="fax" value="<?php echo $myrow["fax"]?>"></td>
      <td> </td>
      <td> </td>
    </tr>
    <tr> 
      <td>Email:</td>
      <td> 
        <input type="Text" name="email" size="35" value="<?php echo $myrow["email"]?>">
      </td>
    </tr>
    <tr> 
      <td>Birthday:</td>
      <td> 
        <select name="bday">
<option value="<?php echo $myrow["bday"]?>" selected><?php echo ($myrow["bday"] == 0?"-":$myrow["bday"]) ?></option>
          <option value="0">-</option>
          <option value="1">1</option>
          <option value="2">2</option>
          <option value="3">3</option>
          <option value="4">4</option>
          <option value="5">5</option>
          <option value="6">6</option>
          <option value="7">7</option>
          <option value="8">8</option>
          <option value="9">9</option>
          <option value="10">10</option>
          <option value="11">11</option>
          <option value="12">12</option>
          <option value="13">13</option>
          <option value="14">14</option>
          <option value="15">15</option>
          <option value="16">16</option>
          <option value="17">17</option>
          <option value="18">18</option>
          <option value="19">19</option>
          <option value="20">20</option>
          <option value="21">21</option>
          <option value="22">22</option>
          <option value="23">23</option>
          <option value="24">24</option>
          <option value="25">25</option>
          <option value="26">26</option>
          <option value="27">27</option>
          <option value="28">28</option>
          <option value="29">29</option>
          <option value="30">30</option>
          <option value="31">31</option>
        </select>
        <select name="bmonth">
          <option value="<?php echo $myrow["bmonth"] ?>" selected><?php echo $myrow["bmonth"]?></option>
          <option value="-">-</option>
          <option value="January">January</option>
          <option value="February">February</option>
          <option value="March">March</option>
          <option value="April">April</option>
          <option value="May">May</option>
          <option value="June">June</option>
          <option value="July">July</option>
          <option value="August">August</option>
          <option value="September">September</option>
          <option value="October">October</option>
          <option value="November">November</option>
          <option value="December">December</option>
        </select>
        <input type="text" name="byear" size="4" maxlength="4" value="<?php echo $myrow["byear"]?>">
      </td>
    </tr>
  </table>
  <table>
    <tr> 
      <td> </td>
      <td> </td>
    </tr>
    <tr> 
      <td colspan=3><b>Secondary: </b></td>
    </tr>
    <tr> 
      <td> 
        <input type="hidden" name="id" value="<?php echo $myrow["id"]?>">
        Firstname: </td>
      <td> 
        <input type="Text" name="firstname2" size="35" value="<?php echo $myrow["firstname2"]?>">
      </td>
    </tr>
    <tr> 
      <td>Lastname:</td>
      <td> 
        <input type="Text" name="lastname2" size="35" value="<?php echo $myrow["lastname2"]?>">
      </td>
    </tr>
    <tr> 
      <td>Address: </td>
      <td colspan=3> 
        <textarea name="address2" rows="5" cols="35"></textarea>
      </td>
    </tr>
    <tr> 
      <td>Home:</td>
      <td> 
        <input type="Text" name="home2" value="<?php echo $myrow["home2"]?>">
      </td>
      <td>Mobile:</td>
      <td> 
        <input type="Text" name="mobile2" value="<?php echo $myrow["mobile2"]?>">
      </td>
    </tr>
    <tr> 
      <td>Work: </td>
      <td> 
        <input type="Text" name="work2" value="<?php echo $myrow["work2"]?>">
      </td>
      <td>Ext:</td>
      <td><input type="Text" name="ext2" size="6" value="<?php echo $myrow["ext2"]?>"></td>
    </tr>
    <tr>
<td>Email:</td>
      <td> 
        <input type="Text" name="email2" size="35" value="<?php echo $myrow["email2"]?>">
      </td>
    </tr>
</table>
  <table>
    <tr>
      <td colspan=4><b><br><br>Account Info</b></td>
    </tr>
   <tr> 
      <td>Accountant: </td>
      <td> 
        <input type="Text" name="accnt" size="35" value="<?php echo $myrow["accnt"]?>">
      </td>
<td>QB Password:</td>
<td>
 <input type="text" name="qb" size="10" value="<?php echo $myrow["qb"]?>">
</td>
    </tr>
    <tr>
<td> </td>
<td><b>Services</b></td>
<td colspan=2> </td>
    </tr>
    <tr>
      <td> </td>
<td>
  <input type="checkbox" name="personal" value="checked" <?php echo $myrow["personal"] ?>>Personal
</td>
<td>Status</td>
      <td>
        <select name="status">
          <option value="<?php echo $myrow["status"] ?>" selected><?php echo $myrow["status"]?></option>
          <option value="Completed">Completed</option>
          <option value="In Review">In Review</option>
          <option value="In Process">In Process</option>
          <option value="Sent to GKM">Sent to GKM</option>
          <option value="Awaiting Source Docs">Awaiting Source Docs</option>
          <option value="On Hold/Past Due">On Hold/Past Due</option>
          <option value="Cancelled">Cancelled</option>
        </select>
      </td>
    </tr>
    <tr>
      <td> </td>
<td>
  <input type="checkbox" name="business" value="checked" <?php echo $myrow["business"]?>>Business
</td>
<td>Status</td>
      <td>
        <select name="status2">
          <option value="<?php echo $myrow["status2"] ?>" selected><?php echo $myrow["status2"]?></option>
          <option value="Completed">Completed</option>
          <option value="In Review">In Review</option>
          <option value="In Process">In Process</option>
          <option value="Sent to GKM">Sent to GKM</option>
          <option value="Awaiting Source Docs">Awaiting Source Docs</option>
          <option value="On Hold/Past Due">On Hold/Past Due</option>
          <option value="Cancelled">Cancelled</option>
        </select>
      </td>
    </tr>
    <tr>
      <td> </td>
<td>
  <input type="checkbox" name="payroll" value="checked" <?php echo $myrow["payroll"] ?>>Payroll
</td>
<td>Status</td>
      <td>
        <select name="status3">
          <option value="<?php echo $myrow["status3"] ?>" selected><?php echo $myrow["status3"]?></option>
          <option value="Completed">Completed</option>
          <option value="In Review">In Review</option>
          <option value="In Process">In Process</option>
          <option value="Sent to GKM">Sent to GKM</option>
          <option value="Awaiting Source Docs">Awaiting Source Docs</option>
          <option value="On Hold/Past Due">On Hold/Past Due</option>
          <option value="Cancelled">Cancelled</option>
        </select>
      </td>
    </tr>
    <tr>
      <td> </td>
<td>
  <input type="checkbox" name="retainer" value="checked" <?php echo $myrow["retainer"] ?>>Retainer
</td>
<td>Status</td>
      <td>
        <select name="status4">
          <option value="<?php echo $myrow["status4"] ?>" selected><?php echo $myrow["status4"]?></option>
          <option value="Completed">Completed</option>
          <option value="In Review">In Review</option>
          <option value="In Process">In Process</option>
          <option value="Sent to GKM">Sent to GKM</option>
          <option value="Awaiting Source Docs">Awaiting Source Docs</option>
          <option value="On Hold/Past Due">On Hold/Past Due</option>
          <option value="Cancelled">Cancelled</option>
        </select>
      </td>
    </tr>
    <tr> 
      <td>History: </td>
      <td colspan=3>
  <textarea name="notesdisplay" rows="5" cols="47"><?php echo $myrow["notes"]?></textarea>
</td>
    </tr>
    <tr>
<td>Notes: </td>
      <td colspan=3>
        <textarea name="newnotes" rows="5" cols="47"></textarea>
      </td>
    </tr>
  </table>
    <br>
    <input type="Submit" name="update" value="Update information">
  </form>
    <br>
  <form method="get" action="delete<?php echo $page_ext; ?>">
    <input type="hidden" name="id" value="<?php echo $myrow["id"]?>">
    <input type="Submit" name="update" value="Delete information">
  </form>
  <?php

  } else
    echo "<br><br>Editing is disabled.\n";
}
else
{
  if(! $read_only)
  {
?>
  <form method="post" action="edit<?php echo $page_ext; ?>">
    
  <table width="380" border="0" cellspacing="1" cellpadding="1">
    <tr> 
      <td> 
        <input type="hidden" name="id" value="<?php echo $myrow["id"]?>">
        Firstname: </td>
      <td> 
        <input type="Text" name="firstname" size="35">
      </td>
      <td>Client ID: </td>
      <td> 
        <input type="Text" name="clientID" size="12" value="<?php echo $myrow["clientID"]?>">
      </td>
    </tr>
    <tr> 
      <td>Lastname: </td>
      <td> 
        <input type="Text" name="lastname" size="35">
      </td>
      <td>Business: </td>
      <td> 
        <input type="Text" name="boss" size="35" value="<?php echo $myrow["boss"]?>">
      </td>
    </tr>
    <tr> 
      <td><b><u>Attention</b></u></td>
      <td colspan=3> 
        <input type="Text" name="comment" size="46">
      </td>
    </tr>
    <tr> 
      <td>Address: </td>
      <td> 
        <textarea name="address" rows="5" cols="35"></textarea>
      </td>
    </tr>
  </table>
  <table>
    <tr> 
      <td colspan=3><b>Telephone: </b></td>
    </tr>
    <tr> 
      <td>Home:</td>
      <td> 
        <input type="Text" name="home">
      </td>
      <td>Mobile:</td>
      <td> 
        <input type="Text" name="mobile">
      </td>
    </tr>
    <tr> 
      <td>Work: </td>
      <td> 
        <input type="Text" name="work">
      </td>
      <td>Ext:</td>
      <td>
        <input type="Text" name="ext" size="6">
      </td>
    </tr>
    <tr> 
      <td>Fax:</td>
      <td>
        <input type="Text" name="fax">
      </td>
      <td> </td>
      <td> </td>
    </tr>
    <tr> 
      <td>Email: </td>
      <td> 
        <input type="Text" name="email" size="35">
      </td>
    </tr>
  </table>
  <table>
    <tr>
      <td>Birthday:</td>
      <td>
        <select name="bday">
          <option value="0" selected>-</option>
          <option value="1">1</option>
          <option value="2">2</option>
          <option value="3">3</option>
          <option value="4">4</option>
          <option value="5">5</option>
          <option value="6">6</option>
          <option value="7">7</option>
          <option value="8">8</option>
          <option value="9">9</option>
          <option value="10">10</option>
          <option value="11">11</option>
          <option value="12">12</option>
          <option value="13">13</option>
          <option value="14">14</option>
          <option value="15">15</option>
          <option value="16">16</option>
          <option value="17">17</option>
          <option value="18">18</option>
          <option value="19">19</option>
          <option value="20">20</option>
          <option value="21">21</option>
          <option value="22">22</option>
          <option value="23">23</option>
          <option value="24">24</option>
          <option value="25">25</option>
          <option value="26">26</option>
          <option value="27">27</option>
          <option value="28">28</option>
          <option value="29">29</option>
          <option value="30">30</option>
          <option value="31">31</option>
        </select>
        <select name="bmonth">
          <option value="-" selected>-</option>
          <option value="January">January</option>
          <option value="February">February</option>
          <option value="March">March</option>
          <option value="April">April</option>
          <option value="May">May</option>
          <option value="June">June</option>
          <option value="July">July</option>
          <option value="August">August</option>
          <option value="September">September</option>
          <option value="October">October</option>
          <option value="November">November</option>
          <option value="December">December</option>
        </select>
        <input type="Text" name="byear" size="4" maxlength="4">
      </td>
    </tr>
  </table>
  <table>
    <tr>
      <td> </td>
      <td> </td>
    </tr>
    <tr> 
      <td colspan=3><b>Secondary:</b></td>
    </tr>
    <tr> 
      <td>Firstname: </td>
      <td> 
        <input type="Text" name="firstname2" size="35">
      </td>
    </tr>
    <tr> 
      <td>Lastname: </td>
      <td> 
        <input type="Text" name="lastname2" size="35">
      </td>
    </tr>
    <tr> 
      <td>Address: </td>
      <td colspan=3> 
        <textarea name="address2" rows="5" cols="35"></textarea>
      </td>
    </tr>
    <tr> 
      <td>Home:</td>
      <td> 
        <input type="Text" name="home2">
      </td>
      <td>Mobile:</td>
      <td> 
        <input type="Text" name="mobile2">
      </td>
    </tr>
    <tr> 
      <td>Work: </td>
      <td> 
        <input type="Text" name="work2">
      </td>
      <td>Ext:</td>
      <td>
        <input type="Text" name="ext2" size="6">
      </td>
    </tr>
    <tr> 
      <td>Email: </td>
      <td> 
        <input type="Text" name="email2" size="35">
      </td>
    </tr>
  </table>
  <table>
    <tr>
      <td colspan=4><b><br><br>Account Info:</b></td>
    </tr>
   <tr> 
      <td>Accountant: </td>
      <td> 
        <input type="Text" name="accnt" size="35">
      </td>
<td>QB Password:</td>
<td>
 <input type="text" name="qb" size="10">
</td>
    </tr>
    <tr>
<td> </td>
<td><b>Services</b></td>
<td colspan=2> </td>
    </tr>

    <tr>
      <td> </td>
<td>
  <input type="checkbox" name="personal" value="checked">Personal
</td>
<td>Status</td>
      <td>
        <select name="status">
          <option value="-" selected>-</option>
          <option value="Completed">Completed</option>
          <option value="In Review">In Review</option>
          <option value="In Process">In Process</option>
          <option value="Sent to GKM">Sent to GKM</option>
          <option value="Awaiting Source Docs">Awaiting Source Docs</option>
          <option value="On Hold/Past Due">On Hold/Past Due</option>
          <option value="Cancelled">Cancelled</option>
        </select>
      </td>
    </tr>
    <tr>
      <td> </td>
<td>
  <input type="checkbox" name="business" value="checked">Business
</td>
<td>Status</td>
      <td>
        <select name="status2">
          <option value="-" selected>-</option>
          <option value="Completed">Completed</option>
          <option value="In Review">In Review</option>
          <option value="In Process">In Process</option>
          <option value="Sent to GKM">Sent to GKM</option>
          <option value="Awaiting Source Docs">Awaiting Source Docs</option>
          <option value="On Hold/Past Due">On Hold/Past Due</option>
          <option value="Cancelled">Cancelled</option>
        </select>
      </td>
    </tr>
    <tr>
      <td> </td>
<td>
  <input type="checkbox" name="payroll" value="checked">Payroll
</td>
<td>Status</td>
      <td>
        <select name="status3">
          <option value="-" selected>-</option>
          <option value="Completed">Completed</option>
          <option value="In Review">In Review</option>
          <option value="In Process">In Process</option>
          <option value="Sent to GKM">Sent to GKM</option>
          <option value="Awaiting Source Docs">Awaiting Source Docs</option>
          <option value="On Hold/Past Due">On Hold/Past Due</option>
          <option value="Cancelled">Cancelled</option>
        </select>
      </td>
    </tr>
    <tr>
      <td> </td>
<td>
  <input type="checkbox" name="retainer" value="checked">Retainer
</td>
<td>Status</td>
      <td>
        <select name="status4">
          <option value="-" selected>-</option>
          <option value="Completed">Completed</option>
          <option value="In Review">In Review</option>
          <option value="In Process">In Process</option>
          <option value="Sent to GKM">Sent to GKM</option>
          <option value="Awaiting Source Docs">Awaiting Source Docs</option>
          <option value="On Hold/Past Due">On Hold/Past Due</option>
          <option value="Cancelled">Cancelled</option>
        </select>
      </td>
    </tr>
    <tr> 
      <td>Notes: </td>
      <td colspan=3> 
        <textarea name="newnotes" rows="5" cols="47"></textarea>
      </td>
    </tr>
  </table>
    <br>
    <input type="Submit" name="submit" value="Enter information">
  </form>
<?php
  } else
    echo "<br><br>Editing is disabled.\n";
}

include ("include/footer.inc.php");
?>

 

-Brandon

Link to comment
Share on other sites

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.