Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > Beginning PHP
|
Beginning PHP Beginning-level PHP discussions. More advanced coders should post to the Pro PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning PHP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 24th, 2005, 02:25 AM
Registered User
 
Join Date: Mar 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to raman1
Default Help me In Learning PHP

Hi Expertz!!

I m fairly new in PHP and Mysql.
I m facing following doubts while begining. Plz help me get out of this Probs:

i make Simple login form and want only Authonticate user will do log in and after login i want to redirect on next page.
Script is:

<?php include_once("connect_server.php");
/*if ($name != "" and $password != "")
{
$query="select user_name,pword from admin_account where user_name='" .$name. "' and pword='" .$password. "'";
$result=mysql_query($query, $con) or die(mysql_error());
echo '<form action="">';
}
else
{
echo "User Name and Password Does not exist";
}
echo "</form>"; */

$user=$_POST['name'];
$pass=$_POST['password'];
if (empty($user))
{
  $message="Please enter a Name!";
  echo "$message";
}
else if (empty($pass))
{
  $message="Please enter a password!";
   echo "$message";
}
else if (!empty($user) && (!empty($pass)))
{
$query="select user_name,pword from admin_account where user_name='". $user ."' and pword='". $pass ."'";
$result=mysql_query($query, $con) or die(mysql_error());
header("Location: index.php"); //// Here i want to redirect next page
}

mysql_close($con);

?>


The above mentioned code showing me Following Error while using Header:

Warning: Cannot add header information - headers already sent by (output started at c:\inetpub\wwwroot\handshake\admin.php:17) in c:\inetpub\wwwroot\handshake\admin.php on line 104
Plz plz help me!

Eargly waiting 4 ur Reply!
THANKS


 
Old March 27th, 2005, 10:09 AM
richard.york's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

A very common error. header() makes changes to the outgoing HTTP headers that are sent out with requests to the web server. HTTP headers *must* appear at the beginning of a document, therefore there can be no output before the call to header. No whitespace before the opening <?php delimiter, no markup, nothing.

About you are outputting with echo before the call to header() is made, which is why you get that error.

http://www.php.net/header

Regards,
Rich

--
[http://www.smilingsouls.net]
Mail_IMAP: A PHP/C-Client/PEAR solution for webmail
Author: Beginning CSS: Cascading Style Sheets For Web Design





Similar Threads
Thread Thread Starter Forum Replies Last Post
Learning AJAX siervocal Ajax 2 June 16th, 2007 05:03 PM
E-learning dineshv Flash (all versions) 1 January 4th, 2007 01:35 AM
Learning C# Jael C# 1 October 19th, 2005 07:54 PM
E-Learning dineshv Flash (all versions) 1 April 1st, 2005 03:12 PM
i am learning kuehhc Beginning PHP 4 March 29th, 2004 04:33 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.