News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

limited registration

Started by Darkorical, April 08, 2008, 03:04:40 PM

Previous topic - Next topic

Darkorical

alright my company has a website that we only want for our existing customers is there a way to make it so if you click on the registration button it  popps up a window  and says the features you are trying to access are for existing customers only please enter your customer number to contenue. Then they enter their number and it checks against something like an xml file to see if they are on the list if they are they get to the registration page if not they get a page taht says please contact customer service about setting up an account.

also if its not too much to ask it would be nice if it automatically adds the customer number (assuming its valid) as the username and not let them change it.

Darkorical

alright I have been working on this and thus far I have made this file


<?php$xmlDoc = new DOMDocument();$xmlDoc->load("custxml.xml");$x=$xmlDoc->getElementsByTagName('custnum');//get the q parameter from URL$q= ucfirst ($_POST["passwd"]);//lookup all links from the xml file if length of q>0$password= "NOTHING!";if (strlen($q) > 5){$hint="";for($i=0; $i<($x->length); $i++) {     $y=$x->item($i)->getElementsByTagName('cust'); if ($y->item(0)->nodeType==1)  {  //find a link matching the search text  if (stristr($y->item(0)->childNodes->item(0)->nodeValue,$q))   {   if ($hint=="")    {    $password= $y->item(0)->childNodes->item(0)->nodeValue; break;    }   }  } }}echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd"><html><head>   <title>Customer ID</title>   <link href="./style/style.css" rel="stylesheet" type="text/css" /></head><body>    <div id="main">      <div class="caption">'. $error .'</div>      <div id="icon">&nbsp;</div>      <form action='. $_SERVER['PHP_SELF'] .' method="post" name="pwd">        At this time we are only allowing existing Distributors sign up for our site please enter your Customer Id.        <table>          <tr><td><input class="text" name="passwd" /></td></tr>          <tr><td align="center"><br/>             <input class="text" type="submit" name="submit_pwd" value="Login"/>          </td></tr>        </table>        </form></div>';if ($q == $password){$c= '<center>Customer Id found Please<a href=index.php?action=register target="_parent">Click here</a> to register</center>';}echo ''. $c .'   </body>       </html>';?>


with a xml document with this format

<?xml version="1.0"?>
<customer>
  <custnum>
    <cust>1234</cust>
  </custnum>
  <custnum>
    <cust>12345</cust>
  </custnum>
</customer>


basically what it does is gives you a box that says enter your customer id you give it to it it checks the xml file for your id if it finds a match it gives you a link to the register page.

currently I am staring at two options for it
1 I change the register links to point directly to it as a page in itself
2 I change the register links to point to a custom action page and embed this into it using an Iframe

either way works just fine  but my question is this

I tried making the link

<a href=index.php?action=register&?q='. $password .' target="_parent">

to make the actual link something like

index.php?action=register&?q=1234

then I added
$q=$ _GET["q"]
to the top of the register page and changed


<input type="text" name="user" size="20" tabindex="', $context['tabindex']++, '" maxlength="25" />


to


<input type="text" name="user" value="'. $q .'" size="20" tabindex="', $context['tabindex']++, '" maxlength="25" />


hoping to get it to input the Customer number that they provided in the beginning into the user name field this failed

I tried different variations of the register&?q=134

register?&q=1234 -> takes me back to the main page
register&q=1234 -> does nothing
register?q=1234 -> takes me back to the main page
register&&q=1234 -> does nothing

does anyone have any suggestions on how to get this to work?


Darkorical

I got it and it works really nice Ill try packaging it up. but I cant seem to post in the mod section

Eliana Tamerin

Do NOT PM me for support.

SimplePortal 2.3.6 is OUT!
SimplePortal Project Manager
Download | Docs
SimplePortal: Power of Simplicity!

Darkorical


