Hi,
Friday, March 7, 2003, 12:27:27 AM, you wrote:
SJ> Been on this a couple of hours... anyone see what I'm doing wrong?
SJ> I get a result of 1 when I echo $result but it doesn't want to update at
SJ> all.
SJ> The action of this form index.php?action=update-account is just a switch
SJ> case
SJ> Which asks you to use the function update_subscriber_account() below...
SJ> <form method='post' action='index.php?action=update-account'>
SJ> <input type='hidden' name='old_id' value='$email'>
SJ> <tr>
SJ> <th colspan = 2 bgcolor = '#5B69A6'>
SJ> $title
SJ> </th>
SJ> </tr>
SJ> <tr>
SJ> <td>Real Name:</td>
SJ> <td><input type = text name='new_realname' maxlength = 100
SJ> value ='$realname'></td>
SJ> </tr>
SJ> <tr>
SJ> <td>Preferred Name:</td>
SJ> <td><input type = text name='new_nickname' maxlength = 100
SJ> value ='$nickname'></td>
SJ> </tr>
SJ> <tr>
SJ> <td>Company:</td>
SJ> <td><input type = text name='new_company' maxlength = 100
SJ> value ='$company'></td>
SJ> </tr>
SJ> <tr>
SJ> <td>Email Address:</td>
SJ> <td><input type = text name='new_email' maxlength = 100
SJ> value ='$email'></td>
SJ> </tr>
SJ> <tr>
SJ> <td>Requested Email Format:</td>";
SJ> echo "<td><select name='new_mimetype'><option";
SJ> if ($mimetype == 'T')
SJ> echo " selected";
SJ> echo ">Text Only<option";
SJ> if ($mimetype == 'H')
SJ> echo " selected";
SJ> echo ">HTML</select></td>";
SJ> print "</tr>
SJ> <tr>
SJ> <td colspan=2 align=center>";
SJ> display_form_button('save-changes');
SJ> print "</td></tr></form></table></center><br>";
SJ> }
SJ> }
SJ> function update_subscriber_account()
SJ> {
SJ> db_connect();
SJ> $query = "update subscribers
SJ> set email = '$new_email',
SJ> nickname = '$new_nickname',
SJ> fullname = '$new_realname',
SJ> company = '$new_company',
SJ> mimetype = '$new_mimetype'
SJ> where email = '$old_id'";
SJ> $result = mysql_query($query)or die("Error: Could not update
SJ> query<BR>$query<BR>".mysql_error());
SJ> if (!$result)
SJ> {
SJ> echo "An error occurred when trying to update the DB";
SJ> }
SJ> else
SJ> {
SJ> echo "$result & Successfully updated the details";
SJ> }
SJ> }
You will need to use the global vars and also escape quotes like this:
function update_subscriber_account()
{
$new_email = addslashes($_POST['new_email']);
.
.
.
$query = "update subscribers
set email = '$new_email',
.
.
--
regards,
Tom
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php