updating database with password

This is a discussion on "updating database with password" within the PHP Forum section. This forum, and the thread "updating database with password are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > PHP Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Oct 23rd, 2006, 18:53
Junior Member
Join Date: Jun 2006
Location: usa
Age: 29
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Exclamation updating database with password

Ok I want my users to update their row when they typed in their user name and password..

The problem is that i want the user to see what is in the database let's say that they made a typo when they first intruduce their info and they want to fix it or add more data to what is already there...

here is my script

PHP: Select all

 
<?php
$host     
"localhost";
$username "localhost";
$password "abc123";
$database "contacts";
$db mysql_connect($host$username$password) or die(mysql_error()); 
mysql_select_db($database) or die(mysql_error()); 
$BusinessName = (isset($_POST['BusinessName']) ? $_POST['BusinessName'] : ''); 
$Slogan = (isset($_POST['Slogan']) ? $_POST['Slogan']:'');
$Business_Address = (isset($_POST['Business_Address']) ? $_POST['Business_Address']:'');
$Tel = (isset($_POST['Tel']) ? $_POST['Tel']:'');
$Website = (isset($_POST['Website']) ? $_POST['Website']:'');
$Email = (isset($_POST['Email']) ? $_POST['Email']:'');
$Member_Status = (isset($_POST['Member_Status']) ? $_POST['Member_Status']:'');
$Fax =(isset($_POST['Fax']) ? $_POST['Fax']:'');
$type = (isset($_POST['type']) ? $_POST['type']:'');
$make = (isset($_POST['make']) ? $_POST['make']:'');
$Categories = (isset($_POST['Categories']) ? $_POST['Categories']:'');
$Keyword = (isset($_POST['Keyword']) ? $_POST['Keyword']:'');
$Picture1 =  (isset($_POST['Picture1']) ? $_POST['Picture1']:'');
$Headline =  (isset($_POST['Headline']) ? $_POST['Headline']:'');
$Slogan2 = (isset($_POST['Slogan2']) ? $_POST['Slogan2']:'');
$Description1 = (isset($_POST['Description1']) ? $_POST['Description1']:'');
$Description2 = (isset($_POST['Description2']) ? $_POST['Description2']:'');
$Description3= (isset($_POST['Description3']) ? $_POST['Description3']:'');
$Contact2 = (isset($_POST['Contact2']) ? $_POST['Contact2']:'');
$Picture2 =  (isset($_POST['Picture2']) ? $_POST['Picture2']:'');
$Picture3 = (isset($_POST['Picture3']) ? $_POST['Picture3']:'');
$Picture4 =  (isset($_POST['Picture4']) ? $_POST['Picture4']:'');
$User_Name = (isset($_POST['User_Name']) ? $_POST['User_Name']:'');
$Password = (isset($_POST['Password']) ? $_POST['Password']: '');
$user = (isset($_POST['User_Name']) ? $_POST['User_Name']:'');
if (isset(
$_POST['submit']))  {
  foreach (
$_POST as $key => $val) {
    $
$key mysql_real_escape_string($val);
  }
  
$q "SELECT `Password` FROM business_info WHERE User_Name = '$user'";
  
$sql mysql_query($q) or die(mysql_error() . "<br />$q");
  if (
mysql_num_rows($sql) == 1) {
    
$confPass mysql_result($sql0'Password');
    if (
$Password == $confPass) {
 
   
$query "UPDATE  business_info SET `BusinessName`= '$BusinessName', `Slogan`='$Slogan', " .
               
"`Business_Address`='$Business_Address', `Tel`='$Tel', `Website`='$Website', " .
               
"`Email`='$Email', `Member_Status`='$Member_Status', `Fax`='$Fax', `type`='$type', " .
               
"`make`='$make', `Categories`='$Categories', `Keyword`='$Keyword', `Picture1`='$Picture1', " .
               
"`Headline`='$Headline', `Slogan2`='$Slogan2', `Description1`='$Description1', " .
               
"`Description2`='$Description2', `Description3`= '$Description3', `Contact2`='$Contact2', " .
               
"`Picture2`='$Picture2', `Picture3`='$Picture3', `User_Name` ='$user', " 
               
"`Password`='$Password' WHERE `User_Name`='$user'";
 
     if (!
mysql_query($query)) {
        echo 
"Couldn't update!<br />" mysql_error();
      } else {
        echo 
"Record updated!";
      }
    } 
 
 else 
 {
 
      echo 
"$pass != $confPass";
    }
  } else {
    
// didn't get any records
    
echo "No records for query: <b>$q</b>";
  }
}
?>
here is my form

PHP: Select all

 
 
 
     
</td>
  </
tr>
  <
tr
    <
td background="../images/fondo2.jpg" bgcolor="#999966"><div align="center"><strong>Business Info</strong></div></td>
  </
tr>
  <
tr
    <
td><table width="100%" border="0" cellspacing="1" cellpadding="1">
        <
tr
          <
td width="17%">Business Name</td>
          <
td width="22%"><input type="text" name="BusinessName" value=""></td>
          <
