Open a new page
Moderator: General Moderators
-
chrislynch
- Forum Newbie
- Posts: 9
- Joined: Tue Mar 07, 2006 9:44 am
Open a new page
Hi, I'm completely new ot php...
i have created a simple login and registration page... It all works perfectly connectingto the database, checking usernames and passwords etc
When the user enters the user name and password and its correct i want to show another webpage just saying welcome username etc etc
or incorrect username or password
How can i do this.
Chris
i have created a simple login and registration page... It all works perfectly connectingto the database, checking usernames and passwords etc
When the user enters the user name and password and its correct i want to show another webpage just saying welcome username etc etc
or incorrect username or password
How can i do this.
Chris
either redirect to the welcome/error page using
or open it in a new window (if that's what you're wanting, i'm not sure) using
Code: Select all
header("Location: welcome.php");Code: Select all
<form action="whatever" method="post" target="_blank">Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
-
chrislynch
- Forum Newbie
- Posts: 9
- Joined: Tue Mar 07, 2006 9:44 am
Code: Select all
if($row[0]== $_POST["user_name"])
{
printf("Login successful");
header("Location: ./welcome.php");
}
else
{
printf("Login error");
header("Location: ./error.php");
}I have the about code but the header function is giving the following error
Warning: Cannot modify header information - headers already sent by (output started at c:\program files\easyphp1-8\www\login.php:2) in c:\program files\easyphp1-8\www\login.php on line 35
don't print anything before calling header("Location: xxx"); or the header won't work
instead, print "welcome" or whatever you want to say on the page you are redirecting to
instead, print "welcome" or whatever you want to say on the page you are redirecting to
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
-
chrislynch
- Forum Newbie
- Posts: 9
- Joined: Tue Mar 07, 2006 9:44 am
Code: Select all
<?php
//Variables used to access the database
$hostname = "localhost";
$database = "access_point_users";
$username = "Chris Lynch";
$password = "CoGiWaV5";
//$user_name = $_POST["user_name"];
$ttt = mysql_connect($hostname, $username, $password) or trigger_error(mysql_error(),E_USER_ERROR);
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING']))
{
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "users"))
{
//Selects the user_name with the entered password
$sql = "SELECT User_Name FROM users WHERE Password = '$_POST[password]'";
mysql_select_db("access_point_users", $ttt) or die( "Unable to select the database");
$Result1 = mysql_query($sql) or die(mysql_error());
//Retrieves the username which matches the password
while ($row = mysql_fetch_array($Result1, MYSQL_BOTH))
{
//Compares the entered user name with the retrieved user name
if($row[0]== $_POST["user_name"])
{
//printf("Login successful");
header("Location: ./welcome.php");
}
else
{
//printf("Login error");
header("Location: ./error.php")
}
}
}
?>chrisWarning: Cannot modify header information - headers already sent by (output started at c:\program files\easyphp1-8\www\login.php:2) in c:\program files\easyphp1-8\www\login.php on line 35
Your headers are being sent by this line
c:\program files\easyphp1-8\www\login.php:2
check login.php on line 2, and remove whatever it's sending to the browser
header() only works if it's the first header being sent.. the rest of them will be ignored.
if you print out anything (even white space) you're sending a header()
c:\program files\easyphp1-8\www\login.php:2
check login.php on line 2, and remove whatever it's sending to the browser
header() only works if it's the first header being sent.. the rest of them will be ignored.
if you print out anything (even white space) you're sending a header()
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
-
chrislynch
- Forum Newbie
- Posts: 9
- Joined: Tue Mar 07, 2006 9:44 am
Line two is the begining of the php code
Code: Select all
<?phpthat's your problem, it should be line 1
the blank line before <?php is sending headers...
just erase the blank line (or any space characters) and your code should work
the blank line before <?php is sending headers...
just erase the blank line (or any space characters) and your code should work
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.