Hello,
I'm sorry, but because I can not figure out what to do a search on, I have not done a search, but I cannot figure something out.
I am building an online inventory system and I have a profile section and edit all. I then display a form which displays defaut values which are what is currently in the database. You can select a check box that tells the database that the billing information should match the shipping information, so the user does not have to fill in the same information twice. There are 8 fields that this applies to (ship_field1-ship_field8 and bill_field1-bill_field8).
The problem I am having is that this is only working for one field...the phone number field. Any help as to what might be causing this could help. Below is the php code for the edit_profile_all.php page. Further, you may test the problem for yourselves at www.godsbible.org/inventory
please create an account, or sign in with user and pass as the username and password according.
Now the code:
<?
session_start();
if ( empty( $first_name ) ) {
?> Welcome Guest, You Can Login <a href="index.htm">Here</a>, Or Signup For Your
Free Account
<?
} else {include 'nav.php'; include 'db.php'; echo "Welcome,
". $_SESSION['first_name'] .". ";
//Get the profile details
$profile = "_profile";
$company2 = $company;
$company2 = eregi_replace(' ', "_", $company2);
$company_profile = $company2 . $profile;
$result = mysql_query("SELECT * FROM $company_profile") or die(mysql_error());
//Display the items
$row = mysql_fetch_array( $result );
$name = $row['name'];
$ship_add11 = $row['ship_add1'];
$ship_add21 = $row['ship_add2'];
$ship_add31 = $row['ship_add3'];
$ship_city1 = $row['ship_city'];
$ship_state1 = $row['ship_state'];
$ship_zip1 = $row['ship_zip'];
$ship_phone1 = $row['ship_phone'];
$ship_fax1 = $row['ship_fax'];
$contact_fname1 = $row['contact_fname'];
$contact_lname1 = $row['contact_lname'];
$contact_email1 = $row['contact_email'];
$bill_add11 = $row['bill_add1'];
$bill_add21 = $row['bill_add2'];
$bill_add31 = $row['bill_add3'];
$bill_city1 = $row['bill_city'];
$bill_state1 = $row['bill_state'];
$bill_zip1 = $row['bill_zip'];
$bill_phone1 = $row['bill_phone'];
$bill_fax1 = $row['bill_fax'];
//For the submission of changed data.
if(isset($_POST['edit']))
{
if($sameas=="yes")
{
$bill_add1 = $ship_add1;
$bill_add2 = $ship_add2;
$bill_add3 = $ship_add3;
$bill_city = $ship_city;
$bill_state = $ship_state;
$bill_zip = $ship_zip;
$bill_phone = $ship_phone;
$bill_fax = $ship_fax;
}
$name = $_POST['name'];
$ship_add1 = $_POST['ship_add1'];
$ship_add2 = $_POST['ship_add2'];
$ship_add3 = $_POST['ship_add3'];
$ship_city = $_POST['ship_city'];
$ship_state = $_POST['ship_state'];
$ship_zip = $_POST['ship_zip'];
$ship_phone = $_POST['ship_phone'];
$ship_fax = $_POST['ship_fax'];
$bill_add1 = $_POST['bill_add1'];
$bill_add2 = $_POST['bill_add2'];
$bill_add3 = $_POST['bill_add3'];
$bill_city = $_POST['bill_city'];
$bill_state = $_POST['bill_state'];
$bill_zip = $_POST['bill_zip'];
$bill_bill_phone = $_POST['bill_phone'];
$bill_fax = $_POST['bill_fax'];
$contact_fname = $_POST['contact_fname'];
$contact_lname = $_POST['contact_lname'];
$contact_email = $_POST['contact_email'];
$sameas = $_POST['sameas'];
//take dashes out of phone numbers to preserve data integrity
$ship_phone = eregi_replace('-', "", $ship_phone);
$ship_fax = eregi_replace('-', "", $ship_fax);
$bill_phone = eregi_replace('-', "", $bill_phone);
$bill_fax = eregi_replace('-', "", $bill_fax);
//Changes Data In Table
mysql_query("UPDATE $company_profile SET
ship_add1='$ship_add1', ship_add2='$ship_add2',
ship_add3='$ship_add3', ship_city='$ship_city',
ship_state='$ship_state', ship_zip='$ship_zip',
ship_phone='$ship_phone', ship_fax='$ship_fax',
contact_fname='$contact_fname',
contact_lname='$contact_lname', contact_email='$contact_email',
bill_add1='$bill_add1', bill_add2='$bill_add2',
bill_add3='$bill_add3', bill_city='$bill_city', bill_state='$bill_state',
bill_zip='$bill_zip', bill_phone='$bill_phone', bill_fax='$bill_fax'
WHERE name='$namea' ") or die(mysql_error());
echo "$namea has been edited.<br/>";
echo "<br /><br /><br />";
include 'profile_nonav.php';
}
else
{
?>
<br><br>
<form method="post">
<table border=1>
<th colspan="2">Edit <? echo $name; ?> information.</th>
<tr>
<td>Company Name<br>(User cannot edit<br>this field.)</td>
<td><? echo $name; ?></td>
</tr>
<tr>
<td>Contact First Name</td>
<td><input name="contact_fname" id="contact_fname" value="<? echo $contact_fname1; ?>"></td>
</tr>
<td>Contact Last Name</td>
<td><input name="contact_lname" id="contact_lname" value="<? echo $contact_lname1; ?>"></td>
</tr>
<tr>
<td>Contact Email Address</td>
<td><input name="contact_email" id="contact_email" value="<? echo $contact_email1; ?>"></td>
</tr>
<tr>
<td>Shipping Information</td>
<td></td>
</tr>
<tr>
<td>Address 1:</td>
<td><input name="ship_add1" id="ship_add1" value="<? echo $ship_add11; ?>"></td>
</tr>
<tr>
<td>Address 2:</td>
<td><input name="ship_add2" id="ship_add2" value="<? echo $ship_add21; ?>"></td>
</tr>
<tr>
<td>Address 3:</td>
<td><input name="ship_add3" id="ship_add3" value="<? echo $ship_add31; ?>"></td>
</tr>
<tr>
<td>City</td>
<td><input name="ship_city" id="ship_city" value="<? echo $ship_city1; ?>"></td>
</tr>
<tr>
<td>State</td>
<td><input name="ship_state" id="ship_state" value="<? echo $ship_state1; ?>"></td>
</tr>
<tr>
<td>ZipCode</td>
<td><input name="ship_zip" id="ship_zip" value="<? echo $ship_zip1; ?>"></td>
</tr>
<tr>
<td>Phone Number</td>
<td><input name="ship_phone" id="ship_phone" value="<? echo $ship_phone1; ?>"></td>
</tr>
<tr>
<td>Fax Number</td>
<td><input name="ship_fax" id="ship_fax" value="<? echo $ship_fax1; ?>"></td>
</tr>
<tr>
<td>Billing Information</td>
<td><input type="checkbox" name="sameas" id="sameas" value="yes">Click this box if same as above.</td>
</tr>
<tr>
<td>Address 1:</td>
<td><input name="bill_add1" id="bill_add1" value="<? echo $bill_add11; ?>"></td>
</tr>
<tr>
<td>Address 2:</td>
<td><input name="bill_add2" id="bill_add2" value="<? echo $bill_add21; ?>"></td>
</tr>
<tr>
<td>Address 3:</td>
<td><input name="bill_add3" id="bill_add3" value="<? echo $bill_add31; ?>"></td>
</tr>
<tr>
<td>City</td>
<td><input name="bill_city" id="bill_city" value="<? echo $bill_city1; ?>"></td>
</tr>
<tr>
<td>State</td>
<td><input name="bill_state" id="bill_state" value="<? echo $bill_state1; ?>"></td>
</tr>
<tr>
<td>ZipCode</td>
<td><input name="bill_zip" id="bill_zip" value="<? echo $bill_zip1; ?>"></td>
</tr>
<tr>
<td>Phone Number</td>
<td><input name="bill_phone" id="bill_phone" value="<? echo $bill_phone1; ?>"></td>
</tr>
<tr>
<td>Fax Number</td>
<td><input name="bill_fax" id="bill_fax" value="<? echo $bill_fax1; ?>"></td>
</tr>
<tr>
<td width="100"> </td>
<td> </td>
</tr>
<tr>
<td><input name="edit" type="submit" id="edit" value="Submit Changes"></td>
<td><input type="reset" value="Cancel"></td>
</tr>
</table>
</form>
<br><br>
<?
}
}
?>
The same is attached to this thread as a .txt