473,242 Members | 1,582 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,242 software developers and data experts.

New window opening for checking the authentication in the login form

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
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. // Connects to your Database
  5. mysql_connect('localhost', 'root', 'epara') or die(mysql_error());
  6. mysql_select_db('mysql') or die(mysql_error()); 
  9. //This code runs if the form has been submitted
  10. if (isset($_POST['submit'])) {
  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";
  17. //header('Location:registration.php');
  19. }
  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);
  30. //if the name exists it gives an error
  31. if ($check2 != 0) {
  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. }
  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. }
  43. // here we encrypt the password and add slashes if needed
  44. $_POST['pass'] = md5($_POST['pass']);
  45. //$_POST['pass'] = ($_POST['pass']);
  47. if (!get_magic_quotes_gpc()) {
  48. $_POST['pass'] = addslashes($_POST['pass']);
  49. $_POST['username'] = addslashes($_POST['username']);
  50. }
  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. ?>
  59. <h1>Registered</h1>
  60. <p>Thank you, you have registered - you may now login <a href="index.php"> Login </a>.</p>
  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">
  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>
  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. ?> 
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,
Nov 7 '08 #1
1 1973
938 Expert 512MB
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

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...
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'. ...
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
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...
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...
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...
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...
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...
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...
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

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.