My problem is my PHP insert code is not writing to the database -- I feel it will be a small error with the HTML form below but I cannot place it.
HTML form (sorry for indenting)
<form method='post' action='form.php'>
<div class='form-group'>
<input type='email' class='form-control' id='email' placeholder='Email : xyz#domain.com'>
</div>
<div class='form-group'>
<input type='text' class='form-control' id='name' placeholder='Name : Joe Bloggs'>
</div>
<div class='form-group'>
<input type='textarea' class='form-control' id='message' placeholder='Message : Hey, can you do this job?'>
</div>
<button type='submit' class='btn btn-default'>Submit</button>
</form>
Below is my "form.php" code I am using to send data to the database.
<?php
//PHP Opened
// Insert Data
$username = "username";
$password = "password";
$dbname = "dbname" ;
// Create connection
$con=mysqli_connect("localhost",$username,$password,$dbname);
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
// From Form
$email = isset($_POST['email']) ? $_POST['email'] : '';
$name = isset($_POST['name']) ? $_POST['name'] : '';
$message = isset($_POST['message']) ? $_POST['message'] : '';
echo '<p>'.$email.'</p>';
$sql="INSERT INTO comment (id, email, name, message)VALUES(null,.$email.,.$name.,.$message.)";
$result = (mysqli_query($con,$sql));
if (false === $result){
echo 'failed';
}
else{
echo 'Record added';
}
mysqli_close($con)
//Close PHP
?>
It is because you did not define an name attribute for those tags.
New HTML code:
<form method='post' action='form.php'>
<div class='form-group'>
<input type='email' name='email' class='form-control' id='email' placeholder='Email : xyz#domain.com'>
</div>
<div class='form-group'>
<input type='text' name='name' class='form-control' id='name' placeholder='Name : Joe Bloggs'>
</div>
<div class='form-group'>
<input type='textarea' name='message' class='form-control' id='message' placeholder='Message : Hey, can you do this job?'>
</div>
<button type='submit' name='post' class='btn btn-default'>Submit</button>
</form>
Also, you need a bit of fixing in PHP:
<?php
//PHP Opened
// Insert Data
$username = "username";
$password = "password";
$dbname = "dbname" ;
// Create connection
$con=mysqli_connect("localhost",$username,$password,$dbname);
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
// From Form
if(isset($_POST['post'])) {
$email = isset($_POST['email']) ? $_POST['email'] : '';
$name = isset($_POST['name']) ? $_POST['name'] : '';
$message = isset($_POST['message']) ? $_POST['message'] : '';
echo '<p>'.$email.'</p>';
$sql = "INSERT INTO comment (id, email, name, message) VALUES(null, " . $email . " , " . $name . ", " . $message . ")";
$result = (mysqli_query($con,$sql));
if (false === $result){
echo 'failed';
}
else{
echo 'Record added';
}
}
mysqli_close($con)
//Close PHP
?>
Related
I wrote this code to update entry in my sql table, but i don't what is wrong.
Here is my form
<form action="" method="POST">
<center>
Alumni_ID :
<input type="text" name="valueh">
<br>
<input type="text" name="name" placeholder="name">
<input type="text" name="phone" placeholder="contact details">
<input type="text" name="details" placeholder="details">
<input type="text" name="address" placeholder="address">
<input type="submit" value="update data">
</center>
</form>
And this is php page,
<?php if (isset($_POST['submit'])) {
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "tssolutions";
$ab = $_POST['name'];
$bc = $_POST['phone'];
$cd = $_POST['details'];
$de = $_POST['address'];
$posted = $_POST['valueh'];
//create connection
$conn = mysqli_connect($servername, $username, $password, $dbname);
//check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
//echo "connected successfully";
$sql = " UPDATE phone SET name='".$ab."', phone='".$bc."', details='".$cd."', address='".$de."' WHERE name = '".$posted."' ";
if(mysqli_query($conn, $sql)) {
echo "<hr>";
echo "<h3 class='w3-center' style='text-color:black'>Record Successfully Updated</h3>";
} else {
echo "<hr>";
echo "<h3 class='w3-center' style='text-color:black'>Error While Updating, Try Again</h3>";
}
mysqli_close($conn);
} ?>
Both the code are on same page Update.php, i wish to send alumni_id so that i can update that record where alumni_id = name in table phone, and then send new values of the row .
You forgot to name the submit button
Instead of
<input type="submit" value="update data">
Try this
<input type="submit" name="submit" value="update data">
To debug your code you can echo your SQL statement
echo $sql = "UPDATE phone SET name='".$ab."', phone='".$bc."', details='".$cd."', address='".$de."' WHERE name = '".$posted."';
You can then see if you have correct syntax and your values are sent correctly
try this code, maybe this helps
$sql = " UPDATE phone SET `name` ='$ab', `phone` ='$bc', `details` ='$cd', `address`='$de' WHERE `name` = '$posted' ";
I've designed a form to insert data to a database on localhost.
<form action='' method='post'>
<input type='submit' name='CRUD' value='New Data'>
<br><br>
<input type='submit' name='CRUD' value='Retrieve Data'>
<br>
<hr>
</form>
<?php
error_reporting(0);
$x = $_POST['CRUD'];
if ($x == "New Data") {
require 'part1.php';
}
?>
I then made a form to insert the data on another file.
<form method='post'>
<label for='site'>Name: </label>
<input type='text' name='site'>
<br><br>
<label for='date'>Date: </label>
<input type='date' name='time'>
<br><br>
<label for='page'>Web URL: </label>
<input type='url' name='page'>
<br><br>
<label for='desc'>Description: </label>
<input type='text' name='desc'>
<br><br>
<input type='submit' name='finish' value='Go'><input type="reset">
</form>
<?php
if ( !empty( $_POST) ){
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "assignment5";
$resource = $_POST['site'];
$date = $_POST['time'];
$url = $_POST['page'];
$explain = $_POST['desc'];
// Create connection
$conn = new mysqli('localhost', 'root', $password, $dbname) or
die("Unable to connect");
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "INSERT INTO thedata (date, Name, URL, Description)
VALUES ('$date', '$resource', '$url', '$explain')";
if (mysqli_query($conn, $sql)) {
echo "New record created successfully";
} else {
echo "Error: " . $sql . "<br>" . mysqli_error($conn);
}
$conn->close();
}
?>
On there own they work as intended but what I need is to have both forms on the same page. Doing this gives an error where default data is inserted and not the form's inputs.
If you want to put the 2 forms in the same page , you have to give each form a submit button .. be aware to use the same submit button to the same forms
Everything works out just fine until I changed the below code from
<form method='post' action='re.php'>
to
<form method='post' action='<?php echo $_SERVER["PHP_SELF"];?>'>
It gives me HTTP error 500. I have done some googling but still have no idea why this is happening! Thanks so much for help!
Below is the whole script
<?php
$hostname = 'localhost';
$username = 'Ciara';
$password = 'mypass';
$database = 'users';
$conn = mysqli_connect($hostname,$username, $password, $database);
if (!$conn) {
die ("Databas connect failed: " . mysqli_connect_error());
} else {
echo "Connected successfully. <br>";
}
echo <<<_END
<html>
<head>
<title>Register</title>
</head>
<body><center>
<form method='post' action='<?php echo $_SERVER["PHP_SELF"];?>'>
Firstname: <input type='text' name='firstname'><br>
Lastname: <input type='text' name='lastname'><br>
E-mail: <input type='text' name='email'><br>
Gender: <input type='radio' value='female' name='gender'>Female
<input type='radio' value='male' name='gender'>Male<br>
Username: <input type='text' name='username'><br>
Password: <input type='text' name='password'><br>
<input type='submit' value='Submit Form'>
</form></center>
_END;
if (isset($_POST['firstname']) &&
isset($_POST['lastname']) &&
isset($_POST['email']) &&
isset($_POST['gender']) &&
isset($_POST['username']) &&
isset($_POST['password'])) {
$firstname = get($conn, 'firstname');
$lastname = get($conn, 'lastname');
$email = get($conn, 'email');
$gender = get($conn, 'gender');
$username = get($conn, 'username');
$password = get($conn, 'password');
$query = "insert into useracc values" . "(null, '$firstname','$lastname','$email','$gender','$username','$password')";
if (mysqli_query($conn, $query)) {
echo "You have successfully registered! <br>";
} else {
echo "Failed to register." . mysqli_error($conn);
}
}
mysqli_close($conn);
echo "</body></html>";
function get($conn, $var) {
return mysqli_real_escape_string($conn, $_POST[$var]);
}
?>
You can't add PHP inside your HTML when you're using echo
<?php
$hostname = 'localhost';
$username = 'Ciara';
$password = '0950767';
$database = 'users';
$conn = mysqli_connect($hostname,$username, $password, $database);
if (!$conn) {
die ("Databas connect failed: " . mysqli_connect_error());
} else {
echo "Connected successfully. <br>";
}
?>
<html>
<head>
<title>Register</title>
</head>
<body><center>
<form method='post' action='<?php echo $_SERVER["PHP_SELF"];?>'>
Firstname: <input type='text' name='firstname'><br>
Lastname: <input type='text' name='lastname'><br>
E-mail: <input type='text' name='email'><br>
Gender: <input type='radio' value='female' name='gender'>Female
<input type='radio' value='male' name='gender'>Male<br>
Username: <input type='text' name='username'><br>
Password: <input type='text' name='password'><br>
<input type='submit' value='Submit Form'>
</form></center>
<?php
if (isset($_POST['firstname']) &&
isset($_POST['lastname']) &&
isset($_POST['email']) &&
isset($_POST['gender']) &&
isset($_POST['username']) &&
isset($_POST['password'])) {
$firstname = get($conn, 'firstname');
$lastname = get($conn, 'lastname');
$email = get($conn, 'email');
$gender = get($conn, 'gender');
$username = get($conn, 'username');
$password = get($conn, 'password');
$query = "insert into useracc values" . "(null, '$firstname','$lastname','$email','$gender','$username','$password')";
if (mysqli_query($conn, $query)) {
echo "You have successfully registered! <br>";
} else {
echo "Failed to register." . mysqli_error($conn);
}
}
mysqli_close($conn);
echo "</body></html>";
function get($conn, $var) {
return mysqli_real_escape_string($conn, $_POST[$var]);
}
?>
Check this code :).
How do you guys insert user input from textbox(html/php) to database (phpmyadmin) using mysql
I keep getting the error "failed to insert" is there something missing with my code.
I did search online on how to fix it but nothing is working. I think something is missing with my code and I can't pin point it.
all files below are in 1 php file named index.php
<!DOCTYPE html>
<?php
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = '';
$db = 'dad_trading';
$dbconn = mysql_connect($dbhost, $dbuser, $dbpass);
mysql_select_db($db);
if (isset($_POST['submit']))
{
$Lastname = $_POST['LastName'];
$firstname = $_POST['FirstName'];
$Middlename = $_POST['MiddleName'];
$address = $_POST['Address'];
$city = $_POST['City'];
$zipcode = $_POST['ZipCode'];
$email = $_POST['email'];
$number = $_POST['number'];
$query = ("INSERT INTO customer ([LName], [FName], [MName], [Street], [City], [ZipCode], [Email], [ContactNo]) VALUES ('$Lastname', '$firstname', '$Middlename', '$address', '$city','$zipcode', '$email', '$number')");
if(mysql_query($query))
{
echo "<script>alert('INSERTED SUCCESSFULLY');</script>";
}
else
{
echo "<script>alert('FAILED TO INSERT');</script>";
}
}
?>
<html>
<head>
<meta charset="UTF-8">
<title>sample</title>
</head>
<body>
<form action="" method = "POST">
First name:
Middle Name:
Last Name:<br>
<input name="FirstName" size="15" style="height: 19px;" type="text" required>
<input name="MiddleName" size="15" style="height: 19px;" type="text" required>
<input name="LastName" size="15" style="height: 19px;" type="text" required>
<br><br>
Email Address:<br>
<input name="email" type="text" required placeholder="Enter A Valid Email Address" style="height: 19px;" size="30"><br><br>
Home Address: <br>
<input name="Address" type="text" required placeholder="Enter your home Address" style="height: 19px;" size="30" maxlength="30"><br><br>
City:
Zipcode:
<br>
<input name="City" size="7" style="height: 19px;" type="text" required>
<input name="ZipCode" size="7" style="height: 19px;" type="text" required>
<br><br>
Telephone/Mobile Number: <br>
<input name="number" type="text" required id="number" placeholder="Mobile Number" style="height: 19px;">
<br>
<br>
<button type ="submit" name="submit" value="send to database"> SEND TO DATABASE </button>
</form>
</body>
</html>
try add the form action using server variable
<form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post">
Here's an example of code that works. From w3Schools. mysql_connect is deprecated, new mysqli works.
<?php
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "myDB";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "INSERT INTO MyGuests (firstname, lastname, email)
VALUES ('John', 'Doe', 'john#example.com')";
if ($conn->query($sql) === TRUE) {
echo "New record created successfully";
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
$conn->close();
?>
Having tried myself to make your code work and as a beginner not knowing it was broken, I came across a few issues using your code. I leave this out for anyone who could end up here while learning on how to insert data in a database and to anyone who could want to point out the mistakes OP made by editing this answer.
I fixed the OP for my purposes, and it worked for me. Goal was to create database entries from a web form for some testing.
<html>
<head>
<meta charset="UTF-8">
<title>sample</title>
</head>
<?php
//These $variables related to the form data html elements eg "<input
//name="City"" input name=values, case sensitive which are derived from
//the //form submit with POST type, from the form at the end of this code
//block.
if (isset($_POST['submit']))
{
$Lastname = $_POST['LastName'];
$firstname = $_POST['FirstName'];
$Middlename = $_POST['MiddleName'];
$address = $_POST['Address'];
$city = $_POST['City'];
$zipcode = $_POST['ZipCode'];
$email = $_POST['email'];
$number = $_POST['number'];
//This is the sql query to apply the form inpur field values into the
database //from the user form in the web page. There is no validation
checking, which //an example at TutorialRepublic for CRUD and php...:
https://www.tutorialrepublic.com/php-tutorial/php-mysql-crud-
application.php
//...Is really much more thorough.
$con = mysqli_connect('localhost','root','Levaral','test');
$query = "INSERT INTO customer (LastName, FirstName, MiddleName,
Address, City, Zipcode, email, number) VALUES (" . " '" . $Lastname .
"', '" . $firstname . "', '" . $Middlename . "', '" . $address . "', '" .
$city . "', '" . $zipcode . "', '" . $email . "', '" . $number . "')";
if (mysqli_query($con,$query))
{
echo "<script>alert('INSERTED SUCCESSFULLY');</script>";
}
else
{
echo "<script>alert('FAILED TO INSERT');</script>";
}
}
?>
<body>
//put html element data in a <form> so you can send the data here by POST
//type, this stumped me
//at first when I was starting.
//I guess since the form is in the same page, it is available to the PHP
//function as some default.
<form action="" method = "POST">
First name:
Middle Name:
Last Name:<br>
<input name="FirstName" size="15" style="height: 19px;" type="text" required>
<input name="MiddleName" size="15" style="height: 19px;" type="text" required>
<input name="LastName" size="15" style="height: 19px;" type="text" required>
<br><br>
Email Address:<br>
<input name="email" type="text" required placeholder="Enter A Valid Email Address" style="height: 19px;" size="30"><br><br>
Home Address: <br>
<input name="Address" type="text" required placeholder="Enter your home Address" style="height: 19px;" size="30" maxlength="30"><br><br>
City:
Zipcode:
<br>
<input name="City" size="7" style="height: 19px;" type="text" required>
<input name="ZipCode" size="7" style="height: 19px;" type="text" required>
<br><br>
Telephone/Mobile Number: <br>
<input name="number" type="text" required id="number" placeholder="Mobile Number" style="height: 19px;">
<br>
<br>
<button type ="submit" name="submit" value="send to database"> SEND TO DATABASE </button>
</form>
//This part below was just for my feedback to see if it worked by
//returning some //data from the query, as in progress to have an edit
//area
//on the same page //without affecting the original if my mind serves me
//right.
<?php
/////
mysqli_select_db($con,"customer");
$sql="SELECT * FROM customer WHERE FirstName = '".$firstname."'";
$result = mysqli_query($con,$sql);
echo "<table>
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>City</th>
<th>Email</th>
<th>Number</th>
</tr>";
while($row = mysqli_fetch_array($result)) {
echo '<tr style="width:20%">';
echo '<td style="width:20%">' . $row['FirstName'] . "</td>";
echo '<td style="width:20%">' . $row['LastName'] . "</td>";
echo '<td style="width:20%">' . $row['City'] . "</td>";
echo '<td style="width:20%">' . $row['email'] . "</td>";
echo '<td style="width:20%">' . $row['number'] . "</td>";
echo "</tr>";
}
echo "</table>";
mysqli_close($con);
?>
</body>
</html>
I have an html file that calls a DB table to pull up a record, and a php file that updates changes to the DB table, and directs the user back to the html file (to reload the updated record).
The html file loads the user data, takes the input, posts it to the php file, and php file writes it to DB table, and reloads the html file. However, upon reload, it shows the old record info and not the newly updated info. I look in DB table, and the update ran correctly and I see the new info. But it does not reflect on the page. How do I fix this?
Is there a better way to do this? Thanks.
HTML file:
<?php
session_start();
$_SESSION['email'] = $email;
if(isset($_SESSION['email'])) {
echo $_SESSION['email'], " is logged in."; // echoes 1
}
else {
echo "User not logged in";
}
?>
<?php
$query = "SELECT email, username, address1, city, state, postalcode, country
FROM users
WHERE email = '$_SESSION[email]';";
$result = mysql_query($query);
if ($result) {
$_SESSION['userdata'] = mysql_fetch_array($result, MYSQL_ASSOC);
}
mysql_close();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<body>
<form name="userprofile" action="update.php" method="post">
<fieldset>
<legend>Update User Profile</legend>
<br class="clear" />
<label for="username">Username</label>
<input type='text' name='username' value='<?php echo $_SESSION['userdata']['username']; ?>'/>
<br class="clear" />
<label for="address1">Address</label>
<input type='text' name='address1' value='<?php echo $_SESSION['userdata']['address1']; ?>'/><br>
<br class="clear" />
<label for="city">City</label>
<input type='text' name='city' value='<?php echo $_SESSION['userdata']['city']; ?>'/><br>
<br class="clear" />
<label for="state">State</label>
<input type='text' name='state' value='<?php echo $_SESSION['userdata']['state']; ?>'/><br>
<br class="clear" />
<label for="postalcode">Postal code</label>
<input type='text' name='postalcode' value='<?php echo $_SESSION['userdata']['postalcode']; ?>'/><br>
<br class="clear" />
<label for="country">Country</label>
<input type='text' name='country' value='<?php echo $_SESSION['userdata']['country']; ?>'/><br>
<br class="clear" />
<br class="clear" />
</fieldset>
<input type="submit" value="Update" />
</form>
</body>
</html>
<br class="clear" />
</form>
</html>
PHP file:
<?php
session_start();
$_SESSION['email'] = $email;
if(isset($_SESSION['email'])) {
echo $_SESSION['email'], " is logged in."; // echoes 1
}
else {
echo "User not logged in";
}
$username = $_POST['username'];
$address1 = $_POST['address1'];
$city = $_POST['city'];
$state = $_POST['state'];
$postalcode = $_POST['postalcode'];
$country = $_POST['country'];
$dbhost = 'localhost';
$dbname = 'dbtable';
$dbuser = 'dbuser';
$dbpass = 'password'; //not really
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
mysql_select_db($dbname, $conn);
$query = "UPDATE users
SET username ='$username',
address1 = '$address1',
city = '$city',
state = '$state',
postalcode = '$postalcode',
country = '$country'
WHERE email = '$_SESSION[email]';";
if(! $conn )
{
die('Could not connect: ' . mysql_error());
}
//echo $query;
mysql_query($query);
$retval = mysql_query($query);
if(! $retval )
{
die('Could not update data: ' . mysql_error());
}
echo "Updated data successfully\n";
mysql_close();
header('Location: update.html');
?>
you need to re assign updated data into your session once the data gets updated into the database table. you may need to modify your code like this
<?php
session_start();
$_SESSION['email'] = $email;
if(isset($_SESSION['email'])) {
echo $_SESSION['email'], " is logged in."; // echoes 1
}
else {
echo "User not logged in";
}
$username = $_POST['username'];
$address1 = $_POST['address1'];
$city = $_POST['city'];
$state = $_POST['state'];
$postalcode = $_POST['postalcode'];
$country = $_POST['country'];
$dbhost = 'localhost';
$dbname = 'dbtable';
$dbuser = 'dbuser';
$dbpass = 'password'; //not really
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
mysql_select_db($dbname, $conn);
$query = "UPDATE users
SET username ='$username',
address1 = '$address1',
city = '$city',
state = '$state',
postalcode = '$postalcode',
country = '$country'
WHERE email = '$_SESSION[email]';";
if(! $conn )
{
die('Could not connect: ' . mysql_error());
}
//echo $query;
$retval = mysql_query($query);
if($retval){
$_SESSION['userdata']['username']=$username;
$_SESSION['userdata']['address1']=$address1;
$_SESSION['userdata']['city']=$city;
$_SESSION['userdata']['state']=$state;
$_SESSION['userdata']['postalcode']=$postalcode;
$_SESSION['userdata']['country']=$country;
echo "Updated data successfully\n";
mysql_close();
header('Location: update.html');
}else{
die('Could not update data: ' . mysql_error());
}
?>
You can do it in index.html page. no need of index.php
<?php
session_start();
$dbhost = 'localhost';
$dbname = 'test';
$dbuser = 'root';
$dbpass = ''; //not really
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
mysql_select_db($dbname, $conn);
$email='ripon';
$_SESSION['email'] = $email;
if(isset($_SESSION['email'])) {
echo $_SESSION['email'], " is logged in."; // echoes 1
}
else {
echo "User not logged in";
}
?>
<?php
if(isset($_POST['submit']))
{
$username = $_POST['username'];
$address1 = $_POST['address1'];
$city = $_POST['city'];
$state = $_POST['state'];
$postalcode = $_POST['postalcode'];
$country = $_POST['country'];
echo $address1;
$dbhost = 'localhost';
$dbname = 'test';
$dbuser = 'root';
$dbpass = ''; //not really
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
mysql_select_db($dbname, $conn);
$query = "UPDATE user SET password = '$address1' WHERE username = '$_SESSION[email]';";
if(! $conn )
{
die('Could not connect: ' . mysql_error());
}
//echo $query;
mysql_query($query) or die(mysql_error());
$retval = mysql_query($query);
if(! $retval )
{
die('Could not update data: ' . mysql_error());
}
echo "Updated data successfully\n";
//mysql_close();
}
?>
<?php
$query = "SELECT username, password, fullname FROM user WHERE username = '$_SESSION[email]';";
$result = mysql_query($query);
if ($result) {
$_SESSION['userdata'] = mysql_fetch_array($result, MYSQL_ASSOC);
}
else
{
echo "error";
echo $query;
}
//mysql_close();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<body>
<?php var_dump($_SESSION['userdata']);?>
<form name="userprofile" action="update.html" method="post">
<fieldset>
<legend>Update User Profile</legend>
<br class="clear" />
<label for="username">Username</label>
<input type='text' name='username' value='<?php echo $_SESSION['userdata']['username']; ?>'/>
<br class="clear" />
<label for="address1">Address</label>
<input type='text' name='address1' value='<?php echo $_SESSION['userdata']['password']; ?>'/><br>
<br class="clear" />
<label for="city">City</label>
<input type='text' name='city' value='<?php echo $_SESSION['userdata']['city']; ?>'/><br>
<br class="clear" />
<label for="state">State</label>
<input type='text' name='state' value='<?php echo $_SESSION['userdata']['state']; ?>'/><br>
<br class="clear" />
<label for="postalcode">Postal code</label>
<input type='text' name='postalcode' value='<?php echo $_SESSION['userdata']['postalcode']; ?>'/><br>
<br class="clear" />
<label for="country">Country</label>
<input type='text' name='country' value='<?php echo $_SESSION['userdata']['country']; ?>'/><br>
<br class="clear" />
<br class="clear" />
</fieldset>
<input type="submit" value="Update" name="submit"/>
</form>
</body>
</html>
<br class="clear" />
</form>
</html>