Jump to content


Photo

Editing Information: Problem (T_T)


  • Please log in to reply
7 replies to this topic

#1 massive

massive
  • Members
  • PipPipPip
  • Advanced Member
  • 40 posts

Posted 24 February 2006 - 03:47 AM

Hi guyz...i'm having a hard time editing my subscribers information....everytime i press the 'UPDATE' button their information disappears everytime i try to view their information again.. (T_T)



heres what happen... let's say i tried to change his/her phone number...then i press update then when i view it their phoneno's disappears...even their last names and first names automatically disappears...i got pisted off then i clicked the update button like 2 to 4 times then the edited phoneno numbers suddenly appears but the firstnames and lastnames really disappeared as if my UPDATE button was program for DELETE....i click again it disappears.....kind of spooky huh?....guyz i really need your help can anybody give their prefered script in editing information...tnx your help will be appreciated :)




here's my script (please give me anonther alternative in editing information.... T_T)
$connection = mysql_connect(DB_SERVER, DB_USER, DB_PASS) or die('Unable to connect!');
    mysql_select_db(DB_NAME) or die('Unable to select database');

if(!$_POST['update']){
    $bdate = $_POST['bdate'];
    $tax = $_POST['tax'];
    $email = $_POST['email'];
    $haddress = $_POST['haddress'];
    $hphoneno = $_POST['hphoneno'];
    $hfaxno = $_POST['hfaxno'];
    $businessname = $_POST['businessname'];
    $baddress = $_POST['baddress'];
    $ophoneno = $_POST['ophoneno'];
    $ofaxno = $_POST['ofaxno'];
    $service = $_POST['service'];
    $zip = $_POST['zip'];
    $cellphone = $_POST['cellphone'];
$change  = "UPDATE subscriber SET birthdate = '$bdate', taxid = '$tax', email = '$email', homeaddress = '$haddress', homephoneno = '$hphoneno', homefaxno = '$hfaxno', businessname = '$businessname', businessaddress = '$baddress', businessphoneno = '$ophoneno', businessfaxno = '$ofaxno', zipcode = '$zip', cellphoneno = '$cellphone' WHERE userid = '$id' ";

$revised = mysql_query($change) or die("Error in query: $change. " . mysql_error());

} ?>
-----html---------------------------------
<form action="<? echo $_SESSION['PHP_SELF']; ?>" method="POST">

#2 hitman6003

hitman6003
  • Members
  • PipPipPip
  • Advanced Member
  • 1,807 posts

Posted 24 February 2006 - 03:52 AM

Look at this line:

