473,480 Members | 1,814 Online
Bytes | Software Development & Data Engineering Community
Create 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 1990
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
3742
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...
0
1554
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'. ...
19
2871
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
4835
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...
1
1398
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...
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...
3
2000
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...
6
3295
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...
1
1409
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...
0
6903
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
7027
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6726
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...
0
6861
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...
0
5318
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,...
1
4763
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...
0
4468
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...
0
1291
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 ...
1
557
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.