First I just want to say I know I am using old mysql code for this. I am going to use mysqli and fix whatever else that may be old. I haven't used mysql for years and I am stumped on this code. I have a database
+-----------+-------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-----------+-------------+------+-----+---------+----------------+
| user_id | int(11) | NO | PRI | NULL | auto_increment |
| username | varchar(50) | YES | | NULL | |
| password | varchar(50) | YES | | NULL | |
| email | varchar(50) | YES | | NULL | |
| city | varchar(50) | YES | | NULL | |
| state | varchar(2) | YES | | NULL | |
| zip | varchar(15) | YES | | NULL | |
| phone | varchar(15) | YES | | NULL | |
| firstName | varchar(50) | YES | | NULL | |
| lastName | varchar(50) | YES | | NULL | |
| sub | varchar(5) | YES | | NULL | |
| orderDate | date | YES | | NULL | |
| endDate | date | YES | | NULL | |
+-----------+-------------+------+-----+---------+----------------+
I just want a quick and easy way to update the null in my sub field to the word yes when the user enters yes it in the form and hits submit for my session. The only way this page can be viewed is by a registered member from the database. I just can't figure out how to update the field of a session user. This is what I have so far for my code. I know the code is old and its a security issue. This is not a live website. I am adding this to a larger collection of pages I have already created. Once I have time I am going to go over mysqli and fix my coding mistakes.
<?php
mysql_connect('localhost','user','pass');
mysql_select_db('db');
session_start();
$username=$_SESSION['username'];
if(!$username){
die("Please login");
}
else
{
$query="select *from users WHERE username='$username' ";
$run=mysql_query($query);
while($row=mysql_fetch_array($run)){
$admin=$row['username'];
}
?>
<!doctype html>
<html>
<head>
<title>entrySubscription</title>
<link rel="stylesheet" type="text/css" href="Substyle.css">
</head>
<body>
<form method="post" name="myForm" autocomplete="on" onsubmit="return validateForm()">
<p><label>Please type yes (required) <input type="text" name="sub""/> </label></p>
<input type="submit" name="submit" value="Submit response" />
<input type="reset" name="reset" value="Clear form" />
</div>
</form>
</body>
</html>