Iam tired because my code is not working true , i write this code for make one membership script
plz help me and debug this code
thanks
Database.sql :
CREATE TABLE news ( id tinyint(4) NOT NULL auto_increment, username text NOT NULL, password text NOT NULL, email text NOT NULL, PRIMARY KEY (id) ) TYPE=MyISAM;
config.php :
<?php
mysql_connect("localhost","root","") or die(mysql_error());
mysql_select_db("member") or die(mysql_error());
?>
make.php :
<?php
if (!isset($_POST['submit'])) {
?>
<form method="POST" action="">
<p><input type="text" name="user" size="20" value="username"><br><input type="text" name="pass" size="20" value="password"><br><input type="text" name="email" size="20" value="email"></p>
<input type="submit" value="submit" name="submit">
</form>
<?php
} else {
$user = $_POST['user'];
$pass = $_POST['pass'];
$email = $_POST['email'];
include "config.php";
$result = MYSQL_QUERY("SELECT * from news WHERE username='$user'");
$worked = mysql_fetch_array($result);
if($worked){
echo "un , roor";
}else{
mysql_query("INSERT INTO news (username,password,email ) VALUES ('$user','$pass','$email')");
echo "Your name and password have been submitted into our database";
}
}
?>
login.htm :
<form method="POST" action="getin.php"> <p><input type="text" name="user" size="20" value="username"><br><input type="text" name="pass" size="20" value="password"></p> <input type="submit" value="submit" name="submit"> </form>
* this file has error :
getin.php :
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<?php
include "config.php";
$username = $_POST['user'];
$password = $_POST['pass'];
$result = MYSQL_QUERY("SELECT * from news WHERE username='$username'and password='$password'")
or die ("Name and password not found or not matched");
$worked = mysql_fetch_array($result);
$username = $worked[username];
$password = $worked[password];
$email = $worked[email];
if($worked)
echo "Welcome $user! Your e-mail address is $email";
setcookie( "user", "$user", time()+3600, "/", "", 0 );
?>
</head>
<body>
</body>
</html>
My problem is setcookie ,
Welcome admin! Your e-mail address is email
Warning: Cannot modify header information - headers already sent by (output started at c:\wamp\www\membership\getin.php:4) in c:\wamp\www\membership\getin.php on line 21
i know i can make cookie with setcookie();
i want make one page for example test.php and if my members has login can view my test.php page
sorry my english is not very good
plz help me , i saw this link : http://ir.php.net/ma...n.setcookie.php but i can't debug this code
thanks all














