473,722 Members | 2,430 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

New window opening for checking the authentication in the login form

2 New Member
Hi All,

I have developed a php applciaiton where a new window is opening on checking the whether valid user orntot how to make that in same window after checking i have die(' not valid user ' ); i even tried with echo also how to solve this the message should come under in the same window only see my code it is
program
----
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. // Connects to your Database
  3.  
  4.  
  5. mysql_connect('localhost', 'root', 'epara') or die(mysql_error());
  6. mysql_select_db('mysql') or die(mysql_error()); 
  7.  
  8.  
  9. //This code runs if the form has been submitted
  10. if (isset($_POST['submit'])) {
  11.  
  12. //This makes sure they did not leave any fields blank
  13. if (!$_POST['username'] | !$_POST['pass'] | !$_POST['pass2'] ) {
  14. die('You did not complete all of the required fields' );
  15. include "registration.php";
  16.  
  17. //header('Location:registration.php');
  18.  
  19. }
  20.  
  21. // checks if the username is in use
  22. if (!get_magic_quotes_gpc()) {
  23. $_POST['username'] = addslashes($_POST['username']);
  24. }
  25. $usercheck = $_POST['username'];
  26. $check = mysql_query("SELECT username FROM login WHERE username = '$usercheck'")
  27. or die(mysql_error());
  28. $check2 = mysql_num_rows($check);
  29.  
  30. //if the name exists it gives an error
  31. if ($check2 != 0) {
  32.  
  33. die( ' <b> Sorry, the username '.$_POST['username'].' is already in use. To Register <a href="registration.php">Please Click Here </b></a>  ');
  34. //header("Location:index.php");
  35. }
  36.  
  37. // this makes sure both passwords entered match
  38. if ($_POST['pass'] != $_POST['pass2']) {
  39. die(' <b> Your passwords did not match. To Register <a href="registration.php"> Please Click Here </b></a> ');
  40. //    header("Location:index.php");
  41. }
  42.  
  43. // here we encrypt the password and add slashes if needed
  44. $_POST['pass'] = md5($_POST['pass']);
  45. //$_POST['pass'] = ($_POST['pass']);
  46.  
  47. if (!get_magic_quotes_gpc()) {
  48. $_POST['pass'] = addslashes($_POST['pass']);
  49. $_POST['username'] = addslashes($_POST['username']);
  50. }
  51.  
  52. // now we insert it into the database
  53. $insert = "INSERT INTO login (username, password)
  54. VALUES ('".$_POST['username']."', '".$_POST['pass']."')";
  55. $add_member = mysql_query($insert);
  56. ?>
  57.  
  58.  
  59. <h1>Registered</h1>
  60. <p>Thank you, you have registered - you may now login <a href="index.php"> Login </a>.</p>
  61.  
  62. <?php
  63. }
  64. else
  65. {
  66. ?>
  67. <html>
  68. <body>
  69. <table cellpadding="0" cellspacing="0" border="0">
  70. <tr valign="baseline">
  71.       <td>
  72.       <div align="left"><img src="images/home_masthead.gif" width="141" height="67"/></div></td>
  73.       <td width="212" align="center"></td>
  74.       <td width="371" align="right" valign="baseline"></td>
  75.       </tr>
  76.       </table>
  77.       <table cellpadding="0" cellspacing="0" border="0" align="right" valign="top">
  78.  
  79.   <tr>
  80.   <td><a href="index.html"><img src="images/nav_images/home.gif" alt="Home" border="0"/></a></td>
  81.   <td><a href="registration.php"> 
  82.     <img src="images/nav_images/company_sec.gif" alt="Registration" border="0"/></a></td>
  83.     <td><a href="login.php"> 
  84.     <img src="images/nav_images/careers_sec.gif" alt="Login" border="0"/></a></td>
  85.   </tr>
  86.   </table><br><br><br>
  87. <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
  88. <p><b> Registration form please fill all the fields</b></p>
  89. <table border="0">
  90. <tr><td><b>Username:</b></td><td>
  91. <input type="text" name="username" maxlength="60">
  92. </td></tr>
  93. <tr><td><b>Password:</b></td><td>
  94. <input type="password" name="pass" maxlength="10">
  95. </td></tr>
  96. <tr><td><b>Confirm Password:</b></td><td>
  97. <input type="password" name="pass2" maxlength="10">
  98. </td></tr>
  99. <tr><td></td></tr>
  100. <tr><th colspan=2><input type="submit" name="submit" value="Register"></th></tr> </table>
  101.  
  102. <tr><td></td></tr>
  103. </table>
  104. </form>
  105. </html>
  106. <br><br><br><br>
  107. <div class="small_text" align="center"><b>@</b><b>2008 Paradigm Consulting, Inc. All rights reserved.<b></div>
  108. </body></html>
  109. <?php
  110. }
  111. ?> 
  112.  
