Change a value in a MYSQL database

Soldato
Joined
10 May 2004
Posts
3,790
Location
East Yorkshire, UK
Hi

I have this script of what you see when you in a MYSQL database

Code:
  <?
$conn = mysql_connect("localhost","watotron_infraon","12345");
$db = mysql_select_db("watotron_infraone");

$username = $_POST["username"];
$password = $_POST["password"];

$result = MYSQL_QUERY("SELECT * from form WHERE username='$username'and password='$password'")
   or die ("username or password are incorrect");

$worked = mysql_fetch_array($result);

$username = $worked[username];
$password = $worked[password];
$forename = $worked[forename];
$othernames = $worked[othernames];
$plan = $worked[plan];

if($worked)
   echo "Welcome $forename $othernames! Your current plan is $plan"; 
?>

Is it possible to change the value of $plan to something else? So it says

What would you like your new plan to be?

Thanks
 
on the signup form they have already specified their plan. This is then stored in the database. In this page i want to give them the option of changing what is in the database
 
thats exactly what i want, however when I add it I get

Parse error: syntax error, unexpected T_STRING in /home/watotron/public_html/School/Project/InfraOne/welcome.php on line 114

this is the current code

Code:
  <?
$conn = mysql_connect("localhost","watotron_infraon","12345");
$db = mysql_select_db("watotron_infraone");

$username = $_POST["username"];
$password = $_POST["password"];

$result = MYSQL_QUERY("SELECT * from form WHERE username='$username'and password='$password'")
   or die ("username or password are incorrect");

$worked = mysql_fetch_array($result);

$username = $worked[username];
$password = $worked[password];
$forename = $worked[forename];
$othernames = $worked[othernames];
$plan = $worked[plan];

if($worked)
   echo "Welcome $forename $othernames! Your current plan is $plan"; 
   UPDATE form SET plan = '$plan' WHERE username = '$username'
?>
 
thx for reply
ok ive tried setting it up, but its coming up with this error

Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /home/watotron/public_html/School/Project/InfraOne/welcome.php on line 121

heres the code

Code:
<?PHP
$username = $_POST["username"];
$password = $_POST["password"];

$result = MYSQL_QUERY("SELECT * from form WHERE username='$username'and password='$password'")
   or die ("username or password are incorrect");

$worked = mysql_fetch_array($result);

$forename = $worked[forename];
$othernames = $worked[othernames];
if($worked)
   echo "Welcome $forename $othernames!; 
   ?>
   
  <hl> 
  </span>


  <form action="" method="post">
     <p class="style6">
	 Plan:
      <label>
        <select name="plan" class="box1" id="plan">
          <option>Starter</option>
          <option>Pro</option>
          <option>Premier</option>
          <option>Business</option>
        </select>
        </label>
      <label>
      <input name="submit" type="submit" class="box2" value="Submit!" />
      </label>
    </p>
  </form>
	
      <?php
  } else {
  $plan = $_POST['plan'];
 $result = mysql_query("INSERT INTO form (plan) VALUES ('$plan')");

if(!$result) {
   die(mysql_error());
} else {
   echo "Thanks you, your hosting has been updated.";
}
}
?>
 
Back
Top Bottom