td width="16%">Status</td>
          <
td width="45%"><input type="text" name="Member_Status" value=""></td>
        </
tr>
        <
tr
          <
td>Slogan</td>
          <
td><input type="text" name="Slogan"value=""></td>
          <
td>Website</td>
          <
td><input type="text" name="Website"></td>
        </
tr>
        <
tr
          <
td>Tel</td>
          <
td><input type="text" name="Tel" value=""></td>
          <
td>Key Words</td>
          <
td><input type="text" name="Keyword"value=""></td>
        </
tr>
        <
tr
          <
td>Fax</td>
          <
td><input type="text" name="Fax" value=""></td>
          <
td>Address</td>
          <
td><input type="text" name="Business_Address" value=""></td>
        </
tr>
      </
table></td>
  </
tr>
  <
tr
    <
td>
 
 <
table width="101%" height="35" border="0" cellpadding="0" cellspacing="0">
        <
tr
          <
td width="13%">State</td>
          <
td width="7%"> <select name="make" style="width:160px;"></td>
 
          <
td width="16%">City</td>
          <
td width="8%"><select name="type" style="width:160px;">
                  </
select>
 
      </
td>
          <
td width="9%">Category</td>
          <
td width="16%"><input type="text" name="Categories" value=""> </td>
 
        </
tr>
      </
table><br>
   <
table width="100%" border="0" cellspacing="1" cellpadding="1">
        <
tr
          <
td background="../images/fondo2.jpg" bgcolor="#CCCCCC"><div align="center"><strong><font color="#000000">Business 
                          Webpage
</font></strong></div></td>
        </
tr>
        <
tr
          <
td>Headline</td>
        </
tr>
        <
tr
          <
td><input type="text" name="Headline" value=""></td>
        </
tr>
        <
tr
          <
td>Slogan </td>
        </
tr>
        <
tr
          <
td><input type="text" name="Slogan2" value=""></td>
        </
tr>
        <
tr
                      <
td>Description1 </td>
        </
tr>
        <
tr
          <
td><TEXTAREA ROWS=5 COLS=65 NAME="Description1"></TEXTAREA></td>
        </
tr>
        <
tr
          <
td>Description2</td>
        </
tr>
        <
tr
          <
td><TEXTAREA ROWS=5 COLS=65 NAME="Description2"></TEXTAREA></td>
        </
tr>
        <
tr
          <
td>Description3</td>
        </
tr>
        <
tr
          <
td><TEXTAREA ROWS=5 COLS=65 NAME="Description3" value=""></TEXTAREA></td>
        </
tr>
        <
tr
          <
td>Contact
            
<TEXTAREA ROWS=3 COLS=40 NAME="Contact2" value=""></TEXTAREA></td>
        </
tr>
        <
tr
          <
td>
 
 
           
Picture1 
     
<input name="Picture1" type="file">
 
 
     </
td>
        </
tr>
        <
tr
          <
td>
    </
td>
        </
tr>
        <
tr
          <
td></td>
        </
tr>
        <
tr>
          <
td><table width="100%" border="1" cellspacing="1" cellpadding="1">
              <
tr>
                <
td>User Name</td>
                <
td>Username: <input type="text" name="User_Name" /></td>
                <
td>Password</td>
                <
td><input type="password" name="Password" /></td>
              </
tr>
            </
table></td>
        </
tr>
      </
table> </td>
  </
tr>
  <
tr
    <
td background="../images/fondo2.jpg"> <div align="right">
       <
input type="submit" name="submit" value="Login" />
        <
input type="reset" value="Reset fields" />
      </
div><td>
  </
form>
</
table></td>
          <
td width="6%" valign="top" bgcolor="#FFFFFF">&nbsp;</td>
        </
tr>
      </
table></td>
  </
tr>
</
table>
  </
tr>
<
body
help please
Reply With Quote

  #2 (permalink)  
Old Oct 23rd, 2006, 23:30
Up'n'Coming Member
Join Date: Feb 2006
Location: London
Age: 25
Posts: 98
Thanks: 0
Thanked 0 Times in 0 Posts
Re: updating database with password

do a select query on the database before the form...

SELECT * FROM whatever WHERE something = something

and then for the input boxes, use a value field with the variable from the mysql row:

<input type="text" name="Website" value="$website">

that will work for everything but a textarea, which is as follows:

<textarea rows=5 cols=65 name="Description1">$description1</textarea>

I hope I understood you correctly!

Cheers,
Jim.
Reply With Quote
Reply

Tags
updating database

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Need help with Username and Password database.!asap tcpodg PHP Forum 8 Sep 26th, 2007 14:12
updating database franknu PHP Forum 4 Oct 8th, 2006 20:32
updating a database using a drop down barnet Classic ASP 4 Jan 18th, 2006 01:28
Updating Database Using ASP and XML cmomah Classic ASP 0 Oct 12th, 2005 20:22
Updating Database Through XML cmomah Other Programming Languages 0 Oct 12th, 2005 20:21


All times are GMT. The time now is 21:04.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43