Jump to content

[SOLVED] Table wont update my data....


weetabix

Recommended Posts

Ok first of all hi all im new and im in desperate need of some help as i have a project due tomorrow.

I've got this table which I want to add data to it.

I wrote the following code, tried it a million times but it doesnt seem to add anything to my database.

Any help is appreciated.

 

 

Form Code Here

function show_form(){
?>
<form action="addStaff.php" method="post">

    <p> Staff ID: 
<input type = "Text" name="staffid">
	<br>
Username:
<input type = "Text" name="username">
<br>
Password:
<input type = "Text" name="password">
<br>
Telephone:
<input type = "Text" name="telephone">
<br>
E-Mail:
<input type = "Text" name="email">
<br>
First Name:
<input type = "Text" name="firstname">
<br>
Last Name:
<input type = "Text" name="surname">
<br>
Address:
<input type = "Text" name="address">
<br>
Postcode:
<input type = "Text" name="postcode">
<br>
Hours per week:
<input type = "Text" name="workhrs">
<br>
Position ID:
<input type = "Number" name = "positionid">
Role
<input type = "Text" name="role">
<br>
<input type= "Submit" name="submit" value= "Submit">	
</form>
<?PHP
}

 

 

 

 

Insertion code

		
                $staff_id = $_POST['staffid'];
	$username = $_POST['username'];
	$password = $_POST['password'];
	$telephone = $_POST['telephone'];
	$email = $_POST['email'];
	$first_name = $_POST['firstname'];
	$last_name = $_POST['surname'];
	$address = $_POST['address'];
	$postcode = $_POST['postcode'];
	$hours_per_week = $_POST['workhrs'];
	$position_id = $_POST['positionid'];
	$role = $_POST['role'];

	$query = "INSERT INTO Staff (staff_id,username,password,telephone,email,first_name,last_name,address,postcode,hours_per_week,position_id,role) VALUES ('$staff_id', '$username', '$password', '$telephone', '$email', '$first_name', '$last_name', '$address', '$postcode', '$hours_per_week', '$position_id', '$role')";
	$results = mysql_query($query);

	echo 'Data Saved!';

	mysql_close($connection);

 

I know its connecting to the database properly but it wont let me save it :(

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.