Jump to content

[SOLVED] php text form update help


Jiraiya

Recommended Posts

I need help creating this php updating form its supposed to update a pic url with a new one that is submitted by a html form i what i have is shown below

 

 

<form>
Picture URL:
<input type="text" pic="pic" />
<input type="submit" value="Submit" />
</form> 
<br />

</form> 
<?php

$username = $_COOKIE['ID_my_site']; 
mysql_connect("mysql", "username", "password") or die(mysql_error());
mysql_select_db("members") or die(mysql_error());


$sql = mysql_query("UPDATE users SET `pic` = name") or die(mysql_error());



?>

Link to comment
Share on other sites

1. In your INPUT tag, what's pic="pic"? Did you mean name="pic"?

2. What's name in your SQL - UPDATE users SET `pic` = name?

 

<form method="post">
Picture URL:
<input type="text" name="pic" />
<input type="submit" name="submit" value="Submit" />
</form>
<br />

</form>
<?php
if (isset($_POST['submit'])) {
$username = $_COOKIE['ID_my_site']; 
mysql_connect("mysql", "username", "password") or die(mysql_error());
mysql_select_db("members") or die(mysql_error());

$pic = mysql_real_escape_string($_POST['pic']);
$sql = mysql_query("UPDATE users SET `pic` = $pic WHERE username='$username'") or die(mysql_error());
}

?

Link to comment
Share on other sites

Well, I wasn't sure how to put it. If your SQL is just -

$sql = mysql_query("UPDATE users SET `pic` = $pic") or die(mysql_error());

 

then that would modify the pic for all users! I'm sure you only want to update one right?

Link to comment
Share on other sites

Hmm...

<form method="post">
Picture URL:
<input type="text" name="pic" />
<input type="submit" name="submit" value="Submit" />
</form>
<br />

</form>
<?php
if (isset($_POST['submit'])) {
$username = $_COOKIE['ID_my_site'];
mysql_connect("mysql", "username", "password") or die(mysql_error());
mysql_select_db("members") or die(mysql_error());

$pic = mysql_real_escape_string($_POST['pic']);
$username = mysql_real_escape_string($username);
$sql = "UPDATE users SET `pic` = '$pic' WHERE username='$username'";
$result = mysql_query($sql) or die(mysql_error());
}

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.