Hey guys, just tying up some loose ends on a current project here and can't quite get it right - wonder if anyone can offer me some advice.
Situation is this - I've got an MS Access database set up (college server for some reason won't do mysql) with two tables
contact - contains kids contact details
passwords - contains a set of username/password details.
I have a form on my page that allows people to enter a username, a password, and a childs name, and then submit, I'd like my php to check that the username and password are correct, and if so, to run a query in the database to display the child's Name, then Contact Number, then emergency contact number in a table
here's what I have so far
Now obviously this doesn't work, but the simple case is, I think I need to tell the php script to check the password, then IF that is right, to run a second script. Is this the correct logic? and if so how do I get it do that?
Any help very much appreciated.
On a second point - this second script, when it works, generates the table in a new, blank page. Which is fine. It works. But it doesn't look nice, is there a way to get it to generate it within a div on a pre-exisiting CSS based page? Or is that insane of me to suggest?
Situation is this - I've got an MS Access database set up (college server for some reason won't do mysql) with two tables
contact - contains kids contact details
passwords - contains a set of username/password details.
I have a form on my page that allows people to enter a username, a password, and a childs name, and then submit, I'd like my php to check that the username and password are correct, and if so, to run a query in the database to display the child's Name, then Contact Number, then emergency contact number in a table
here's what I have so far
Code:
<html>
<head></head>
<body>
<?php
$user = $_POST ['username'];
$pass = $_POST ['password'];
$conn=odbc_connect('mydb03','','');
$sql="SELECT password FROM [passwords] where username='$user'";
$rs=odbc_exec($conn,$sql); //executes the query on the database connection
if (odbc_fetch_row($rs)) { //gets the data from the database
$pass=odbc_result($rs,"password");
<?php
$name = $_POST ['inputname']; //get the data from the form
$conn=odbc_connect('mydb03','',''); //all quotes are single quotes, replace nn with your number
$sql="SELECT contact, emergency FROM [contact] where cubname='$name'";
$rs=odbc_exec($conn,$sql); //executes the query on the database connection
if (odbc_fetch_row($rs)) { //gets the data from the database
$contact=odbc_result($rs,"contact");
$emergency=odbc_result($rs,"emergency");
echo "<table>"; //display the data in a table
echo "<tr><td>Name:</td><td>$name</td>";
echo "<tr><td>contact:</td><td>$contact</td>";
echo "<tr><td>emergency:</td><td>$emergency</td>";
echo "</table>";
}
else { //display a message if name not found
echo "<p>Name not found - please check spellings.";
}
odbc_close($conn); //close the database connection
?>
}
else { //display a message if name not found
echo "<p>Incorrect password or child name - please try again.";
}
odbc_close($conn); //close the database connection
?>
</body>
</html>
Now obviously this doesn't work, but the simple case is, I think I need to tell the php script to check the password, then IF that is right, to run a second script. Is this the correct logic? and if so how do I get it do that?
Any help very much appreciated.
On a second point - this second script, when it works, generates the table in a new, blank page. Which is fine. It works. But it doesn't look nice, is there a way to get it to generate it within a div on a pre-exisiting CSS based page? Or is that insane of me to suggest?