Jump to content

[SOLVED] why will this not work?


squiblo

Recommended Posts

ive messed about with this code for ages now but i cant get it to work, can anyone see the problem? there are no errors. The problem is that, it is always echoing from the database but when i change it in the form, it still echoes the same things from the database

 

<style>
table.pagecontent {
background-color: <?php if (!isset($_GET['bgcolor'])){
?>
<?php

$_SESSION['myusername'];

$connect = mysql_connect("***","***","***") or die ("Couldn't connect");
mysql_select_db("***") or die ("Couldn't find db");

$username = isset($_SESSION['myusername']) ? $_SESSION['myusername'] : 'default_value';

$query = mysql_query("SELECT * FROM members WHERE username='$username'");
if (mysql_num_rows($query)==0){
   die;
}else{
   $row = mysql_fetch_assoc($query);
   $location = $row['bgcolor'];
   if($location == ""){
      echo "";
   }else{
      echo $location;
   }
}
?>
<?php
}
else
echo ($_GET['bgcolor']);
?>
}
</style>

<form name="bgcolor" method="GET" action="">
Background color:<br>
<select name="bgcolor"><option selected></option>
<option style="background-color:#F0F8FF; color: #000000;">AliceBlue</option>
<option style="background-color:#FAEBD7; color: #000000;">AntiqueWhite</option>
<option style="background-color:#00FFFF; color: #000000;">Aqua</option>
<input type="submit" name="bgcolor" value="Change"></form>
</form>

Link to comment
https://forums.phpfreaks.com/topic/172365-solved-why-will-this-not-work/
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.