Jump to content

having trouble getting form to update database


scmeeker

Recommended Posts

When the update button is clicked, it access this code to update the table BUT its not updating the table.  No information is changed and just goes back to what was there on the previous page.  The username is the session variable.

 

Any suggestions??

 

 

$item_bio = mysql_real_escape_string($_POST[bio]);;
$item_other_artists = mysql_real_escape_string($_POST[other_artists]);




$sql="UPDATE store SET bio = '$item_bio', other_artists = '$item_other_artists' WHERE username = '".$_GET["username"]."'";

if (!mysql_query($sql))

  {

  die('Error: ' . mysql_error());

  } 


header("location:update.php?username=".$_SESSION['username']."");

Link to comment
Share on other sites

Okay, I changed that. Then when I clicked the "update" button, it cleared out the data in the database that was in the "bio" and "other_artists" and came up blank.  So now it is communicating but not updating the information.  Hmmmm...any other suggestions?

 

I'm going to post the form too.  Can I send the session variable through the "form action"?  How would I do that?

 

<form action=artist_profile_update.php>

<br />
<span class="titles">bio</span><br />
<span class="smallfont">ignore this</span><br />
<p> <textarea name="bio" rows=10 cols=90><?php echo $display_block = "$item_bio" ?></textarea></p>
<br />
<span class="titles"></span><br />
<span class="smallfont"> ignore</span><br />
<p> <textarea name="other_artists" rows=10 cols=90><?php echo $display_block = "$item_other_artists" ?></textarea></p>
<br />
<br />
<input type="submit" name="Submit" value="Update">
</form>

Link to comment
Share on other sites

I'm not clear on how this form fits into things, but you can pass a form item using a hidden field if you're just looking for a way to get it out through the POST variables.  There's no advantage to that over reading it directly from the $_SESSION, and often people are doing that help with security.

 

These statements don't make any sense:

 


 

Either echo $display_block or $item_bio.  Don't know where those variables are suppossed to get their values from, as their not in evidence in the script, and thus would be empty and not set.

Link to comment
Share on other sites

Okay, I changed that. Then when I clicked the "update" button, it cleared out the data in the database that was in the "bio" and "other_artists" and came up blank.  So now it is communicating but not updating the information.  Hmmmm...any other suggestions?

 

I'm going to post the form too.  Can I send the session variable through the "form action"?  How would I do that?

 

<form action=artist_profile_update.php>

<br />
<span class="titles">bio</span><br />
<span class="smallfont">ignore this</span><br />
<p> <textarea name="bio" rows=10 cols=90><?php echo $display_block = "$item_bio" ?></textarea></p>
<br />
<span class="titles"></span><br />
<span class="smallfont"> ignore</span><br />
<p> <textarea name="other_artists" rows=10 cols=90><?php echo $display_block = "$item_other_artists" ?></textarea></p>
<br />
<br />
<input type="submit" name="Submit" value="Update">
</form>

 

If the form cleared the values from the database fields, that would indicate the $item_bio and $item_other_artists variables contain no values. The UPDATE query is then setting those field values to match.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.