<?xml version="1.0"?>
<!DOCTYPE modification SYSTEM "http://www.simplemachines.org/xml/modification">
<!-- This package was generated by SleePys Modification Maker at http://sleepycode.com -->
<modification xmlns="http://www.simplemachines.org/xml/modification" xmlns:smf="http://www.simplemachines.org/">
<id>smf:mymod</id>
<version>1.0</version>
<file name="$languagedir/index.english.php">
<operation>
<search position="replace"><![CDATA[$txt['welcome_guest'] = 'Welcome, <b>' . $txt[28] . '</b>. Please <a href="' . $scripturl . '?action=login">login</a> or <a href="' . $scripturl . '?action=register">register</a>.';
]]></search>
<add><![CDATA[$txt['welcome_guest'] = 'Welcome, <b>' . $txt[28] . '</b>. Please <a href="' . $scripturl . '?action=login">login</a> or <a href="' . $boardturl . 'cust.php">register</a>.';
]]></add>
</operation>
</file>
<file name="$themedir/index.template.php">
<operation>
<search position="replace"><![CDATA[
// If the user is a guest, also show [register] button.
if ($context['user']['is_guest'])
echo ($current_action == 'register' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '">&nbsp;</td>' : '' , '
<td valign="top" class="maintab_' , $current_action == 'register' ? 'active_back' : 'back' , '">
<a href="', $scripturl, '?action=register">' , $txt[97] , '</a>
</td>' , $current_action == 'register' ? '<td class="maintab_active_' . $last . '">&nbsp;</td>' : '';
]]></search>
<add><![CDATA[ // If the user is a guest, also show [register] button.
if ($context['user']['is_guest'])
echo ($current_action == 'register' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '">&nbsp;</td>' : '' , '
<td valign="top" class="maintab_' , $current_action == 'register' ? 'active_back' : 'back' , '">
<a href="', $boardurl, 'cust.php">' , $txt[97] , '</a>
</td>' , $current_action == 'register' ? '<td class="maintab_active_' . $last . '">&nbsp;</td>' : '';
]]></add>
</operation>
</file>
<file name="$themedir/Register.template.php">
<operation>
<search position="replace" whitespace="loose"><![CDATA[
echo '
// ]]></script>

<form action="', $scripturl, '?action=register2" method="post" accept-charset="', $context['character_set'], '" name="creator" id="creator" onsubmit="return verifyAgree();">
<table border="0" width="100%" cellpadding="3" cellspacing="0" class="tborder">
<tr class="titlebg">
<td>', $txt[97], ' - ', $txt[517], '</td>
</tr><tr class="windowbg">
<td width="100%">
<table cellpadding="3" cellspacing="0" border="0" width="100%">
<tr>
<td width="40%">
<b>', $txt[98], ':</b>
<div class="smalltext">', $txt[520], '</div>
</td>
]]></search>
<add><![CDATA[// ]]>echo'</script>';
$q=$_GET["q"];

echo '
<form action="', $scripturl, '?action=register2" method="post" accept-charset="', $context['character_set'], '" name="creator" id="creator" onsubmit="return verifyAgree();">
<table border="0" width="100%" cellpadding="3" cellspacing="0" class="tborder">
<tr class="titlebg">
<td>', $txt[97], ' - ', $txt[517], '</td>
</tr><tr class="windowbg">
<td width="100%">
<table cellpadding="3" cellspacing="0" border="0" width="100%">
<tr>
<td colspan="2" width="40%" align="center">
<b>Your Customer ID will be your login for this site.</b><br />
You entered <strong>'. $q .'</strong>. This will be your login on this site. If your customer ID is not <strong>'. $q .'</strong> click <a href="'. $boardurl .'cust.php">here</a> to go back and reenter it.

<input type="hidden" type="text"  name="user" value="', $q, '" size="20" tabindex="', $context['tabindex']++, '" maxlength="25" />
</td> ]]></add>
</operation>
</file>
</modification>

SleePy

#5

<?xml version="1.0"?>
<!DOCTYPE modification SYSTEM "http://www.simplemachines.org/xml/modification">
<!-- This package was generated by SleePys Modification Maker at http://sleepycode.com -->
<modification xmlns="http://www.simplemachines.org/xml/modification" xmlns:smf="http://www.simplemachines.org/">
    <id>smf:mymod</id>
    <version>1.0</version>
    <file name="$languagedir/index.english.php">
        <operation>
            <search position="replace"><![CDATA[$txt['welcome_guest'] = 'Welcome, <b>' . $txt[28] . '</b>. Please <a href="' . $scripturl . '?action=login">login</a> or <a href="' . $scripturl . '?action=register">register</a>.';
]]></search>
            <add><![CDATA[$txt['welcome_guest'] = 'Welcome, <b>' . $txt[28] . '</b>. Please <a href="' . $scripturl . '?action=login">login</a> or <a href="' . $boardturl . 'cust.php">register</a>.';
]]></add>
        </operation>
    </file>
    <file name="$themedir/index.template.php">
        <operation>
            <search position="replace"><![CDATA[
    // If the user is a guest, also show [register] button.
    if ($context['user']['is_guest'])
        echo ($current_action == 'register' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '">&nbsp;</td>' : '' , '
                <td valign="top" class="maintab_' , $current_action == 'register' ? 'active_back' : 'back' , '">
                    <a href="', $scripturl, '?action=register">' , $txt[97] , '</a>
                </td>' , $current_action == 'register' ? '<td class="maintab_active_' . $last . '">&nbsp;</td>' : '';
]]></search>
            <add><![CDATA[    // If the user is a guest, also show [register] button.
    if ($context['user']['is_guest'])
        echo ($current_action == 'register' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '">&nbsp;</td>' : '' , '
                <td valign="top" class="maintab_' , $current_action == 'register' ? 'active_back' : 'back' , '">
                    <a href="', $boardurl, 'cust.php">' , $txt[97] , '</a>
                </td>' , $current_action == 'register' ? '<td class="maintab_active_' . $last . '">&nbsp;</td>' : '';
]]></add>
        </operation>
    </file>
    <file name="$themedir/Register.template.php">
        <operation>
<search position="replace" whitespace="loose"><![CDATA[
<form action="', $scripturl, '?action=register2" method="post" accept-charset="', $context['character_set'], '" name="creator" id="creator" onsubmit="return verifyAgree();">
    <table border="0" width="100%" cellpadding="3" cellspacing="0" class="tborder">
        <tr class="titlebg">
            <td>', $txt[97], ' - ', $txt[517], '</td>
        </tr><tr class="windowbg">
            <td width="100%">
                <table cellpadding="3" cellspacing="0" border="0" width="100%">
                    <tr>
                        <td width="40%">
                            <b>', $txt[98], ':</b>
                            <div class="smalltext">', $txt[520], '</div>
                        </td>
]]></search>
            <add><![CDATA[';
$q=$_GET["q"];

echo '
<form action="', $scripturl, '?action=register2" method="post" accept-charset="', $context['character_set'], '" name="creator" id="creator" onsubmit="return verifyAgree();">
    <table border="0" width="100%" cellpadding="3" cellspacing="0" class="tborder">
        <tr class="titlebg">
            <td>', $txt[97], ' - ', $txt[517], '</td>
        </tr><tr class="windowbg">
            <td width="100%">
                <table cellpadding="3" cellspacing="0" border="0" width="100%">
                    <tr>
                        <td colspan="2" width="40%" align="center">
                            <b>Your Customer ID will be your login for this site.</b><br />
                            You entered <strong>'. $q .'</strong>. This will be your login on this site. If your customer ID is not <strong>'. $q .'</strong> click <a href="'. $boardurl .'cust.php">here</a> to go back and reenter it.
                       
                            <input type="hidden" type="text"  name="user" value="', $q, '" size="20" tabindex="', $context['tabindex']++, '" maxlength="25" />
                        </td> ]]></add>
        </operation>
    </file>
</modification>
Jeremy D ~ Site Team / SMF Developer ~ GitHub Profile ~ Join us on IRC @ Libera.chat/#smf ~ Support the SMF Support team!

Darkorical

#6
Coding PHP is like Feeding Mogwai



if you do it after midnight gremlins come out and screw things up

I seem to have quite easilly fixed the issues I had last night and resubmitted this mod to the mod site.

http://custom.simplemachines.org/mods/index.php?mod=1162

Eliana Tamerin

I'll be eager to see the results when it's approved.
Do NOT PM me for support.

SimplePortal 2.3.6 is OUT!
SimplePortal Project Manager
Download | Docs
SimplePortal: Power of Simplicity!

Deprecated

This mod sounds like it would be particularly useful for private sites such as those for families or clubs. It's a shame you haven't pursued getting it fixed and released. How about if you attach your mod to a post and let me see it? I might have some suggestions on how to fix it. Please also describe what the problem seems to be.

Also, I presume your XML list is not directly accessible by the public?

Darkorical

actually it was fixed and works perfectly but the powers that be decided that the way I did it wasn't the way they wanted it and I haven't had a chance to get back around to reworking it into what they want

Advertisement: