garydt Posted February 22, 2007 Share Posted February 22, 2007 When a new user tries to register an username that already exists, instead of being redirected to another page i want a window pop-up to happen. How do i do that? Here's what I've got so far. // *** Redirect if username exists $MM_flag="MM_insert"; if (isset($_POST[$MM_flag])) { $MM_dupKeyRedirect="usernmm.php"; $loginUsername = $_POST['usernamein']; $LoginRS__query = sprintf("SELECT usernamf FROM info WHERE usernamf=%s", GetSQLValueString($loginUsername, "text")); mysql_select_db($database_regdb, $regdb); $LoginRS=mysql_query($LoginRS__query, $regdb) or die(mysql_error()); $loginFoundUser = mysql_num_rows($LoginRS); //if there is a row in the database, the username was found - can not add the requested username if($loginFoundUser){ $MM_qsChar = "?"; //append the username to the redirect page if (substr_count($MM_dupKeyRedirect,"?") >=1) $MM_qsChar = "&"; $MM_dupKeyRedirect = $MM_dupKeyRedirect . $MM_qsChar ."requsername=".$loginUsername; header ("Location: $MM_dupKeyRedirect"); exit; } } Link to comment https://forums.phpfreaks.com/topic/39697-new-username/ Share on other sites More sharing options...
magic2goodil Posted February 22, 2007 Share Posted February 22, 2007 something simple would be just instead of the header command try like: echo "<script> window.open('".$MM_dupKeyRedirect."'); </script>"; Link to comment https://forums.phpfreaks.com/topic/39697-new-username/#findComment-191643 Share on other sites More sharing options...
garydt Posted February 22, 2007 Author Share Posted February 22, 2007 I tried doing that but no pop-up window came up, just a blank normal window. Heres what i got now- // *** Redirect if username exists $MM_flag="MM_insert"; if (isset($_POST[$MM_flag])) { $MM_dupKeyRedirect="usernmm.php"; $loginUsername = $_POST['usernamein']; $LoginRS__query = sprintf("SELECT usernamf FROM info WHERE usernamf=%s", GetSQLValueString($loginUsername, "text")); mysql_select_db($database_regdb, $regdb); $LoginRS=mysql_query($LoginRS__query, $regdb) or die(mysql_error()); $loginFoundUser = mysql_num_rows($LoginRS); //if there is a row in the database, the username was found - can not add the requested username if($loginFoundUser){ $MM_qsChar = "?"; //append the username to the redirect page if (substr_count($MM_dupKeyRedirect,"?") >=1) $MM_qsChar = "&"; $MM_dupKeyRedirect = $MM_dupKeyRedirect . $MM_qsChar ."requsername=".$loginUsername; echo "<script> window.open('".$MM_dupKeyRedirect."'); </script>"; exit; } } Link to comment https://forums.phpfreaks.com/topic/39697-new-username/#findComment-191682 Share on other sites More sharing options...
ki Posted February 22, 2007 Share Posted February 22, 2007 you want like an alert box? echo "<script> alert(".$value."); </script>"; Link to comment https://forums.phpfreaks.com/topic/39697-new-username/#findComment-191693 Share on other sites More sharing options...
garydt Posted February 23, 2007 Author Share Posted February 23, 2007 no. When the user clicks submit i want the page to stay and a popup to come up saying 'that username exists' How can i do that? Link to comment https://forums.phpfreaks.com/topic/39697-new-username/#findComment-192036 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.