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
https://forums.phpfreaks.com/topic/159976-solved-php-text-form-update-help/
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());
}

?

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());
}

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.