Jump to content

404 Error after login


alphasil

Recommended Posts

Hi

 

I'm getting this error but i'm sure the file is there, this is my code where i'm having this problem

elseif($_POST["page"] == "users_login") 
	{
		$user_utilizador = trim(strip_tags($_POST['email']));
		$user_password = trim(strip_tags($_POST['passwd']));
		$encrypted_md5_password = md5($user_password);
		$validate_user_information = mysql_query("select * from `utilizador` where `utilizador` = '".mysql_real_escape_string($user_utilizador)."' and `password` = '".mysql_real_escape_string($encrypted_md5_password)."'");
		echo $validate_user_information;
		if(mysql_num_rows($validate_user_information) == 1)
		{
			$get_user_information = mysql_fetch_array($validate_user_information);
			$_SESSION["VALID_USER_ID"] = $user_utilizador;
			$_SESSION["USER_FULLNAME"] = strip_tags($get_user_information["nome"]);
			echo 'index.php?uid='.$_SESSION["USER_FULLNAME"].'&';
			echo 'login_process_completed_successfully=yes';
		}
		else
		{
			echo '<br><div class="info">Desculpe, a informação fornecida está errada. Corrije-a por favor. Obrigado.</div><br>';
		}
	}

So after the login process it should open the index.php 

I have try with

header(Location: index,php) and the details are displayed in the same page as the login...

 

any help please?

Thanks

 

 

Link to comment
Share on other sites

Thank you for your help

 

Yes i have error display but there is error right now, i don't have the 404 error but another issue

I put the header and now the login page and the index page are displayed at same time after login. Why the login page not close? 

elseif($_POST["page"] == "users_login") 
	{
		$user_utilizador = trim(strip_tags($_POST['email']));
		$user_password = trim(strip_tags($_POST['passwd']));
		$encrypted_md5_password = md5($user_password);
		$validate_user_information = mysql_query("select * from `utilizador` where `utilizador` = '".mysql_real_escape_string($user_utilizador)."' and `password` = '".mysql_real_escape_string($encrypted_md5_password)."'");
		if(mysql_num_rows($validate_user_information) == 1)
		{
			$get_user_information = mysql_fetch_array($validate_user_information);
			$user_nome = $get_user_information["nome"];
			$_SESSION["VALID_USER_ID"] = $user_utilizador;
			$_SESSION["USER_FULLNAME"] = $user_nome;
			header("Location: index.php");
		}
		else
		{
			echo '<br><div class="info">Desculpe, a informação fornecida está errada. Corrije-a por favor. Obrigado.</div><br>';
		}
	}
Link to comment
Share on other sites

You should place a exit() call immediately after header(), otherwise the rest of the script continues processing.

 

Also, md5 is not encryption, nor is it safe. Please read this: http://jeremykendall.net/2014/01/04/php-password-hashing-a-dead-simple-implementation/

 

And you should not be using the mysql functions -- they will being going away in a future version of PHP -- but rather using mysqli or PDO along with prepared statements.

Edited by boompa
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.