darubillah Posted September 15, 2009 Share Posted September 15, 2009 hi, I want my users to use specific e-mail address that mean, when ever my user register on my site services they will use only my e-mail service @thextremezik.com following is my registering code <?php /*** Pirates of the Black Sea | Check RPGBUNNY.COM for more Full RPG Sources | www.rpgbunny.com ***/include "antet.php"; include "func.php"; $config=config(); if (!$config[3][1]) msg($lang['regClosed']); $factions=factions(); $_SESSION["code"]=rand(1000, 9999); ?> <html> <?php echo "<link rel='stylesheet' type='text/css' href='".$imgs.$fimgs."default.css'>"; ?> <head> <title><?php echo $title; ?> - <?php echo $lang['register'] ?></title> </head> <body class="q_body"> <link rel="stylesheet" type="text/css" href="layout/css/css/style.css"/> <div align="left"> <table class="q_table"> <form name="form1" method="post" action="register_.php"> <label><?php echo $lang['username'] ?> <input class='textbox' type="text" name="name"> </label> <p> <label><?php echo $lang['password'] ?> <input class='textbox' type="password" name="pass"> </label> </p> <p> <label><?php echo $lang['retypePass'] ?> <input class='textbox' type="password" name="pass_"> </label> </p> <p> <label><?php echo $lang['validEmail'] ?> <input class='textbox' type="text" name="email"> </label> </p> <p> <label><?php echo $lang['faction'] ?> <select class='dropdown' name="faction"> <?php for ($i=0; $i<count($factions); $i++) echo "<option value='".$i."'>".$factions[$i][1]."</option>"; ?> </select> </label> </p> <p> <label><?php echo $lang['typeCode'] ?> '<?php echo $_SESSION["code"];?>'<img src="captcha.php"> <input class='textbox' type="text" name="code"> </label> </p> <p> <label> <input class='button' type="submit" name="reg" value="<?php echo $lang['submit'] ?>"> </label> </p> </form> </td> </tr> </table> </div> </body> </html> see registeration page http://piratesoftheblacksea.thextremezik.com/ please help me Quote Link to comment https://forums.phpfreaks.com/topic/174337-how-to-restrict-user-to-use-a-specific-e-mail-address-when-registering/ Share on other sites More sharing options...
backie Posted September 15, 2009 Share Posted September 15, 2009 Use regex. Something like preg_match("/[a-z0-9_\-\.]+\@thextremezik\.com/i",$EmailVar); should do the trick. Quote Link to comment https://forums.phpfreaks.com/topic/174337-how-to-restrict-user-to-use-a-specific-e-mail-address-when-registering/#findComment-919042 Share on other sites More sharing options...
Garethp Posted September 15, 2009 Share Posted September 15, 2009 Even easier if(!preg_match('~\@thextremezik\.com$~i', $EmailVar)) Quote Link to comment https://forums.phpfreaks.com/topic/174337-how-to-restrict-user-to-use-a-specific-e-mail-address-when-registering/#findComment-919045 Share on other sites More sharing options...
backie Posted September 15, 2009 Share Posted September 15, 2009 In theory the second one is easier, but it can allow for invalid emails to be validated which could lead to all sorts of problems depending on what you use the email address for. It did point out to me I forgot "$" at the end of my regex example. Quote Link to comment https://forums.phpfreaks.com/topic/174337-how-to-restrict-user-to-use-a-specific-e-mail-address-when-registering/#findComment-919046 Share on other sites More sharing options...
Psycho Posted September 15, 2009 Share Posted September 15, 2009 Even easier, don't allow the user to enter in their domain at all, just the username portion of the email. Then in your code, assume that the domina is the one you specify. On the actual form, display the domain name to the right of the input field so the user understands that the domain is assumed <input type="text" name="uname" > @thextremezik.com Then just validate that the value has letters, numbers, undercore, dash, plus sign & periods. Of course the value can't begin or end with a period or have two periods in succession. Quote Link to comment https://forums.phpfreaks.com/topic/174337-how-to-restrict-user-to-use-a-specific-e-mail-address-when-registering/#findComment-919051 Share on other sites More sharing options...
darubillah Posted September 16, 2009 Author Share Posted September 16, 2009 thank you for your answers can you please tell me where I should add this code, or please add this code for me This one if(!preg_match('~\@thextremezik\.com$~i', $EmailVar)) or any other thanks Quote Link to comment https://forums.phpfreaks.com/topic/174337-how-to-restrict-user-to-use-a-specific-e-mail-address-when-registering/#findComment-919438 Share on other sites More sharing options...
darubillah Posted September 16, 2009 Author Share Posted September 16, 2009 whats $EmailVar = ? I am new in php Quote Link to comment https://forums.phpfreaks.com/topic/174337-how-to-restrict-user-to-use-a-specific-e-mail-address-when-registering/#findComment-919440 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.