I'm new to php and dymanic web applications
using PHP I'm tyring to read from table Id(primary key) to other form and save othe table as forign key.
I appreciat for you help

What do you have so far?

This is what I have Sofar :
I created From and save to mysql table let say <person>.. so I wanted to continue to next step of registeration but save diffrent table<academicq> so I want to get to Id from the <person> table and save mysql as foriegn key... this is whay I have so far...

//my php code for <person>
<?php 

include("connection/sqlconnect.php");

// get values from form
$staffId=$_POST['staffid'];
$fName=$_POST['fName'];
$lName=$_POST['lName'];
$country=$_POST['countryoforigin'];
$nationality=$_POST['nationality'];
$race=$_POST['race'];
$religion=$_POST['religion'];
$general_status=$_POST['general_status'];
$phone=$_POST['phone'];
$department=$_POST['department'];
$cposition=$_POST['position'];
$email=$_POST['email'];
$category=$_POST['category'];
$year=$_POST['year'];

// Insert data into mysql

echo "hithere ";


$sql= "INSERT INTO expertdirectory (staffId, firstName, lastName, countryoforigin, nationality, race, religion, general_status,
                                    department, cposition, year_employed, handphone, email) VALUES 
                                    ('$staffId','$fName', '$lName', '$country', '$nationality', '$race', '$religion',
                                    '$general_status', '$department', '$cposition', '$year', '$phone', '$email')";




$result=mysql_query($sql);
if($result)
{
echo "<BR>";

hearder("location: register/academic.php?staffId=$_POST[staffId]");
echo "the data sent somewhere";
}


mysql_close();
?>

And I get this error:
Fatal error: Call to undefined function hearder() in C:\xampp\htdocs\projectX\registration1.php on line 42
pls halp me thanks

It's header(), remove the 'r'.

Can I give you some additional advice? You said you are trying to save <person> table to <academic> table as foreign key right?

So why don't you try to normalize the database since the connector is staffId why dont you use left join functions? It will make it short and faster in computation of the database.

Member Avatar for diafol
header("location: register/academic.php?staffId=$_POST[staffId]");
    echo "the data sent somewhere";
}

COuld be an issue. It may be best to save the staff_id in a session as opposed to making it visible and liable to messing with. ANyway, would the user know his/her staff_id to place it in a form? Or is this placed there from a previous form? Bit confused.

there can be no output to the browser be for the header().
So remove echo statments at line 24 and 38
also move the comment at line 1 inside the <?php tag

Thank You guys That help a lot!

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.