Jump to content

after the alert message button it suppose to be on registration site


shebbycs

Recommended Posts

registration.php

<html>
<body>

  <form name="register" method="post" action="login.php"  //onsubmit="return a()">
  <table border='0'>
  <tr><td>Username:</td><td><input type='text'name='username' maxlength='60'></td></tr>
  <tr><td>Password:</td><td><input type='password' name='pass' maxlength='10'></td></tr>
  <tr><td>Confirm Password:</td><td><input type='password' name='pass2' maxlength='10'></td></tr>
  <tr><th colspan=2><input type='submit' name='sub' value='Register'></th></tr> </table>
  </form>  
  <body>
</html>

 

 

 

and this direct to login page where the code is

 

<?php

mysql_connect("localhost","root") or die(mysql_error());

mysql_select_db("Regis") or die(mysql_error());  

  if (isset($_POST['sub']))
         {
          $message=strip_tags($message);



         if (!$_POST['username'] | !$_POST['pass'] | !$_POST['pass2'] )
            {

	       echo("<SCRIPT LANGUAGE='JavaScript'>window.alert('You did not complete all of the required fields')</SCRIPT>");
	       return false;
             }


        // checks if the username is in use

        if (!get_magic_quotes_gpc())
       {
        $_POST['username'] = addslashes($_POST['username']);
       }

        $usercheck = $_POST['username'];

        $check = mysql_query("SELECT username FROM registration WHERE username = '$usercheck'")

         or die(mysql_error());

        $check2 = mysql_num_rows($check);


       //if the name exists it gives an error

       if ($check2 != 0)
      {
       print ('Sorry, the username '.$_POST['username'].' is already in use.');
      }

      if ($_POST['pass'] != $_POST['pass2']) 
      {
        print ('Your passwords did not match. ');
      }

     

      // here we encrypt the password and add slashes if needed

       $_POST['pass'] = md5($_POST['pass']);

       if (!get_magic_quotes_gpc())
      {
       $_POST['pass'] = addslashes($_POST['pass']);

       $_POST['username'] = addslashes($_POST['username']);
      }

      // now we insert it into the database

     if($_POST['username'] && $_POST['pass'] && $_POST['pass2'] )
     {
     $insert = "INSERT INTO registration (username, password) VALUES ('".$_POST['username']."', '".$_POST['pass']."')";
     $add_member = mysql_query($insert);

     echo("<SCRIPT LANGUAGE='JavaScript'>window.alert('Registration had been succesfully added ')</SCRIPT>");

     }

   }



//if the login form is submitted 

/* if (isset($_POST['submit']))
  {


// makes sure they filled it in

	if(!$_POST['username'] | !$_POST['pass']) 
         {

	   die('You did not fill in a required field.');

	 }

	// checks it against the database



	if (!get_magic_quotes_gpc())
         {

           $_POST['email'] = addslashes($_POST['email']);
      
         }

	$check = mysql_query("SELECT * FROM registration WHERE username = '".$_POST['username']."'")or die(mysql_error());



//Gives error if user dosen't exist

$check2 = mysql_num_rows($check);

if ($check2 == 0)
{
  die('That user does not exist in our database. <a href=register.php>Click Here to Register</a>');
}



while($info = mysql_fetch_array( $check ))

{

  $_POST['pass'] = stripslashes($_POST['pass']);

  $info['password'] = stripslashes($info['password']);

  $_POST['pass'] = md5($_POST['pass']);



//gives error if the password is wrong

	if ($_POST['pass'] != $info['password'])
          
          {

            die('Incorrect password, please try again.');

	  }
}
}

  else

{



// if they are not logged in 

?> 

<form action="submit.php" method="post">

<table border="0"> 

<tr><td colspan=2><h1>Login</h1></td></tr> 

<tr><td>Username:</td><td> 

<input type="text" name="username" maxlength="40"> 

</td></tr> 

<tr><td>Password:</td><td> 

<input type="password" name="pass" maxlength="50"> 

</td></tr> 

<tr><td><a href=register.php>Register</a></td>

<td><input type="submit" name="submit" value="Login">

</td></tr> 

</table> 

</form> 

<?php 

}         */



?> 

 

My problem is when the code is reading this statement

 

if (!$_POST['username'] | !$_POST['pass'] | !$_POST['pass2'] )

            {

 

      echo("<SCRIPT LANGUAGE='JavaScript'>window.alert('You did not complete all of the required fields')</SCRIPT>");

      return false;

            }

 

ya it is appear that alert box but it will direct to login page im want it to be in registration page any modification on my code?

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.