This form allows Claromentis user creation simply by filling up a form on the public website.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <script type="text/javascript"> var additional=0; function add_member() { document.getElementById('add_member_box').style.display='none'; document.getElementById('additional_members').style.display='block'; document.getElementById('firstname1').focus(); additional++; } function more_member() { var member = new Array; for(i=1; i<=additional; i++) { n = 'firstname' + i; s = 'surname' + i; e = 'email' + i; member[i] = [document.getElementById(n).value, document.getElementById(s).value, document.getElementById(e).value]; } if(additional==1) { document.getElementById('additional_title').innerHTML += 's'; } additional++; document.getElementById('members').innerHTML += '<div class="members"><input type="text" name="number' + additional + '" size="3" id="number' + additional + '" class="number" value="' + additional + '" /> <input type="text" name="firstname' + additional + '" size="30" id="firstname' + additional + '" /> <input type="text" name="surname' + additional + '" size="30" id="surname' + additional + '" /> <input type="text" name="email' + additional + '" size="30" id="email' + additional + '" /> <a href="javascript:remove(' + additional + ')">Remove</a></div>'; for(i=1; i<additional; i++) { n = 'firstname' + i; s = 'surname' + i; e = 'email' + i; document.getElementById(n).value = member[i][0]; document.getElementById(s).value = member[i][1]; document.getElementById(e).value = member[i][2]; } document.getElementById('number1').value = 1; document.getElementById('firstname'+additional).focus(); } function remove(row) { var member = new Array; var newmember = new Array; for(i=1; i<=additional; i++) { n = 'firstname' + i; s = 'surname' + i; e = 'email' + i; member[i] = [document.getElementById(n).value, document.getElementById(s).value, document.getElementById(e).value]; } if(additional==1) { document.getElementById('add_member_box').style.display='block'; document.getElementById('additional_members').style.display='none'; document.getElementById('firstname1').value = ''; document.getElementById('surname1').value = ''; document.getElementById('email1').value = ''; additional--; } else { document.getElementById('members').innerHTML = ''; members = '<div class="members"><input type="text" name="number" size="3" id="number" class="number" /> <input type="text" name="n" size="30" id="n" value="First Name" class="label" /> <input type="text" name="s" size="30" id="s" value="Last Name" class="label" /> <input type="text" name="e" size="30" id="e" value="Email" class="label" /></div>'; additional--; for(i=1; i<=additional; i++) members += '<div class="members"><input type="text" name="number' + i + '" size="3" id="number' + i + '" class="number" value="' + i + '" /> <input type="text" name="firstname' + i + '" size="30" id="firstname' + i + '" /> <input type="text" name="surname' + i + '" size="30" id="surname' + i + '" /> <input type="text" name="email' + i + '" size="30" id="email' + i + '" /> <a href="javascript:remove(' + i + ')">Remove</a></div>'; document.getElementById('members').innerHTML = members; kick = member[row]; member.splice(row,1); for(i=1; i<=additional; i++) { n = 'firstname' + i; s = 'surname' + i; e = 'email' + i; document.getElementById(n).value = member[i][0]; document.getElementById(s).value = member[i][1]; document.getElementById(e).value = member[i][2]; } if(additional==1) { document.getElementById('additional_title').innerHTML = 'Additional Member'; document.getElementById('number1').value = ''; } } } function populate() { var pre = document.registration; pre.billname.value = pre.firstname0.value + ' ' + pre.surname0.value; pre.billadd.value = pre.address.value; pre.billcity.value = pre.city.value; pre.billcounty.value = pre.county.value; pre.billpostcode.value = pre.postcode.value } function clearbilling() { var pre = document.registration; pre.billname.value = ''; pre.billadd.value = ''; pre.billcity.value = ''; pre.billcounty.value = ''; pre.billpostcode.value = ''; } function validate() { var error = 0; var msg = 'Required :\n'; var pre = document.registration; pre.additionals.value = additional; if(!pre.title[0].checked && !pre.title[1].checked && !pre.title[2].checked && !pre.title[3].checked) {error=1; msg+='- Title\n';} if(!pre.firstname0.value) {error=1; msg+='- First Name\n';} if(!pre.surname0.value) {error=1; msg+='- Last Name\n';} if(!pre.company.value) {error=1; msg+='- Company Name\n';} if(!pre.address.value) {error=1; msg+='- Company Address\n';} if(!pre.city.value) {error=1; msg+='- City/Town\n';} if(!pre.county.value) {error=1; msg+='- County\n';} if(!pre.postcode.value) {error=1; msg+='- Postcode\n';} if(!pre.phone.value) {error=1; msg+='- Telephone\n';} if(!pre.email0.value) {error=1; msg+='- Email\n';} if(additional) { for(i=1; i<=additional; i++) { eval("if(!pre.firstname"+i+".value) {error=1; msg+='- Member "+i+" First Name\\n';}"); eval("if(!pre.surname"+i+".value) {error=1; msg+='- Member "+i+" Last Name\\n';}"); eval("if(!pre.email"+i+".value) {error=1; msg+='- Member "+i+" Email\\n';}"); } } if(!pre.billname.value) {error=1; msg+='- Billing Contact Name\n';} if(!pre.billadd.value) {error=1; msg+='- Biling Address\n';} if(!pre.billcity.value) {error=1; msg+='- Billing City/Town\n';} if(!pre.billcounty.value) {error=1; msg+='- Billing County\n';} if(!pre.billpostcode.value) {error=1; msg+='- Billing Postcode\n';} if(!pre.terms.checked) {error=1; msg+='- Terms & Conditions\n';} if(error) { alert(msg); return false; } else return true; } </script> <style type="text/css"> <!-- .members { height: 25px; } .label { border: 2px solid #FFFFFF; } .number { border: 1px solid #FFFFFF; text-align:right; } body { font-family:Arial, Helvetica, sans-serif; font-size: 12px; } legend { font-family:Arial, Helvetica, sans-serif; font-weight: bold; color: #666666; text-transform: uppercase; font-size: 11px; } a { text-decoration: none; color: #CCCCCC; font-size: 0.9em; } a:hover { text-decoration: underline; color: #000000; } --> </style> </head> <body> <form action="http://53.claromentis.com/intranet/main/register_new_user.php" method="post" name="registration" id="registration" onsubmit="return validate()"> <fieldset><legend>Company Details</legend> <label for="title">Title</label><br /> <input type="radio" value="Mr." name="title" /> Mr. <input type="radio" value="Ms." name="title" /> Ms. <input type="radio" value="Mrs." name="title" /> Mrs. <input type="radio" value="Miss." name="title" /> Miss<br /> <label for="firstname1">First Name</label> <br /> <input name="firstname0" type="text" id="firstname0" size="30" maxlength="30" /> <br /> <label for="surname0">Last Name</label> <br /> <input name="surname0" type="text" id="surname0" size="30" maxlength="30" /> <br /> <label for="company">Company Name</label> <br /> <input type="text" name="company" size="30" id="company" /> <br /> Company Registration Number<br /> <input type="text" name="companyreg" size="30" id="companyreg" /> <br /> Company Address<br /> <textarea name="address" id="address" cols="45" rows="3"></textarea> <br /> City/Town<br /> <input type="text" name="city" size="30" id="city" /> <br /> County<br /> <input type="text" name="county" size="30" id="county" /> <br /> Postcode<br /> <input type="text" name="postcode" size="30" id="postcode" /> <br /> Telephone<br /> <input type="text" name="phone" size="30" id="phone" class="field" /> <br /> Mobile<br /> <input type="text" name="mobile" size="30" id="mobile" class="field" /><br /> Fax<br /> <input type="text" name="fax" size="30" id="fax" class="field" /> <br /> Email<br /> <input type="text" name="email0" size="30" id="email0" class="field" /> <br /> Web<br /> <input type="text" name="web" size="30" id="web" class="field" /> <br /> </fieldset> <br /> <div id="add_member_box"> <input name="add_member_button" type="button" id="add_member_button" value="Additional Member" onclick="add_member()" /><br /> </div> <fieldset id="additional_members" style="display:none"> <legend id="additional_title">Additional Member</legend> <div id="members"> <div class="members"><input type="text" name="number" size="3" id="number" class="number" /> <input type="text" name="n" size="30" id="n" value="First Name" class="label" /> <input type="text" name="s" size="30" id="s" value="Last Name" class="label" /> <input type="text" name="e" size="30" id="e" value="Email" class="label" /></div> <div class="members"><input type="text" name="number1" size="3" id="number1" class="number" /> <input type="text" name="firstname1" size="30" id="firstname1" /> <input type="text" name="surname1" size="30" id="surname1" /> <input type="text" name="email1" size="30" id="email1" /> <a href="javascript:remove(1)">Remove</a></div> </div> <div style="clear:both; padding-top:10px; padding-left:45px;"><input name="more_member_button" type="button" id="more_member_button" value="Add More Member" onclick="more_member()" /></div> </fieldset> <input name="additionals" type="hidden" id="additionals" value="0" /> <br /> <fieldset> <legend>Billing Information</legend> <input name="billing" id="billing" type="radio" value="same" onclick="populate()" /> Same as above <input name="billing" id="billing" type="radio" value="new" onclick="clearbilling()" /> Enter new billing Information <br /> <p>Contact Name<br /> <input type="text" name="billname" size="30" id="billname" /> <br /> Billing Address<br /> <textarea name="billadd" id="billadd" cols="45" rows="3"></textarea> <br /> City/Town<br /> <input type="text" name="billcity" size="30" id="billcity" /> <br /> County<br /> <input type="text" name="billcounty" size="30" id="billcounty" /> <br /> Postcode<br /> <input type="text" name="billpostcode" size="30" id="billpostcode" /> <br /> </fieldset> <br /> </p> <label for="reference"> <input type="checkbox" name="terms" id="terms" /> I have read and agree to membership Guide and Terms & Conditions<br /> <br /> <input type="submit" value="Submit Form" name="Submit" /> <br /> <br /> </label> </form> </body> </html> tml>
script ‘register_new_user.php’
<? // User Registration Process // dB connection require_once("../common/core.php"); require_once("../common/connect.php"); // random password generator function rand_pass() { $pass = ''; for($i=1; $i<=6 ; $i++) $pass .= chr( mt_rand(97, 122) ); $pass .= mt_rand(11,99); return $pass; } // time stamp = NOW $timestampnow = mktime(); // set language if (!isset($_POST['language'])) $language = 'en'; // processing the users $add_member = ""; if(isset($_POST['additionals']) && $_POST['additionals']>=0) { if($_POST['additionals']==1) $add_member = "Additional member"; else $add_member = "Additional members"; for($i=0; $i<=$_POST['additionals']; $i++) { // strip slashes from additional member data $add_firstname = stripslashes($_POST['firstname'.$i]); $add_surname = stripslashes($_POST['surname'.$i]); $add_email = $_POST['email'.$i]; // create user name mt_srand((double)microtime() * 1000000); $add_uname = strtolower($add_firstname[0].$add_surname.mt_rand(1, 100)); // create password $add_user_pass = rand_pass(); // encrypt password $add_epass = md5($add_user_pass); // insert user to database if($i==0) $query = "insert into users ( intranetuser, username, password, last_time_used, last_time_login, surname, firstname, company, work_location, landline, mobile, emailad, ex_area_id, city, language) values ( 'yes', '$add_uname', '$add_epass', 0, '$timestampnow', '".addslashes($add_surname)."', '".addslashes($add_firstname)."', '".$_POST['company']."', '".$_POST['address']."', '".$_POST['phone']."', '".$_POST['mobile']."', '$add_email', 2, '".$_POST['city']."', '$language' )"; else $query = "insert into users ( intranetuser, username, password, last_time_used, last_time_login, surname, firstname, company, usercomments, landline, emailad, ex_area_id, city, language) values ( 'yes', '$add_uname', '$add_epass', 0, '$timestampnow', '".addslashes($add_surname)."', '".addslashes($add_firstname)."', '".$_POST['company']."', '".$_POST['address']."', '".$_POST['phone']."', '$add_email', 2, '".$_POST['city']."', '$language' )"; $result = $db->query(new Query($query)); $userid_new = $db->insertId(); // assign to role $query = "insert into user_roles(userid,roleid) values ('$userid_new', '1')"; $result = $db->query(new Query($query)); // assign to group $query = "insert into user_groups(userid,groupid) values ('$userid_new', '2')"; $result = $db->query(new Query($query)); if($i>0) { $add_member .= " $i . First Name : $add_firstname, Last Name : $add_surname, Email : $add_email, User Name : $add_uname, Password : $add_user_pass"; } // email the username and password $mail_body = "Thank you for your registering with Claromentis. Your account has been set up -------------------------------------------------------------------------- Please point your browser to http://53.claromentis.com/ and then enter the information below : username : $add_uname password : $add_user_pass -------------------------------------------------------------------------- If you have any problem please send us an email to enquiries@claromentis.com and we will be happy to help. -------------------------------------------------------------------------- www.claromentis.com "; $headers = "From: Claromentis Support <support@claromentis.com>\r\n"; $headers.= "Reply-to: Claromentis Support <support@claromentis.com>\r\n"; $headers.= "Content-Type: text/plain\r\n"; $headers.= "Message-ID: <mailserver@".$_SERVER['SERVER_NAME'].">\r\n"; $headers.= "X-Mailer: PHP v".phpversion()."\r\n"; mail($add_email, 'Claromentis: Your Account', $mail_body, $headers); } } // send email to admin $admin_mail = "Claromentis Support <support@claromentis.com>"; $mail_body = "New registration Title : ".$_POST['title']." First Name : ".$_POST['firstname0']." Last Name : ".$_POST['surname0']." Company Name : ".$_POST['company']." Company Registration Number : ".$_POST['companyreg']." Address : ".$_POST['address']." City/Town : ".$_POST['city']." County : ".$_POST['county']." Postcode : ".$_POST['postcode']." Telephone : ".$_POST['phone']." Mobile : ".$_POST['mobile']." Fax : ".$_POST['fax']." Email : ".$_POST['email0']." Web : ".$_POST['web']; if(isset($_POST['additionals']) && $_POST['additionals']>=0) $mail_body.= " ".$add_member; $mail_body.=" Billing Contact Name : ".$_POST['billname']." Address : ".$_POST['billadd.']." City/Town : ".$_POST['billcity']." County : ".$_POST['billcounty']." Postcode : ".$_POST['billpostcode']; $headers = "From: Claromentis Support <support@claromentis.com>\r\n"; $headers.= "Reply-to: Claromentis Support <support@claromentis.com>\r\n"; $headers.= "Content-Type: text/plain\r\n"; $headers.= "Message-ID: <mailserver@".$_SERVER['SERVER_NAME'].">\r\n"; $headers.= "X-Mailer: PHP v".phpversion()."\r\n"; mail($admin_mail, 'Claromentis: New Members', $mail_body, $headers); // redirect to thank you page header("Location: http://53.claromentis.com/thanks.html"); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"><head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"><title>Thank You</title> <style> body { font-family:Arial, Helvetica, sans-serif; font-size: 12px; } </style></head><body> <h1>Thank You</h1> <p>Your form has been submitted.</p> <p>You will be emailed with username and password to access members area at <a linkindex="0" href="http://53.claromentis.com/">http://53.claromentis.com</a></p> <p>Note: Make sure check your junk (spam) folder if you have not receive our email in 5 minutes.<br> Should you require further assistance please don't hesitate to <a linkindex="1" href="http://www.claromentis.com/contact/contact.php">contact us</a></p> </body></html>
Discussion