shebbycs Posted November 19, 2011 Share Posted November 19, 2011 <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 Quote Link to comment https://forums.phpfreaks.com/topic/251410-can-you-show-the-registrationphp-with-session/ Share on other sites More sharing options...
trq Posted November 19, 2011 Share Posted November 19, 2011 $SESSION should be $_SESSION and it has nothing to do with redirection. There are however plenty of tutorials already around that cover how to use sessions. Do you really want us to write one just for you? Quote Link to comment https://forums.phpfreaks.com/topic/251410-can-you-show-the-registrationphp-with-session/#findComment-1289461 Share on other sites More sharing options...
shebbycs Posted November 19, 2011 Author Share Posted November 19, 2011 sure sir as im learning to do session Quote Link to comment https://forums.phpfreaks.com/topic/251410-can-you-show-the-registrationphp-with-session/#findComment-1289464 Share on other sites More sharing options...
shebbycs Posted November 20, 2011 Author Share Posted November 20, 2011 Sir im thinks you show the example of php with session with user level too Quote Link to comment https://forums.phpfreaks.com/topic/251410-can-you-show-the-registrationphp-with-session/#findComment-1289677 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.