PHP dislike IIS?
Moderator: General Moderators
- peperoni
- Forum Newbie
- Posts: 16
- Joined: Thu Jun 15, 2006 10:52 pm
- Location: Managua, Nicaragua
- Contact:
PHP dislike IIS?
Hi u all,
I'm writin i little application in PHP with SQL Server as Database Manager and IIS as Web Server.
http://georiesgos-ca.amnet.com.ni/servi ... /login.php
The problem is that when i was codin i try it in my PC with SQL Server and Apache but when its on position on the server it doesn't work... Please try admin admin and look how it reload the page... i think isnt the Database because if you enter a wrong user e.g aaa aaaa it shows the error page...
Thanks
See u!
I'm writin i little application in PHP with SQL Server as Database Manager and IIS as Web Server.
http://georiesgos-ca.amnet.com.ni/servi ... /login.php
The problem is that when i was codin i try it in my PC with SQL Server and Apache but when its on position on the server it doesn't work... Please try admin admin and look how it reload the page... i think isnt the Database because if you enter a wrong user e.g aaa aaaa it shows the error page...
Thanks
See u!
- peperoni
- Forum Newbie
- Posts: 16
- Joined: Thu Jun 15, 2006 10:52 pm
- Location: Managua, Nicaragua
- Contact:
feyd | Please use
Now authentication
Login.php
Thanks...
feyd | Please use
Code: Select all
,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]
Conection!Code: Select all
function Conectar(){
if (!($con = mssql_connect("georiesgos-ca","productos","productos"))){
echo "Error conectando el motor base de datos.";
exit();
}
if (!(mssql_select_db("Productos",$con))){
echo "Error seleccionando la base de datos.";
exit();
}
return $con;
}Code: Select all
function UsuarioValido($usuario, $password){
if($usuario =="" || $password=="") return false;
$sql = sprintf("SELECT count(*) FROM usuarios WHERE login_user = '%s' AND passwd_user = '%s'", $usuario, $password);
$con = Conectar();
$resultado = mssql_query($sql,$con);
$fila = mssql_fetch_array($resultado);
if ($fila[0]==1){
return true;
}
else{
return false;
}
}Code: Select all
<?php
if (isset($_POST["cmdEntrar"]) && isset($_POST["txtUsuario"]) && isset($_POST["txtPass"])){
if (UsuarioValido($_POST["txtUsuario"], $_POST["txtPass"])){
$GLOBALS['login']=$_POST["txtUsuario"];
$GLOBALS['passwd']=$_POST["txtPass"];
//Registrar Varibles de Sesion!
session_register('login');
session_register('passwd');
header("Location:index.php");
exit();
}
else {
header("Location:error.php");
}
}
?>feyd | Please use
Code: Select all
,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]In your third script, you have a call to a (deprecated) function session_register(); what version of PHP are you working with? Working with register_globals = On? What does the code that validate the session variables look like, i.e. the code at the top of index.php that checks the user login?
I strongly recommend changing your strategy, if you can possibly update your version of PHP, or at least work without global variables it's a step in the right direction.
I strongly recommend changing your strategy, if you can possibly update your version of PHP, or at least work without global variables it's a step in the right direction.
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
Try this for login. Remember to use session_start() at the beginning of every page within the session realm.
Code: Select all
<?php
session_start();
if (isset($_POST["cmdEntrar"]) && isset($_POST["txtUsuario"]) && isset($_POST["txtPass"])){
if (UsuarioValido($_POST["txtUsuario"], $_POST["txtPass"])){
//Registrar Varibles de Sesion!
$_SESSION['login'] = $_POST["txtUsuario"];
$_SESSION['passwd'] = $_POST["txtPass"];
// Mueve el usario al otra pagina correcto
// usando un URL completamento
header("Location: http://www.fullurl.org/index.php");
exit();
} else {
// La informacion del usario no esta valido
header("Location: http://www.fullurl.org/error.php");
}
}
?>- peperoni
- Forum Newbie
- Posts: 16
- Joined: Thu Jun 15, 2006 10:52 pm
- Location: Managua, Nicaragua
- Contact:
Thank you all for helpin... and sorry about the wrong postin code..
All the session stuff are activated in the php.ini
C u!
PHP Version 5.1.4what version of PHP are you working with?
My php.ini says:Working with register_globals = On?
Code: Select all
; - register_globals = Off [Security, Performance]index.phpWhat does the code that validate the session variables look like
Code: Select all
<?php require_once 'funciones.php';
session_start();
//Revisa si hay una session iniciada.
if(!isset ($_SESSION['login']) ||
!isset ($_SESSION['passwd']) ||
!UsuarioValido($_SESSION['login'],$_SESSION['passwd'])){
header("Location:login.php");
}
?>C u!
- peperoni
- Forum Newbie
- Posts: 16
- Joined: Thu Jun 15, 2006 10:52 pm
- Location: Managua, Nicaragua
- Contact:
Thanks everybody for helpin...
I solved the problem, it was all because using
Thanks Everah your code was all i needed.
We'll keep in touch...
I solved the problem, it was all because using
Code: Select all
session_register();Thanks Everah your code was all i needed.
We'll keep in touch...