Call a PHP page from another PHP page
Posted: Mon Jun 30, 2008 9:50 am
Hello! My first post here
I'm making a website for the university and I want to create a log In page. My website has some iframes and one of them is displaying the Username and Password textboxes with a submit button. After user presses the Submit, the website is calling another PHP (LogInValidate.PHP) which checks if the username and password are ok. The problem is that I want to create a cookie when the user has succesfuly logged in and I've read that the cookie should be created at the top of the page before the <html>. So if the LogInValidate.PHP page says that the user is logged in, I want to call another PHP page (Welcome.PHP) which will create the cookie and then it will display a welcome message...
So, how can I call the Welcome.PHP without using a form? (because forms should have a submit button to work and I want to be done automatically).
Sorry if the question is stupid but I couldn't find anything useful in google...maybe I didn't search for the correct keywords...
Thanks alot!
edit: I have tried the header("Location: welcome.PHP") but I get this error: Warning: Cannot modify header information - headers already sent by (output started at c:\http\site\loginvalidate.php:7) in c:\http\site\loginvalidate.php on line 15
here's the code of LogInValidate.PHP
I'm making a website for the university and I want to create a log In page. My website has some iframes and one of them is displaying the Username and Password textboxes with a submit button. After user presses the Submit, the website is calling another PHP (LogInValidate.PHP) which checks if the username and password are ok. The problem is that I want to create a cookie when the user has succesfuly logged in and I've read that the cookie should be created at the top of the page before the <html>. So if the LogInValidate.PHP page says that the user is logged in, I want to call another PHP page (Welcome.PHP) which will create the cookie and then it will display a welcome message...
So, how can I call the Welcome.PHP without using a form? (because forms should have a submit button to work and I want to be done automatically).
Sorry if the question is stupid but I couldn't find anything useful in google...maybe I didn't search for the correct keywords...
Thanks alot!
edit: I have tried the header("Location: welcome.PHP") but I get this error: Warning: Cannot modify header information - headers already sent by (output started at c:\http\site\loginvalidate.php:7) in c:\http\site\loginvalidate.php on line 15
here's the code of LogInValidate.PHP
Code: Select all
<html>
<head>
<title>
</title>
</head>
<body>
<?php
extract($_POST);
if(!($conn=odbc_connect("dbWSM", "", ""))) { die("could not connect to the database."); }
$sql="SELECT username FROM Customers WHERE
username= '" . $txtUsr . "' AND password= '" . $txtPass . "'";
if(!($rs=odbc_exec($conn,$sql))) { die(mysql_error); }
if (odbc_result($rs,1) != "") {
echo odbc_result($rs,1);
header("Location: welcome.php");
}
else { header("Location: invalid.php" }
?>
<a href="logout.php">(Log out)</a>
</body>
</html>