if(!$_POST['update']){

Your telling it "if there is no POST update, do this...".

I'm assuming you want the opposite of that, so change it to:

if($_POST['update']){

As far as stuff disappearing and such, we can't help with code we can't see.

#3 massive

massive
  • Members
  • PipPipPip
  • Advanced Member
  • 40 posts

Posted 25 February 2006 - 12:20 AM

hi hitman ^^ , when i change my if(!$_POST['update']) to this if($_POST['update']) the disappearing thing was gone ^^...but it can't still update an information...i've made a small version of the page here it is:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>edit information</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<?

     
       
       
 if(!$_POST['submit'])
 {
  
       $connection = mysql_connect(DB_SERVER, DB_USER, DB_PASS) or die('Unable to connect!');
       mysql_select_db(DB_NAME) or die('Unable to select database');
       $query = "SELECT lname, fname FROM subscriber WHERE username = '$subscriber'";
       $display = mysql_query($query) or die("Error in query: $query. " . mysql_error());
       
       if($_POST['update']) {
       $query = "UPDATE subscriber SET lname = '$lname', fname = '$fname' WHERE username = '$subscriber'"; 
       $new = mysql_query($query) or die("Error in query: $query. " . mysql_error());
       
       }


?>
<p>&nbsp;</p>
<form action="<? echo $_SERVER['PHP_SELF']; ?>" method="post">
<table width="750" border="0" cellspacing="0">
  <tr>
    <td width="395">&nbsp;</td>
    <td width="351"><div align="right">username: 
          <input name="subscriber" type="text">
        <input type="submit" name="Submit" value="Submit">
      </div></td>
  </tr>
</table>
<p>&nbsp;</p>
<? if(mysql_num_rows($display)) {?>
<table width="750" border="0" cellspacing="0">
              <? while($row = mysql_fetch_object($display)) {  ?>
  <tr>
    <td width="238">last name: 
      <input name="lname" type="text" value="<? echo $row->lname  ?>"></td>
    <td width="508">firstname: 
      <input name="fname" type="text" value="<? echo $row->fname ?>"></td>
  </tr>
  <? } ?>
</table>

<p>
  <input type="submit" name="Submit2" value="Update">  
</p>
<? } ?>
</form>
<? } ?>
<p>&nbsp; </p>
</body>
</html>


#4 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 25 February 2006 - 01:31 AM

<input type="submit" name="Submit2" value="Update">
Look for the presence (or absence) of $_POST['Submit2'] or its value being Update since that's the variable you're looking for or its name. Maybe that'll help.
Legend has it that reading the manual never killed anyone.
My site

#5 massive

massive
  • Members
  • PipPipPip
  • Advanced Member
  • 40 posts

Posted 25 February 2006 - 02:00 AM

still won't work....(T_T) could you give me a sample of your script in editing information...?or anyone else?...its about 2 weeks now and i still can't figure it out...whats the problem with it...?tnx...

#6 hitman6003

hitman6003
  • Members
  • PipPipPip
  • Advanced Member
  • 1,807 posts

Posted 25 February 2006 - 04:13 AM

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>edit information</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<?

$html = '<form action="<? echo $_SERVER['PHP_SELF']; ?>" method="post">
<table width="750" border="0" cellspacing="0">
  <tr>
    <td width="395">&nbsp;</td>
    <td width="351"><div align="right">username:
          <input name="subscriber" type="text">
        <input type="submit" name="Submit" value="Submit">
      </div></td>
  </tr>
</table><br>
<input type="submit" name="submit" value="Submit"> ';


if($_POST['submit'] == "Submit") {
  
   $connection = mysql_connect(DB_SERVER, DB_USER, DB_PASS) or die('Unable to connect!');
   mysql_select_db(DB_NAME) or die('Unable to select database');

   $query = "SELECT lname, fname FROM subscriber WHERE username = '$subscriber'";
   $display = mysql_query($query) or die("Error in query: $query. " . mysql_error());

    if (mysql_num_rows($display) > 0) {
        $html = '<table width="750" border="0" cellspacing="0">'
        while($row = mysql_fetch_object($display)) {
          $html .= '
                <tr>
                  <td colspan="2">' . $subscriber . '</td>
              </tr>
              <tr>
                <td width="238">last name:
                  <input name="lname" type="text" value="' . $row[lname] . '"></td>
                <td width="508">firstname:
                  <input name="fname" type="text" value="' . $row[fname] . '"></td>
              </tr>';
        }
        $html .= '</table><br><input type="submit" name="submit" value="Update"> ';
    }
}
      
if($_POST['submit'] == "Update") {
    $query = "UPDATE subscriber SET lname = '$lname', fname = '$fname' WHERE username = '$subscriber'";
    $new = mysql_query($query) or die("Error in query: $query. " . mysql_error());
}
mysql_close($connection);

echo $html;
?>
</body>
</html>


#7 massive

massive
  • Members
  • PipPipPip
  • Advanced Member
  • 40 posts

Posted 26 February 2006 - 05:42 AM

[div align=\"left\"]Still can't solve it in editing/updating an information..... T_T, So here is the actuall code i've been working on:

Here is the querying for updating...just copy and paste it to see it more clearly for debugging...tnx


<?  

    if((!isset($_GET['id']) || trim($_GET['id']) == ''))
        {
            die('Missing record ID!');
        }
 
    $connection = mysql_connect(DB_SERVER, DB_USER, DB_PASS) or die('Unable to connect!');
    mysql_select_db(DB_NAME) or die('Unable to select database');

    $query2 = "SELECT username, ServiceType FROM subscription WHERE username = '$id'";
    $display = mysql_query($query2) or die("Error in query: $query. " . mysql_error());
    
    $query = "SELECT *, CONCAT(lname, ', ', fname) AS name FROM subscriber  WHERE username = '$id'";
    $result = mysql_query($query) or die("Error in query: $query. " . mysql_error());
    
    if($_POST['update']){
    $connection = mysql_connect(DB_SERVER, DB_USER, DB_PASS) or die('Unable to connect!');
    mysql_select_db(DB_NAME) or die('Unable to select database');
    $change  = "UPDATE subscriber SET birthdate = '$bdate', taxid = '$tax', email = '$email', homeaddress = '$haddress', homephoneno = '$hphoneno', 
                homefaxno = '$hfaxno', businessname = '$businessname', businessaddress = '$baddress', businessphoneno = '$ophoneno', 
                businessfaxno = '$ofaxno', zipcode = '$zip', cellphoneno = '$cellphone' WHERE username = '$id' ";
    $revised = mysql_query($change) or die("Error in query: $change. " . mysql_error());
    }
    
    
        
?>



------------------Here is the HTML code -------------------
<form action="<? echo $_SESSION['PHP_SELF']; ?>" method="POST">
<table width="750" border="0" cellspacing="0">
  <tr> 
    <td width="221"><div align="center"><font face="Tahoma, Verdana, Arial"><img src="mainlogo.JPG" width="177" height="109"></font></div></td>
    <td width="525" bgcolor="#CCCCCC"><img src="pic_side.jpg" width="525" height="200"></td>
  </tr>
</table>
<hr align="left" width="750">
  <font face="Tahoma, Verdana, Arial"> </font> 
  <? if(mysql_num_rows($result) > 0)
                  {
                    while($row = mysql_fetch_object($result)) {?>
  <table width="750" border="0" cellspacing="0">
    <tr> 
      <td><font size="-2" face="Tahoma, Verdana, Arial">DATE OF APPLICATION: (YYYY 
        - MM - DD)</font></td>
    </tr>
  </table>
  <table width="750" border="0" cellspacing="0">
    <tr> 
      <td><font face="Tahoma, Verdana, Arial"> 
        <input name="dateapplication" type="text" value="<? echo $row->dateapplication?>" size="13" readonly="true">
        </font></td>
    </tr>
  </table>
  <table width="750" border="0" cellspacing="0">
    <tr> 
      <td width="15%"><font size="-2" face="Tahoma, Verdana, Arial">LAST NAME:</font></td>
      <td width="11%"> </td>
      <td width="23%"><font size="-2" face="Tahoma, Verdana, Arial">FIRST NAME:</font></td>
      <td width="4%"> </td>
      <td width="43%"><font size="-2" face="Tahoma, Verdana, Arial">MIDDLE NAME:</font></td>
      <td width="4%"> </td>
    </tr>
  </table>
  <table width="750" border="0" cellspacing="0">
    <tr> 
      <td width="20%"><font face="Tahoma, Verdana, Arial"> 
        <input name="lname" type="text"  value="<? echo $row->lname ?>" readonly="">
        </font></td>
      <td width="6%"> </td>
      <td width="20%"><font face="Tahoma, Verdana, Arial"> 
        <input name="fname" type="text"  value="<? echo $row->fname ?>" readonly="">
        </font></td>
      <td width="7%"> </td>
      <td width="21%"><font face="Tahoma, Verdana, Arial"> 
        <input name="mname" type="text"  value="<? echo $row->mname ?>" readonly="">
        </font></td>
      <td width="20%"> </td>
      <td width="0%"> </td>
      <td width="0%"> </td>
      <td width="6%"> </td>
    </tr>
  </table>
  <table width="750" border="0" cellspacing="0">
    <tr> 
      <td width="26%"><font size="-2" face="Tahoma, Verdana, Arial">  </font></td>
      <td width="27%"><font size="-2" face="Tahoma, Verdana, Arial">  </font></td>
      <td width="47%"><font size="-2" face="Tahoma, Verdana, Arial">  </font></td>
    </tr>
  </table>
  <table width="750" border="0" cellspacing="0">
    <tr> 
      <td width="20%"><font size="-2" face="Tahoma, Verdana, Arial">BIRTHDATE:(YYYY-MM-DD)</font></td>
      <td width="6%"> </td>
      <td width="23%"><font size="-2" face="Tahoma, Verdana, Arial">GENDER:</font></td>
      <td width="4%"> </td>
      <td width="43%"><font size="-2" face="Tahoma, Verdana, Arial">CIVIL STATUS:</font></td>
      <td width="4%"> </td>
    </tr>
  </table>
  <table width="750" border="0" cellspacing="0">
    <tr> 
      <td width="20%"><font face="Tahoma, Verdana, Arial"> 
        <input name="bdate" type="text"  value="<? echo $row->birthdate ?>" size="13">
        </font></td>
      <td width="6%"> </td>
      <td width="20%"><font face="Tahoma, Verdana, Arial"> 
        <input name="gender" type="text"  value="<? echo $row->gender ?>" readonly="">
        </font></td>
      <td width="7%"> </td>
      <td width="21%"><font face="Tahoma, Verdana, Arial"> 
        <input name="stats" type="text"  value="<? echo $row->civilstatus ?>" readonly="">
        </font></td>
      <td width="20%"> </td>
      <td width="0%"> </td>
      <td width="0%"> </td>
      <td width="6%"> </td>
    </tr>
  </table>
  <table width="750" border="0" cellspacing="0">
    <tr> 
      <td><font size="-2" face="Tahoma, Verdana, Arial">  </font></td>
    </tr>
  </table>
  <table width="750" border="0" cellspacing="0">
    <tr> 
      <td width="26%"><font face="Tahoma, Verdana, Arial" size="-2" color="#000000">CORPORATE/PERSONAL 
        TAX ID NO. (IF FILIPINO)</font></td>
      <td width="74%"><font face="Tahoma, Verdana, Arial" size="-2">E-MAIL:</font></td>
    </tr>
  </table>
  <table width="750" border="0" cellspacing="0">
    <tr> 
      <td width="20%"><font face="Tahoma, Verdana, Arial"> 
        <input name="tax" type="text"  value="<? echo $row->taxid ?>">
        </font></td>
      <td width="6%"> </td>
      <td width="31%"><font face="Tahoma, Verdana, Arial"> 
        <input type="text" name="email" value="<? echo $row->email ?>">
        </font></td>
      <td width="12%"> </td>
      <td width="5%"><font face="Tahoma, Verdana, Arial">  </font></td>
      <td width="20%"> </td>
      <td width="0%"> </td>
      <td width="0%"> </td>
      <td width="6%"> </td>
    </tr>
  </table>
  <table width="750" border="0" cellspacing="0">
    <tr> 
      <td width="26%"><font size="-2" face="Tahoma, Verdana, Arial">  </font></td>
      <td width="74%"><font size="-2" face="Tahoma, Verdana, Arial">  </font></td>
    </tr>
  </table>
  <table width="750" border="1" cellspacing="0" bgcolor="#eeeeee">
    <tr> 
      <td nowrap><font size="2" face="Tahoma, Verdana, Arial"><strong><font size="-2"> 
        PERSONAL/INDIVIDUAL</font></strong></font></td>
    </tr>
  </table>
  <table width="750" border="0" cellspacing="0">
    <tr> 
      <td><font size="-2" face="Tahoma, Verdana, Arial">HOME ADDRESS:</font></td>
    </tr>
  </table>
  <table width="750" border="0" cellspacing="0">
    <tr> 
      <td width="48%"><font face="Tahoma, Verdana, Arial"> 
        <input name="haddress" type="text"  value="<? echo $row->homeaddress ?>" size="84" maxlength="80">
        </font></td>
    </tr>
  </table>
  <table width="750" border="0" cellspacing="0">
    <tr> 
      <td><font size="-2" face="Tahoma, Verdana, Arial">  </font></td>
    </tr>
  </table>
  <table width="750" border="0" cellspacing="0">
    <tr> 
      <td width="24%"><font size="-2" face="Tahoma, Verdana, Arial">HOME PHONE 
        NUMBER:</font></td>
      <td width="2%"> </td>
      <td width="69%"><font size="-2" face="Tahoma, Verdana, Arial">HOME FAX NUMBER:</font></td>
      <td width="5%"> </td>
    </tr>
  </table>
  <table width="750" border="0" cellspacing="0">
    <tr> 
      <td width="20%"><font face="Tahoma, Verdana, Arial"> 
        <input name="hphoneno" type="text"  value="<? echo $row->homephoneno ?>">
        </font></td>
      <td width="6%"> </td>
      <td width="20%"><font face="Tahoma, Verdana, Arial"> 
        <input name="hfaxno" type="text" value="<? echo $row->homefaxno ?>">
        </font></td>
      <td width="23%"> </td>
      <td width="5%"><font face="Tahoma, Verdana, Arial">  </font></td>
      <td width="20%"> </td>
      <td width="0%"> </td>
      <td width="0%"> </td>
      <td width="6%"> </td>
    </tr>
  </table>
  <table width="750" border="1" cellspacing="0" bgcolor="#eeeeee">
    <tr> 
      <td width="38%"> <div align="left"><font size="2" face="Tahoma, Verdana, Arial"><strong> 
          <font size="-2">COMPANY/CORPORATION</font> </strong></font></div></td>
    </tr>
  </table>
  <table width="750" border="0" cellspacing="0">
    <tr> 
      <td><font size="-2" face="Tahoma, Verdana, Arial">BUSINESS/OFFICE NAME:</font></td>
    </tr>
  </table>
  <table width="750" border="0" cellspacing="0">
    <tr> 
      <td width="48%"><font face="Tahoma, Verdana, Arial"> 
        <input name="businessname" type="text"  value="<? echo $row->businessname ?>" size="84" maxlength="80">
        </font></td>
      <td width="52%"> </td>
    </tr>
  </table>
  <table width="750" border="0" cellspacing="0">
    <tr> 
      <td><font size="-2" face="Tahoma, Verdana, Arial">  </font></td>
    </tr>
  </table>
  <table width="750" border="0" cellspacing="0">
    <tr> 
      <td><font size="-2" face="Tahoma, Verdana, Arial">BUSINESS/OFFICE ADDRESS:</font></td>
    </tr>
  </table>
  <table width="750" border="0" cellspacing="0">
    <tr> 
      <td width="48%"><font face="Tahoma, Verdana, Arial"> 
        <input name="baddress" type="text"  value="<? echo $row->businessaddress ?>" size="84" maxlength="80">
        </font></td>
      <td width="52%"> </td>
    </tr>
  </table>
  <table width="750" border="0" cellspacing="0">
    <tr> 
      <td width="24%"><font size="-2" face="Tahoma, Verdana, Arial">OFFICE PHONE 
        NUMBER:</font></td>
      <td width="2%"> </td>
      <td width="49%"><font size="-2" face="Tahoma, Verdana, Arial">OFFICE FAX 
        NUMBER:</font></td>
      <td width="25%"> </td>
    </tr>
  </table>
  <table width="750" border="0" cellspacing="0">
    <tr> 
      <td width="20%"><font face="Tahoma, Verdana, Arial"> 
        <input name="ophoneno" type="text"  value="<? echo $row->businessphoneno ?>">
        </font></td>
      <td width="6%"> </td>
      <td width="20%"><font face="Tahoma, Verdana, Arial"> 
        <input name="ofaxno" type="text"  value="<? echo $row->businessfaxno ?>">
        </font></td>
      <td width="7%"> </td>
      <td width="21%"><font face="Tahoma, Verdana, Arial">  </font></td>
      <td width="20%"> </td>
      <td width="0%"> </td>
      <td width="0%"> </td>
      <td width="6%"> </td>
    </tr>
  </table>
  <table width="750" border="0" cellspacing="0">
    <tr> 
      <td width="26%"><font size="-2" face="Tahoma, Verdana, Arial">ZIP CODE:</font></td>
      <td width="27%"><font face="Tahoma, Verdana, Arial" size="-2">CELLPHONE 
        NO.: </font></td>
      <td width="47%"> </td>
    </tr>
  </table>
  <table width="750" border="0" cellspacing="0">
    <tr> 
      <td width="20%"><font face="Tahoma, Verdana, Arial"> 
        <input name="zip" type="text"  value="<? echo $row->zipcode ?>">
        </font></td>
      <td width="6%"> </td>
      <td width="20%"><font face="Tahoma, Verdana, Arial"> 
        <input name="cellphone" type="text"  value="<? echo $row->cellphoneno ?>">
        </font></td>
      <td width="7%"> </td>
      <td width="21%"><font face="Tahoma, Verdana, Arial">  </font></td>
      <td width="20%"> </td>
      <td width="0%"> </td>
      <td width="0%"> </td>
      <td width="6%"> </td>
    </tr>
  </table>
  <table width="750" border="1" cellspacing="0" bgcolor="#eeeeee">
    <tr> 
      <td width="38%"> <div align="left"><font size="2" face="Tahoma, Verdana, Arial"><strong><font size="-2">SUBSCRIPTION 
          TYPE</font></strong></font></div></td>
    </tr>
  </table>
  <table width="750" border="0" cellspacing="0">
    <tr> <? $lrow = mysql_fetch_object($display) ?>
      <td width="11%"> <font size="-2" face="Tahoma, Verdana, Arial">SERVICE TYPE:</font></td>
      <td width="24%"><font face="Tahoma, Verdana, Arial"> 
        <input name="service" type="text"  value="<? echo $lrow->ServiceType ?>">
        </font></td>
      <td width="65%"><font size="-2" face="Tahoma, Verdana, Arial">  </font></td>
    </tr>
  </table>
  <table width="750" border="0" cellspacing="0">
    <tr> 
      <td><font size="-2" face="Tahoma, Verdana, Arial">  </font></td>
    </tr>
  </table>
  <table width="750" border="1" cellspacing="0" bgcolor="eeeeee">
    <tr> 
      <td> </td>
    </tr>
  </table>
  <p> 

  </p>
  <table width="750" border="0" cellspacing="0">
    <tr> 
      <td> <div align="right"><font face="Tahoma, Verdana, Arial"> 
         
          <input type="submit" name="submit" value="Update">
          </font></div></td>
    </tr>
    <? } ?>
  </table>
  <? }?>
</form>
</body>
</html>
[/div]

#8 massive

massive
  • Members
  • PipPipPip
  • Advanced Member
  • 40 posts

Posted 26 February 2006 - 01:51 PM

problem solved


i used:

if(isset($_POST['submit'])

instead of:

if($_POST['submit'])




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users