Regarding my previous post:

http://www.daniweb.com/forums/thread326976.html

I manage to correct that error.

Now my problem is the misplacement of records on my fields.

Records that suppose to be in the Region field now displays at the Name field.
Records that should be on the Zipcode field now at the Age field.
Records that should be on CPnumber field now displays at the Birthday field.

It does displays the record though.
Just dont know why i have this misplacement error in displaying the fields.

<html>
<head>
<title>Record Entry</title>
</head>

<body>

<center>

<br><br>
<br><br>
<br><br>
<br><br>


<b>
<?php

// $sample = isset($_POST['sample']) ? $_POST["sample"] : "";

	$fname=isset($_POST['fname']) ? $_POST["fname"] : "";
	$age=isset($_POST['age']) ? $_POST["age"] : "";
	$birthday=isset($_POST['birthday']) ? $_POST["birthday"] : "";
	

	$address=isset($_POST['address']) ? $_POST["address"] : "";
	$status=isset($_POST['status']) ? $_POST["status"] : "";
	$religion=isset($_POST['religion']) ? $_POST["religion"] : "";
	$region=isset($_POST['region']) ? $_POST["region"] : "";
	$zipcode=isset($_POST['zipcode']) ? $_POST["zipcode"] : "";
	$cpnumber=isset($_POST['cpnumber']) ? $_POST["cpnumber"] : "";

$con = mysql_connect('localhost', 'root' , '');
	
if (! $con)
	{
die(mysql_error());
	}
mysql_select_db("database" , $con) or die("Select Error: ".mysql_error());
$result=mysql_query("INSERT INTO Record (Name, Age, Birthday, Address, Status, Religion, Region, ZipCode, CPNumber) VALUES (
		
'$fname',
'$age', 
'$birthday',
'$address', 
'$status',
'$religion', 
'$region',
'$zipcode', 
'$cpnumber')") or die("Insert Error: ".mysql_error());
mysql_close($con);

/* Database Connection Ends */



print "Record successfully added.";
?>


<br><br>
<form method="POST" action="Insertform.php">
<input type="submit" value="Insert Another Record">
</form>
<br><br>

<form method="POST" action="index.php">
<input type="submit" value="Back to Main Menu">
</form>

</center>
</body>
</html>

Recommended Answers

All 6 Replies

Now my problem is the misplacement of records on my fields.

Records that suppose to be in the Region field now displays at the Name field.
Records that should be on the Zipcode field now at the Age field.
Records that should be on CPnumber field now displays at the Birthday field.

How do you know that the records are "misplaced"? Are you
A. looking directly at the db table OR
B. are you querying the db via some php script and looking at the result of your php script?

If "B", then it is possible your php script is just showing the data incorrectly. Your insert statement seems correct.

Well it is B.

My script and statements are correct.

Hhhm dont know whats wrong.

Well it is B.

My script and statements are correct.

Hhhm dont know whats wrong.

Maybe the best thing to do is to start by POSTING one field and maybe and then adding another etc..

Also it maybe worth testing this by changing,

$fname=isset($_POST['fname']) ? $_POST["fname"] : "";

to this

$fname = mysql_real_escape_string($_POST['fname']);

Im just thinking that if you simplify the code even more and reduce the amount of inserts you can see if its working or not.

Just an idea...

Also if you have any idea why this is happening to me can you please help..

http://www.daniweb.com/forums/thread327532.html

I've fix it.

Uhm thanks for the replies though.

Please dont hijack

I've fix it.

Uhm thanks for the replies though.

Please dont hijack

Hey,
thats cool.

What does hijack mean?

if it was the link to my thread then i am sorry i will not do that again, i am totally new here.

It would be good if you posted what the fix / problem / issue was for you and marked it as solved though.

Regards
John

This is funny.

The mistake was on my other php code or html file that is.

The arrangement of fields wasn't correct.

Sorry though.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.