Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.
Moderator: General Moderators
chrisso
Forum Newbie
Posts: 10 Joined: Sat May 06, 2006 6:50 am
Post
by chrisso » Sat May 06, 2006 10:32 pm
feyd | Please use Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
I've tried to write a login script.
But when I try to load the login page, nothing's showing up :S
What's wrong with this script? :Code: Select all
<?
$link = mysql_connect($dbhost, $dbuname, $dbpw);
if (!$link) {
die('Could not connect: ' . mysql_error());
}
$db_selected = mysql_select_db($dbname, $link);
if (!$db_selected) {
die ('Can\'t use foo : ' . mysql_error());
}
$username = $_POST["uname"];
$password = $_POST["pwd"];
$result = mysql_query("SELECT * FROM `cw_user` WHERE uname = '$username'");
$array = mysql_fetch_assoc($result) or die (mysql_error());
if($username == $array['uname'] and md5($password) == $array['passwd'] and $array['admin'] == 1){
$_SESSION["logged_in"] = TRUE;
$_SESSION["admin"] = TRUE;
$result = TRUE;
} else { $result = FALSE; }
if($result){ echo "Du er logget inn!"; } else { echo "Du har skrevet en feil kombinasjon av brukernavn og passord!";}
echo $array['uname'];
?>
Thank you
feyd | Please use Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Sat May 06, 2006 10:35 pm
Run the following in a new file and tell us the results please.
Code: Select all
<?php
$ve = phpversion();
$os = PHP_OS;
$er = intval(error_reporting());
$rg = (in_array(strtolower(ini_get('register_globals')), array(0, false, '', null, 'off')) ? 'Off' : 'On');
$de = (in_array(strtolower(ini_get('display_errors')), array(0, false, '', null, 'off')) ? 'Off' : 'On');
$so = (in_array(strtolower(ini_get('short_open_tag')), array(0, false, '', null, 'off')) ? 'Off' : 'On');
$eol = (isset($_SERVER['HTTP_HOST']) ? "<br />\n" : "\n");
$ec = array(
'E_STRICT' => 2048,
'E_ALL' => 2047,
'E_USER_NOTICE' => 1024,
'E_USER_WARNING' => 512,
'E_USER_ERROR' => 256,
'E_COMPILE_WARNING' => 128,
'E_COMPILE_ERROR' => 64,
'E_CORE_WARNING' => 32,
'E_CORE_ERROR' => 16,
'E_NOTICE' => 8,
'E_PARSE' => 4,
'E_WARNING' => 2,
'E_ERROR' => 1,
);
$e = array();
$t = $er;
foreach ($ec as $n => $v)
{
if (($t & $v) == $v)
{
$e[] = $n;
$t ^= $v;
}
}
$er = $er . ' (' . implode(' | ', $e) . ')';
echo 'PHP Version: ' . $ve . $eol;
echo 'PHP OS: ' . $os . $eol;
echo 'Error Reporting: ' . $er . $eol;
echo 'Register Globals: ' . $rg . $eol;
echo 'Short Tags: ' . $so . $eol;
echo 'Display Errors: ' . $de . $eol;
?>
chrisso
Forum Newbie
Posts: 10 Joined: Sat May 06, 2006 6:50 am
Post
by chrisso » Sat May 06, 2006 10:58 pm
I don't how I did it, but now it works :S
Thank you anyway.. Nice to see that ppl are helpful
dibyendrah
Forum Contributor
Posts: 491 Joined: Wed Oct 19, 2005 5:14 am
Location: Nepal
Contact:
Post
by dibyendrah » Sun May 07, 2006 2:55 am
Thanx feyd for the script . Really helpfull for finding PHP environment variable withour viewing php.ini
It displays the following for me :
Code: Select all
PHP Version: 5.1.2-1
PHP OS: Linux
Error Reporting: 2039 (E_USER_NOTICE | E_USER_WARNING | E_USER_ERROR | E_COMPILE_WARNING | E_COMPILE_ERROR | E_CORE_WARNING | E_CORE_ERROR | E_PARSE | E_WARNING | E_ERROR)
Register Globals: Off
Short Tags: On
Display Errors: On
Cheers,
Dibyendra