Jump to content

Restricting all email addresses that sign up to one domain


dan182skater

Recommended Posts

Hello. I am using a script that has an option in the admin backend to restrict certain domains for email adresses. But I want to do the opposite: restrict all but one domain (or 2 or 3 in the future). In the admin section of the script, it says "Admin: Email Domain Checker"
--Restricted Email Domains: domain1.com, domain2.com, domain3.com, etc. Then it says "Add", "Edit", or "Delete". Then those 3 domains that I specified in the admin section (domain1.com, domain2.com, and domain3.com) are the ones that cannot be used to register on the front end of the site. So to clerify what I said before, I want it so that when I type in domain1.com, domain2.com, and domain3.com, those are the ONLY ones that email addresses ending in those can register. Here is the code for the register page that talks about the domain name checker function:

From join.php
[code]if($conf['domain_checker']=="on" && check_domain($email))
error_screen(42);[/code]

Here is the code that states the function in the admin backend:

From settings.php
[code]case 'domain_checker': $_option = '<b>Email Domain Checker</b>'.$chk_fld;break;[/code]

[code] <tr>
<td class='lined title' colspan="2"><a name="domain">Admin: Email Domain Checker</a></td>
    </tr>
<tr>
    <td align="center" colspan="2"><table border="0" width="100%" cellspacing="0" cellpadding="2" bordercolor="#cccccc" class="body">
        <form action="admin.php#domain" method="post">
    <input type="hidden" name="mode" value="settings">
    <input type="hidden" name="adsess" value="<?=$adsess?>">
        <tr><td>Restricted Email Domains:</td></tr>
    <?
    $res = sql_execute("SELECT * FROM domains ORDER BY id","res");
    while($row = mysql_fetch_object($res)){
        echo "<tr><td><input type=\"checkbox\" name=\"domains[".$row->id."]\"> ".$row->domain."</td></tr>";
    }
    ?>
        <tr><td><input type="text" name="domain_name" value="">&nbsp;&nbsp;<input type="submit" name="submit" value="Add">&nbsp;&nbsp;<input type="submit" name="submit" value="Edit">&nbsp;&nbsp;<input type="submit" name="submit" value="Delete"></td></tr></form></table></td>
    </tr>
<tr><td>&nbsp;</td></tr>[/code]

Help is needed ASAP as this project I am working on is for my school and needs to be done within this week. ANY HELP IS GREATLY APPRECIATED!! Thank you in advance!
Link to comment
Share on other sites

here is how I would do it in general
first create a table with the allowed domains.
next make an form with a text field to get the first part of the email address and second a dropdownbox that only displays the allowed domains.
this way you will only get email adresses from the domains you listed.

you can look at something similar here

http://kyushunetwork.com/index.php?page=register1

I am not sure if this is what you want

anatak
Link to comment
Share on other sites

One solution is:
[code]

<?php

function valid_e_domain($email)
{
$forbidden = array('hotmail','bogus');
foreach($forbidden as $domain)
{
if (eregi("@".$domain.".", $email))
{
  return false; break;
}
}
return true;
}


if(!empty($_POST['email']) && valid_e_domain($_POST['email']))
{
echo "accepted";
}
else
{
echo "NOT accepted";
}


?>

[/code]
Link to comment
Share on other sites

Hey! Thanks for your response but I just thought of something that you might be able to help me with for a few seconds. I decided that I am going to just have the text box for the email on the registration page and after that text box I'll just type in @berkeley.edu. So I need a simple function that makes sure that the text box before the "@berkeley.edu" has only characters that would be in the first part of an email address. Then I want it to insert the email address into the database by automatically adding the @berkeley.edu. I will only be using that domain so there is no need for any others and once again, I just want that @berkeley.edu inserted into the database after the first part of the email address automatically. Let me know if you can help. THANKS!
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.