---
when running this it is going to different page the authentications please suggest me the answer as early as possible this whole code is in one page only not in separate pages.

Thanks in Advance,
Geeta
Nov 7 '08 #1
1 2009
nathj
938 Recognized Expert Contributor
You need to post code in code tags! It makes easier to read, more importantly it's the rules.
Nov 7 '08 #2

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

Similar topics

1
3792
by: Display Name | last post by:
the customer I'm developing a site for uses a canned form-parsing page that allows her to have an email subscription opt-in page add emails to a list she can manage using a link that you point your HTML form to. the actual form-parsing page resides on a server that's uneditable to me since it sits on an inaccessible server. my problem is more irritating than anything; everything double-submits.. when you submit the form, I've forced a...
0
1583
by: Scott | last post by:
The error is "The Web Server reported the following error when attempting to create or open the Web project located at the following URL: "http://localhost". 'The HTTP redirect request failed'. There is a value in the web.config that we use to auto login us developers so that we are not prompted to go to our login page each time we open the website for debugging. Our login page looks for this particular string, and logs us in...
19
2897
by: Wouter | last post by:
Hi, I try to make when i send a <form> that he dont open a new window. Is there someone who know how i can make this whit javascript ? Greets Wouter
3
4868
by: Kris van der Mast | last post by:
Hi, I've created a little site for my sports club. In the root folder there are pages that are viewable by every anonymous user but at a certain subfolder my administration pages should be protected by forms authentication. When I create forms authentication at root level it works but when I move my code up to the subfolder I get this error: Server Error in '/TestProjects/FormsAuthenticationTestingArea' Application.
1
1411
by: David Krussow | last post by:
I have implemented ASP.NET Forms authentication in a test app. The app has a number of forms - only one of which requires authentication in order to be viewed (the "secured form"). Everything works as the documentation says it should - with the exception that on subsequent browser sessions, the single form that should require authentication in order to be viewed does, in fact, display without the login form first appearing. In other words,...
6
517
by: Manny Chohan | last post by:
I am using forms authetication in the web config. i can validate a user against a database and click on images which makes hidden panels visible.However when i click on the link inside a panel which should take user to another pages, it defaults them back to the login page prompting them to enter username and password. Could someone please shed some light on this on how i can fix this issue? Thanks Manny
3
2027
by: kermit | last post by:
Hi, I am hoping this is a foolish or simple question. I am creating a multiuser app. consisit of a login page and a dataentry page. If the user leaves the data entry page (other than exiting the browser). I want them to 'have' to go back through the login screen and re-login. My problem is the browser's (IE 6) Back and Forward buttons. If the user clicks the Back button from the data entry screen they go to the login in screen and if...
6
3344
by: Ming Zhang | last post by:
Hi guys, I have couple of ASP.NET applications that only support digest windows authentication, and credentials are managed in a central AD. When users login to one app, they can easily navigate to other apps without reenter UID/PWD. Everything works except it doesn't meet our security policy for new created users. When creating a new user, it's required to have "user must change password when first time login". In this case, the user will...
1
1427
by: noor | last post by:
hi, can any one tell me a javascript that can be called on mouseover event of a html link control . script can check from session either a user is login or not In the case of Login it will redirect to the given url. In the case of not Login it will prompt the user that u r not login kindly login. actually that link leads a user to Download Software. but this feature is only for registerd user.
0
8863
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8739
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
9157
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9088
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5995
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4502
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3207
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2602
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2147
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.