Here's the form...
Code: Select all
<form method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>">
<br />Choose your profile picture or start looking after your pet horse<br />
Horse <input type="radio" name="1horse" value="1"/><br />
Cat <input type="radio" name="2cat" value="2"/><br />
Dog <input type="radio" name="3dog" value="3"/><br />
<input type="submit" name="pet_submit" />
</form>Code: Select all
// Collects data from "horse" table
$horse_profile_pic_query2 = mysql_query("SELECT * FROM users WHERE id='$member_id'")
or die(mysql_error());
// puts the "users" info into the an array
$horse_profile_pic_result2 = mysql_fetch_array( $horse_profile_pic_query2 );
if ( $horse_profile_pic_result2['profile_pic_id'] == 1) {
echo "<br /><br /><img src=\"a/images/1horse.jpg\" />";
} elseif ( $horse_profile_pic_result2['profile_pic_id'] == 2) {
echo "<br /><br /><img src=\"a/images/2cat.jpg\" /><br />";
include "a/inc/profile-pic-form.php";
} elseif ( $horse_profile_pic_result2['profile_pic_id'] == 3) {
echo "<br /><br /><img src=\"a/images/3dog.jpg\" />";
include "a/inc/profile-pic-form.php";
} else {
echo "<br /><br /><img src=\"a/images/7default.jpg\" /><br />";
include "a/inc/profile-pic-form.php";
}
Code: Select all
// if value is submitted insert into database
if (isset($_POST['1horse'])) {
//set $image to chosen value
$image = $_POST['1horse'];
//update $users table with chosen value
mysql_query("UPDATE users SET profile_pic_id = $image WHERE username = '$member_username'");
} elseif (isset($_POST['2cat'])) {
//set $image to chosen value
$image = $_POST['2cat'];
//update $users table with chosen value
mysql_query("UPDATE users SET profile_pic_id = $image WHERE username = '$member_username'");
} elseif (isset($_POST['3dog'])) {
//set $image to chosen value
$image = $_POST['3dog'];
//update $image table with chosen value
mysql_query("UPDATE users SET profile_pic_id = $image WHERE username = '$member_username'");
} Thanks