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
https://forums.phpfreaks.com/topic/80053-solved-table-wont-update-my-data/
Share on other sites

Unknown column 'telephone' in 'field list'

 

Yeah I guess apparently I was dumb enough not to notice that it's telephone_no in the Table  :o

 

works like a charm now, thanks a million!!

 

Yup, no problem.

 

Please click Topic Solved if it isnt too much to ask lol :)

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.