Jump to content

Wont Update Info


LostNights

Recommended Posts

It wont update my information in the DB

[code]
<?php

$id = $_GET['id'];

    if (isset($_POST['submitbutton'])) {

mysql_connect('localhost','user','user') or die ("Cannot connect to server");

mysql_select_db("photodirectory") or die ("Cannot connect to database");

$query = "UPDATE corporatelist SET firstname='$_POST[firstname]', lastname='$_POST[lastname]',title='$_POST[title]',department='$_POST[department]',office='$_POST[office]',phone='$_POST[phone]' WHERE sku = '".$id."' ";
$result = mysql_query($query);

        if (!$result) {
            echo "There was a problem with your entry. <a href='infoupdate2.php'>Back</a>";
        } else {
            echo "Your information has been changed.";
        }
    } else {
?>
<?php echo $id; ?>
<form action="infoupdate2.php" method="post">

<p>First Name: <input type="text" maxlength="30" size="32" name="firstname" /></p>

<p>Last Name: <input type="text" maxlength="30" size="32" name="lastname" /></p>

<p>Job Title: <input type="text" maxlength="55" size="57" name="title" /></p>

<p>Department: <input type="text" maxlength="18" size="20" name="department" /></p>

<p>Office: <input type="text" maxlength="4" size="6" name="office" /></p>

<p>Phone Number: <input type="text" maxlength="4" size="6" name="phone" /></p>

<input type="submit" value="Enter Employee Information" name="submitbutton" />

</form>

<?php } ?>
[/code]
Link to comment
https://forums.phpfreaks.com/topic/9480-wont-update-info/
Share on other sites

When I change
[code]
$query = "UPDATE corporatelist SET firstname='$_POST[firstname]', lastname='$_POST[lastname]',title='$_POST[title]',department='$_POST[department]',office='$_POST[office]',phone='$_POST[phone]' WHERE sku = '".$id."' ";
[/code]

to
[code]
$query = "UPDATE corporatelist SET firstname='$_POST[firstname]', lastname='$_POST[lastname]',title='$_POST[title]',department='$_POST[department]',office='$_POST[office]',phone='$_POST[phone]' WHERE lastname = 'Benko' ";
[/code]

That changes it for the person whos last name is Benko, so its a problem with the variable.
Link to comment
https://forums.phpfreaks.com/topic/9480-wont-update-info/#findComment-35033
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.