Jump to content

Help with mod: actionhook_ClientSignup


routerboy

Recommended Posts

Greetings all:

 

New to this stuff, so bare with me. I have an issue with my own mod when a customer is signing up for an account:...:-)

 

On my clientregister.tpl file I added two radio buttons. One for yes(value=1); one for no(value=0).

 

The person registering on the site is asked if they want to receive a custom registration code, to be received in a seperate email, so they can obtain a eval copy of our software. Below is a copy of that code:

 

<tr>

<td class="fieldarea">{$LANG.downloadfile}</td><td><div>

<div><input type="radio" name="downloadfile" checked value="1"

<?=($_POST["downloadfile"]=="1"||!isset($_POST["downloadfile"])?"checked":"")?>Yes</div><br>

<div><input type="radio" name="downloadfile" value="0" <?=($_POST["downloadfile"]=="0"?"checked":"")?>No</div>

</div>

</td>

</tr>

 

If they select yes, they should get a second email with that code. If no, no second email - but registration continues.

 

So I invoked the actionhooks.php function here: actionhook_ClientSignup($vars) and added to this section:

 

# This function runs when a new client is added

# $vars["ClientID"]

# $vars["FirstName"]

# $vars["LastName"]

# $vars["CompanyName"]

# $vars["Email"]

# $vars["Address1"]

# $vars["Address2"]

# $vars["City"]

# $vars["State"]

# $vars["Postcode"]

# $vars["Country"]

# $vars["PhoneNumber"]

# $vars["Password"]

$vars["downloadfile"];

// I have others vars...but remove them to ease this message.

 

$tempvalue = md5(base64_encode($_POST["firstname"].$_POST["lastname"]. $_POST["email"].$_POST["clientphonenumber"]));

 

$guid = strtoupper(substr($tempvalue,0,8)."-". substr($tempvalue,8,8)."-". substr($tempvalue,16,8)."-". substr($tempvalue,24,8));

 

$ttdb = mysql_connect($ttdb_host, $ttdb_user, $ttdb_pass);

 

mysql_select_db($ttdb_db, $ttdb);

 

$query = mysql_query(("insert into tblCustomId set firstname = '".$_POST["firstname"]."', lastname = '".$_POST["lastname"]."', rtype = '".$_POST["promotional"]."', newsletter = '".intval($_POST["newsletters"])."', promoproducts = '".intval($_POST["promoproducts"])."', zipcode = '".$_POST["postcode"]."', email = '".$_POST["email"]."', code = '".$guid."'"), $ttdb);

 

$to = $_POST["email"];

$subject = "Registration Complete";

 

$message = '';

$message .= '<br>';

$message .= '<br>';

$message .= '<p>Hello '.$_POST["firstname"].' '.$_POST["lastname"].'.';

$message .= '<br>';

$message .= '<p>Thank you for your interest in our software! Below is your information related to your personal registration code.';

$message .= '<br>';

$message .= '<p><b>Your register information:</b>';

$message .= '<p>First name: '.$_POST["firstname"];

$message .= '<p>Last name: '.$_POST["lastname"];

$message .= '<p>Email: '.$_POST["email"];

$message .= '<p>Your personal registration code is: '.$guid;

$message .= '<br>';

$message .= '<br>';

$message .= '<br><p>Regards,<br>';

$message .= 'Support';

$message .= '<br>';

$message .= '<br>';

$headers = "MIME-Version: 1.0\r\n";

$headers .= "Content-type: text/html; charset=windows-1251\r\n";

$headers .= "From: Support <support@mydomain.com>\n";

mail($to, $subject, $message, $headers);

 

mysql_query($query, $ttdb);

mysql_close($ttdb);

 

}

 

}

 

The reason for doing it this way, is to populate a second DB (and its tables) with the code that gets generated for a registration code. And the above appears to work as expected! :)

 

Now the issue -

 

I need it to be an option! If they click No to the radio buttons, then DO not send an email, or populate the second DB but still populate the whmcs tables. I have tried everything I know how to do to include a "if then else" statements, but it fails to insert the data no matter what. If I remove my if statement, the DB does get populated.

 

Help!

 

RB

Link to comment
Share on other sites

Sorry... Not following you. Put a two (2) where?

 

In here?

 

input type="radio" name="downloadfile" checked value="1"

<?=($_POST["downloadfile"]=="1"||!isset($_POST["downloadfile"])?"checked":"")?>Yes</div><br>

<div><input type="radio" name="downloadfile" value="0" <?=($_POST["downloadfile"]=="0"?"checked":"")?>No</div>

 

or here....

 

if ($_POST["downloadfile"==2]) {

 

$ttgid = 0;

 

....

 

RB

Link to comment
Share on other sites

If the No option is selected then the variable downloadfile will equal 2

(Normally a variable is set at 0 or NULL when its not set at all)

An example would be

 

if ($vars["downloadfile"] == "1") {

STUFF TO DO

} elseif ($vars["downloadfile"] =="2") {

CODE HERE

}

Link to comment
Share on other sites

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.   Paste as plain text instead

  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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated