Jump to content

new username


garydt

Recommended Posts

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

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

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.