473,406 Members | 2,352 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Validating Page: Eror message

119 100+
Hi

I am creating login page with validation.

i have index.php page with login box, for validating this login detail i m redirecting to login_validate.php.

Login_validate.php file code:
Expand|Select|Wrap|Line Numbers
  1. <?php 
  2.  
  3. include ("config/config.php");
  4. $dbtable = "users";
  5. $resultvalue =0;
  6. $username = $_POST['usr_name'];
  7. $password = $_POST['usr_pass'];
  8.  
  9.  
  10. $result = mysql_query("SELECT * FROM $dbtable where user_name = '".$username."' and password = '".$password."'");
  11. $resultvalue = mysql_num_rows($result);
  12. $result;
  13. if($resultvalue>0)
  14. {
  15.  echo "<script>window.location='home.php'</script>";
  16. }
  17. else
  18. {
  19. echo "****************** Alertbox [error msg]**************";
  20. //echo "<script>window.location='error.php'</script>";
  21. }
  22. mysql_close();
  23. ?>
  24.  
now what i want to do is i want to display alert box if the user detail is not true,

Can some one help me how to display alert box in that echo field please, i tried java script but, error in that.

Regards
magesh
Dec 30 '08 #1
6 1333
djpaul
137 100+
Hello phpmagesh.
as far as i know you can do it with javascript.
Expand|Select|Wrap|Line Numbers
  1. <Script language="javascript">alert("wrong login attempt!");</script>
Good luck!

P.s. you better change this ($username = $_POST['usr_name'];) to
Expand|Select|Wrap|Line Numbers
  1. $username = strip_tags(mysql_real_escape_string($_POST['usr_name']));
It's much saver for your database!

Regards!
paul
Dec 30 '08 #2
phpmagesh
119 100+
@djpaul

Hi,

thanks for your knid help,

Can you tell me the actual difference for this code please, since i dont know about that so far,

($username = $_POST['usr_name'];) to

$username = strip_tags(mysql_real_escape_string($_POST['usr_name']));

Thanks in advance,

Regards
magesh
Dec 30 '08 #3
djpaul
137 100+
Hey phpmagesh,
These are functions from php.
I always use the manual wich you can download from there site.
These are 2 functions to clean up the mess wich a bad user can insert into your database and hack you.
Try google on mysql_real_escape_string and strip_tags.

Watch your security, it's very important!
Maybe it helps if you read about sql injection and that kind of stuff.

Good luck!
Paul
Dec 30 '08 #4
phpmagesh
119 100+
@djpaul
Hi djpaul,

Thank you for your kind information, this will be useful message for me about the sql injection. if possible can you tell me some sites where i can get this details similar to this since i m creating a dynamic website, Security is more important for me in my site.

Again thank you so much,

Regards
magesh
Dec 30 '08 #5
djpaul
137 100+
Hmm, we have a magic word for it: Google!
Just type in: sql injection php and you find a lot of information about it.
I have an pdf who explains it but it's in dutch, so i think you can't read it... :)
Maybe you recognize the code's but that's not enough i think.

But as far as i know there are more of these pdf's arround the internet.
Try to look arround, if you are not shure if it's save you always can ask it here.
Some people helped me to a while ago, so now i help you and other people!

Good luck!
Paul
Dec 30 '08 #6
Atli
5,058 Expert 4TB
Hi.

For the record, the manual is also available online.
(See strip_tags and mysql_real_escape_string)

You can also read about SQL Injection in the manual.
PHP: SQL Injection - Manual
Dec 30 '08 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: The Plankmeister | last post by:
Hi... What's the best method of validating input characters? I would like to prevent users submitting exotic characters (such as those acquired on Windows Systems by pressing ALT+) and thought...
6
by: mike | last post by:
Hello, After trying to validate this page for a couple of days now I was wondering if someone might be able to help me out. Below is a list of snippets where I am having the errors. 1. Line 334,...
5
by: DeMZed | last post by:
Hi, When validating my web site, I've got the following error : ------------------------------ Line 31, column 26: cannot generate system identifier for general entity "PHPSESSID" <a...
2
by: Chris Dunaway | last post by:
I have a form with a textbox and numerous panels, buttons and other controls. I have handled the textbox Validating and Validated events. The textbox will hold a filename. In the validating...
0
by: Gary Shell | last post by:
I am experiencing some strange behavior between a UserControl's validating event and a treeview control. Initially, I thought it was related to an issue in the Knowledgebase article 810852...
17
by: stathis gotsis | last post by:
Hello everyone, I am tying to come up with an elegant way to process some input data that come from a form. When the user hits the 'Submit' button, i want the form to appear again with the...
7
by: Bruce HS | last post by:
I'd like to call my ancestor Validation Function every time any control on a Win Form generates a Validating or Validated event. I'm using VB. I've extended Textbox, for instance, to have its...
5
by: amatuer | last post by:
hi i have a link from page1 to page2. this link uses a querystring to transfer data. usually i have no problems using querystring t transfer data. bt for the first time page2 does not display.an...
5
by: chadwick | last post by:
Hi everyone - I have a form that contains a TabControl object with 2 tab pages, TabPage1 and TabPage2. TabPage1 contains two text boxes and a cancel button, which closes the form. I would like...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.