Jump to content

Can you show the registration.php with session


shebbycs

Recommended Posts

 

 

<html>
<head>
<script type="text/javascript">
  function a()
{
   var x = document.register.username.value;
   var y = document.register.pass.value;
   var z = document.register.pass2.value;
   
   if(x==""&& y==""&& z=="")
   {
    alert("Please insert all message!");
    return false;
   }
   if(x=="")
   {
     alert("Please insert an username!");
     return false;
   }
   if(y=="")
   {
     alert("Please insert an password!");
     return false;
   }
   if(z=="")
   {
     alert("Please insert an password2!");
     return false;
   }
   
   if (y!=z)
   {
     alert("Your passwords did not match");
     return false;
   }
   



}
</script>
</head>
<?php
    mysql_connect("localhost","root") or die(mysql_error());
    mysql_select_db("cute") or die(mysql_error());


     if (isset($_POST["sub"]))
     {
        $_POST['pass'] = md5($_POST['pass']);
      if (!get_magic_quotes_gpc())
       {
        $_POST['username'] = addslashes($_POST['username']);
        $_POST['pass'] = addslashes($_POST['pass']);
      }


       $usercheck = $_POST["username"];

       $check = mysql_query("SELECT username FROM regis WHERE username = '$usercheck'") or die(mysql_error());

       $check2 = mysql_num_rows($check);
        //if the name exists it gives an error
     if ($check2 != 0)
     {
      echo("<SCRIPT LANGUAGE='JavaScript'>window.alert('Sorry, the username" ." ".$usercheck." ". "is already in use.')</SCRIPT>");
      echo ("<SCRIPT LANGUAGE='JavaScript'>setTimeOut(window.location = 'registration.php',1)</script>");

     }

      else if($_POST['username'] && $_POST['pass'] && $_POST['pass2'] )
     {
      $insert = "INSERT INTO regis(username, password) VALUES ('".$_POST['username']."', '".$_POST['pass']."')";
      $add_member = mysql_query($insert);
      echo("<SCRIPT LANGUAGE='JavaScript'>window.alert('Registration had been succesfully added ')</SCRIPT>");
     }

     }
     
?>
<body>



  <form name="register" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"  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>

 

 

This my registration page can you show how to redirect to login.php using $SESSION and also it kept the username information in session

 

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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