- Messages
- 232
- Reaction score
- 0
- Points
- 26
Re: Mga Tanong tungkol sa PHP, CSS, jquery, HTML at MySQL pasok D2
Help naman po:
Warning: session_register() [function.session-register]: Cannot send session cookie - headers already sent by (output started at C:\xampp\htdocs\Gunsmith\web\checklogin.php:9) in C:\xampp\htdocs\Gunsmith\web\checklogin.php on line 39
Warning: session_register() [function.session-register]: Cannot send session cache limiter - headers already sent (output started at C:\xampp\htdocs\Gunsmith\web\checklogin.php:9) in C:\xampp\htdocs\Gunsmith\web\checklogin.php on line 39
Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\Gunsmith\web\checklogin.php:9) in C:\xampp\htdocs\Gunsmith\web\checklogin.php on line 41
Warning: Unknown: Your script possibly relies on a session side-effect which existed until PHP 4.2.3. Please be advised that the session extension does not consider global variables as a source of data, unless register_globals is enabled. You can disable this functionality and this warning by setting session.bug_compat_42 or session.bug_compat_warn to off, respectively in Unknown on line 0
Yan ung sinasabi nya pag nag-lologin ako.
eto codes ng checklog.php
eto naman ung sa login_success.php
ok na po to mga sir. napagana ko na.
Help naman po:
Warning: session_register() [function.session-register]: Cannot send session cookie - headers already sent by (output started at C:\xampp\htdocs\Gunsmith\web\checklogin.php:9) in C:\xampp\htdocs\Gunsmith\web\checklogin.php on line 39
Warning: session_register() [function.session-register]: Cannot send session cache limiter - headers already sent (output started at C:\xampp\htdocs\Gunsmith\web\checklogin.php:9) in C:\xampp\htdocs\Gunsmith\web\checklogin.php on line 39
Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\Gunsmith\web\checklogin.php:9) in C:\xampp\htdocs\Gunsmith\web\checklogin.php on line 41
Warning: Unknown: Your script possibly relies on a session side-effect which existed until PHP 4.2.3. Please be advised that the session extension does not consider global variables as a source of data, unless register_globals is enabled. You can disable this functionality and this warning by setting session.bug_compat_42 or session.bug_compat_warn to off, respectively in Unknown on line 0
Yan ung sinasabi nya pag nag-lologin ako.
eto codes ng checklog.php
<?php
$host="localhost"; // Host name
$username="root"; // Mysql username
$password=""; // Mysql password
$db_name="db_login"; // Database name
$tbl_name="members"; // Table name
// Connect to server and select databse.
mysql_connect($host,$username,$password) or die ("Unable to connect");
mysql_select_db($db_name)or die("Cannot select DB");
// username and password sent from form
$myusername=$_POST['myusername'];
$mypassword=$_POST['mypassword'];
// To protect MySQL injection (more detail about MySQL injection)
$myusername = stripslashes($myusername);
$mypassword = stripslashes($mypassword);
$myusername = mysql_real_escape_string($myusername);
$mypassword = mysql_real_escape_string($mypassword);
$sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'";
$result=mysql_query($sql);
// Mysql_num_row is counting table row
$count=mysql_num_rows($result);
// If result matched $myusername and $mypassword, table row must be 1 row
if($count==1){
// Register $myusername, $mypassword and redirect to file "login_success.php"
session_register("myusername");
session_register("mypassword");
header("location:login_success.php");
}
else {
echo "Wrong Username or Password";
}
?>
eto naman ung sa login_success.php
// Check if session is not registered , redirect back to main page.
// Put this code in first line of web page.
<?
session_start();
if(!session_is_registered(myusername)){
header("location:index.php");
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
Login Successful
</body>
</html>
ok na po to mga sir. napagana ko na.
Last edited: