On Aug 27, 2008, at 12:06 PM, Jason Pruim wrote:
Hi Everyone,
So I'm working on a project (Same one I sent the question about
regarding the user access rights on monday) And now I am attempting
to update the record... Here is some of my code:
index.php
<?PHP
<form method="post" action="purlprocess.php">
First Name/Last Name<input type="text" name="txtFName"
value="{$row['FName']}" $edit> <input type="text" name="txtLName"
value="{$row['LName']}" $edit><br>
Email Address <input type="text" name="txtEmail"
value="{$row['email']}" $edit><br>
Company name <input type="text" name="txtBusiness"
value="{$row['Business']}" $edit><br>
Company Address <input type="text" name="txtAddress1"
value="{$row['Address1']}" $edit><br>
City/State/Zip <input type="text" name="txtCity"
value="{$row['City']}" $edit> <input type="text" name="txtState"
value="{$row['State']}" $edit> <input type="text" name="txtZip"
value="{$row['Zip']}" $edit><br>
Phone <input type="text" name="txtPhone" value="{$row['phone']}"
$edit><br>
Your Favorite Type of coffee: <input type="radio" name="rdoCoffee"
value="Starbucks"> <img src="../media/starbucks.jpeg" width="10%">
<input type="radio" name="rdoCoffee" value="Folgers"> <img src="../
media/folgers.jpeg" width="10%"> <input type="radio"
name="rdoCoffee" value="Other"> Other: <input type="text"
name="txtCoffee" size="20"><br>
When would a good time to bring it over be? <input type="text"
name="txtMeeting"><br>
<input type="submit" value="Yes! Give me the caffeine!">
<input type="hidden" name="Record" value="{$row['record']}">
</p>
</form>
?>
purlprocessing.php
<?PHP
$FName= $_POST['txtFName'];
$LName= $_POST['txtLName'];
$Email= $_POST['txtEmail'];
$Business = $_POST['txtBusiness'];
$Address1 = $_POST['txtAddress1'];
$City = $_POST['txtCity'];
$State = $_POST['txtState'];
$Zip = $_POST['txtZip'];
$CoffeeChoicetest = $_POST['rdoCoffee'];
//$Coffee = $_POST['txtCoffee'];
$Phone = $_POST['txtPhone'];
$Record = $_POST['Record'];
$Meeting = $_POST['txtMeeting'];
$date = time();
$IPAddress = $_SERVER['REMOTE_ADDR'];
if ($CoffeeChoicetest == "Other"){
$Coffee = $_POST['txtCoffee'];
}else{
$Coffee = $_POST['rdoCoffee'];
}
$sql = "UPDATE `schreur` set FName='{$FName}', LName='{$LName}',
email='{$Email}', Business='{$Business}', Address1='{$Address1}',
City='{$City}', State='{$State}', Zip='{$Zip}', Coffee='{$Coffee}',
subscribed='0', date='{$date}', IPAddress='{$IPAddress}',
Meeting='{$Meeting}' WHERE record='{$Record}'";
mysqli_query($link, $sql) or die("Could not update..." .
mysqli_error($link));
?>
mysql> describe schreur;
+------------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------+-------------+------+-----+---------+-------+
| FName | varchar(20) | YES | | NULL | |
| LName | varchar(20) | YES | | NULL | |
| email | varchar(50) | YES | | NULL | |
| phone | varchar(12) | YES | | NULL | |
| url | int(12) | YES | | NULL | |
| record | int(7) | YES | | NULL | |
| subscribed | int(1) | NO | | | |
| date | varchar(12) | YES | | NULL | |
| IPAddress | varchar(19) | YES | | NULL | |
| Business | varchar(20) | YES | | NULL | |
| Address1 | varchar(50) | YES | | NULL | |
| City | varchar(20) | YES | | NULL | |
| State | varchar(2) | YES | | NULL | |
| Zip | varchar(10) | YES | | NULL | |
| Coffee | varchar(20) | YES | | NULL | |
| Meeting | text | YES | | NULL | |
+------------+-------------+------+-----+---------+-------+
The problem is when I am attempting to update some of the info, it
erases the info in the field.
Anyone got a clue as to what is going on? :)
Thanks for looking!
Okay so I should have looked just a little bit longer before sending
the e-mail... the $edit var that is in some of the text fields either
contains NULL or "disabled" depending on an editing flag... disabled
fields don't get passed back to the script and so it sets the fields
to NULL... Now I just need to figure out how to overcome that
limitation...
What I'm trying to do, is if the text they are presented with is
correct, don't give them the ability to "accidentally" edit it. Make
them have to click a link to enable editing. It makes it a more
intentional method, and hopefully will keep the bots out a LITTLE bit
if they find the form and the pURL's...
--
Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
11287 James St
Holland, MI 49424
www.raoset.com
japruim@xxxxxxxxxx
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php