PHP REGISTER PROBLEM

  • Автор Автор z7c
  • Начална дата Начална дата

z7c

Registered
Здравейте това по долу което ще видите е php код за регистрация...
работи си , но не работи за валидацията на кода който се вавежда най отдолу .. за антибот защита..
моля някой ако може да помогне ето и кода:


<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
// +----------------------------------------------------------------------+
// | This source file is a part of iScripts.com iScripts EasyIndex v1.0 |
// +----------------------------------------------------------------------+
// | Copyrights Armia Systems, Inc and iScripts.com © 2005 |
// | All rights reserved |
// +----------------------------------------------------------------------+
// | This script may not be distributed, sold, given away for free to |
// | third party, or used as a part of any internet services such as |
// | webdesign etc. |
// +----------------------------------------------------------------------+
ob_start();
require("./includes/global.php");
require("./includes/function.php");
//require("../includes/general_settings.php");
//is_admin_login();
require("./user_header.php");
//require("./toplink.php");
/*php code for adding data to database */
if (get_magic_quotes_gpc()) {
function stripslashes_deep($value)
{
$value = is_array($value) ?
array_map('stripslashes_deep', $value) :
stripslashes($value);

return $value;
}

$_POST = array_map('stripslashes_deep', $_POST);
$_GET = array_map('stripslashes_deep', $_GET);
$_COOKIE = array_map('stripslashes_deep', $_COOKIE);
}



if($_POST["btnSubmit"] =="Register"){
$txtUserName = $_POST["txtUserName"];
$txtPassword = $_POST["txtPassword"];
$txtFirstName = $_POST["txtFirstName"];
$txtLastName = $_POST["txtLastName"];
$txtAddress1 = $_POST["txtAddress1"];
$txtAddress2 = $_POST["txtAddress2"];
$txtCity = $_POST["txtCity"];

$txtPhone = $_POST["txtPhone"];
$txtFAX = $_POST["txtFAX"];
$txtEmail = $_POST["txtEmail"];
$ddlCounty = $_POST["ddlCounty"];
$ddlGender = $_POST["ddlGender"];
$txtURL = $_POST["txtURL"];
$ddlEducation = $_POST["ddlEducation"];
$txtDescription = $_POST["txtDescription"];
foreach($_POST as $key=>$value){
$$key=addslashes($value);
}

if(trim($txtUserName)=="" or trim($txtPassword)=="" or trim($txtFirstName)=="" or trim($txtAddress1)=="" or trim($txtCity)=="" or trim($txtPhone)=="" or trim($txtEmail)==""){
$message="Please Fill All Required Fields";
}else if( strcmp($txtConfirmPassword,$txtPassword) !=0 or strlen($txtPassword) <6 ){
$message="Either The Password Doesnot matches or password less than six char length";
}else if( validate_email($txtEmail) != "1"){
$message="Please Enter a Valid Email Address";
}
else{

$sqluserexists = "SELECT vLoginName FROM iscriptseitbl_users WHERE vLoginName = '" . addslashes($txtUserName) . "'";
$resultuserexists = mysql_query($sqluserexists) or die(mysql_error());

if(mysql_num_rows($resultuserexists)!=0){
$message = "This User Name '$txtUserName' is in use!. Please select a different one!";
$notregistered = "1";

}else{
$sqluserexists = "SELECT vLoginName FROM iscriptseitbl_users WHERE vLoginName = '" . addslashes($txtUserName) . "'";
$resultuserexists = mysql_query($sqluserexists) or die(mysql_error());

if(mysql_num_rows($resultuserexists)!=0){
$txtUserName=stripslashes($txtUserName);
$message = "This User Name '$txtUserName' is in use!. Please select a different one!";
$notregistered = "1";
}else{
if(!isValidUsername($txtUserName)){
$txtUserName=stripslashes($txtUserName);
$message = "Invalid User Name '".htmlentities($txtUserName)."'!. Please select a user name with no special characters (@,#,^,& etc. ) and spaces!";
$notregistered = "1";
}else{
$sql = "INSERT INTO iscriptseitbl_users(vLoginName,vPassword,vFirstName ,vLastName ,vAddress1 ,vAddress2 ,vCity , ";
$sql .="vCounty , vPhone ,vFax ,vEmail ,vUrl , vGender ,vEducation,";
$sql .="vDescription ,dDateReg,vStatus) ";
$sql .="VALUES ('".addslashes($txtUserName)."','".md5($txtPassword)."','".addslashes($txtFirstName)."','".addslashes($txtLastName)."','".addslashes($txtAddress1)."','".addslashes($txtAddress2)."','".addslashes($txtCity)."',";
$sql .="'".addslashes($ddlCounty)."','".addslashes($txtPhone)."','". addslashes($txtFAX) ."','". addslashes($txtEmail) ."','". addslashes($txtURL) ."','". addslashes($ddlGender) ."','". addslashes($ddlEducation) ."',";
$sql .="'".addslashes($txtDescription)."',now(),'1')";

mysql_query($sql) or die(mysql_error());
$sqluserid = mysql_insert_id();

$mailcontent1 = "Dear ".$txtFirstName.", <br>";
$mailcontent1 .= "Welcome to Chicagobusiness.net <br>Your account with Chicagobusiness.net has been successfully created.";
$mailcontent1 .= "<br><br>Given below are your login details:<br>";
$mailcontent1 .= "User Name :".$txtUserName."<br>";
$mailcontent1 .= "Password :".$txtPassword."<br>";
$mailcontent1 .= "<br>Thank you for registering with Chicagobusiness.net";
$subject = "Welcome to Chicagobusiness.net! Your account has been successfully created!";
$EMail = $txtEmail;
$Headers="From: info@localbusiness.host22.com\n";
$Headers.="Reply-To: info@localbusiness.host22.com\n";
$Headers.="MIME-Version: 1.0\n";
$Headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
//echo $mailcontent1;
//exit;
//mail($EMail,$subject,$mailcontent1,$Headers);
session_start();
$_SESSION["guserid"] = $sqluserid;
$_SESSION["gloginname"]= $_POST["txtUserName"];
header("location:userindex.php");
exit;
session_start();
if(($_SESSION['security_code'] == $_POST['security_code']) && (!empty($_SESSION['security_code'])) ) {
// Insert you code for processing the form here, e.g emailing the submission, entering it into a database.
unset($_SESSION['security_code']);
} else {
// Insert your code for showing an error message here
}
}
}

}
}

if($message !=""){
foreach($_POST as $key=>$value){
$$key=stripslashes($value);
}
}

}

?>

<table width="100%" border="0" cellspacing="1" cellpadding="0" align=center height="80%">
<tr>
<?php require("./sidelink.php"); ?>
<td width="80%" align="center" valign="top"class="pagebgcolor">

<form name="frmRegistration" method ="POST" action = "<?php echo $_SERVER['PHP_SELF']?>" onsubmit="return validateRegistrationForm();">
<table width="80%" border="0" cellpadding="0" cellspacing="0" align=center>
<tr>
<td colspan=3 width="97%" align="right" class="pagelbl">Register</td>
</tr>

<tr><td width="100%" colspan="3" align="center" class=boldtextblack><?=$message;?></td></tr>
<tr><td width="100%" colspan="3" align="left">
<span class="boldtextblack"><br>Login Details</span> </td>
</tr>
<tr><td width="20%" class="textblack"> User Name *</td>
<td width="2%"> </td><td width="78%"><INPUT type="text" class=TextBox name="txtUserName" size="40" maxlength="100" value="" value="<?=$txtUserName?>"/></td></tr>
<tr><td width="20%" class="textblack"> Password *</td>
<td width="2%"> </td><td width="78%"><INPUT type="password" class=TextBox name="txtPassword" size="40" maxlength="100" /></td></tr>
<tr>
<td width="20%" class="textblack"> Confirm Password* </td>
<td width="2%"> </td><td width="78%"><INPUT type="password" class=TextBox name="txtConfirmPassword" size="40" maxlength="100" /></td></tr>
<tr><td width="100%" colspan="3" align="left" class="darktext">
<span class="boldtextblack"><br> Contact Details</span> </td>
</tr>
<tr><td width="20%" class="textblack"> First Name *</td>
<td width="2%"> </td><td width="78%"><INPUT type="text" class=TextBox name="txtFirstName" size="40" maxlength="100" value="<?php echo htmlentities($txtFirstName); ?>" /></td></tr>
<tr><td width="20%" class="textblack"> Last Name</td>
<td width="2%"> </td><td width="78%"><INPUT type="text" class=TextBox name="txtLastName" size="40" maxlength="100" value="<?php echo htmlentities($txtLastName);?>" /></td></tr>
<tr><td width="20%" class="textblack"> Address Line 1 *</td>
<td width="2%"> </td><td width="78%"><INPUT type="text" class=TextBox name="txtAddress1" size="40" maxlength="100" value="<?php echo htmlentities($txtAddress1);?>" /></td></tr>
<tr><td width="20%" class="textblack"> Address Line 2</td>
<td width="2%"> </td><td width="78%"><INPUT type="text" class=TextBox name="txtAddress2" size="40" maxlength="100" value="<?php echo htmlentities($txtAddress2);?>" /></td></tr>
<tr><td width="20%" class="textblack"> City *</td>
<td width="2%"> </td><td width="78%"><INPUT type="text" class=TextBox name="txtCity" size="40" maxlength="100" value="<?php echo htmlentities($txtCity);?>" /></td></tr>

<tr><td width="20%" class="textblack"> County</td>
<td width="2%"> </td>
<td width="78%">
<SELECT name="ddlCounty" class=TextBox>
<option selected>Select One
<option>Antrim
<option>Armagh
<option>Carlow
<option>Cavan
<option>Clare
<option>Cork
<option>Derry
<option>Donegal
<option>Down
<option>Dublin
<option>Fermanagh
<option>Galway
<option>Kerry
<option>Kildare
<option>Kilkenny
<option>Laois
<option>Leitrim
<option>Limerick
<option>Longford
<option>Louth
<option>Mayo
<option>Meath
<option>Monaghan
<option>Offaly
<option>Roscommon
<option>Sligo
<option>Tipperary
<option>Tyrone
<option>Waterford
<option>Westmeath
<option>Wexford
<option>Wicklow</option>




</SELECT>
</td>
</tr>

<tr><td width="20%" class="textblack"> Phone *</td>
<td width="2%"> </td><td width="78%"><INPUT type="text" class=TextBox name="txtPhone" size="40" maxlength="50" value="<?php echo htmlentities($txtPhone); ?>" /></td></tr>
<tr><td width="20%" class="textblack"> Fax</td>
<td width="2%"> </td><td width="78%"><INPUT type="text" class=TextBox name="txtFAX" size="40" maxlength="100" value="<?php echo htmlentities($txtFAX); ?>" /></td></tr>
<tr><td width="20%" class="textblack"> Email *</td>
<td width="2%"> </td><td width="78%"><INPUT type="text" class=TextBox name="txtEmail" size="40" maxlength="100" value="<?php echo htmlentities($txtEmail); ?>" /></td></tr>
<tr><td width="20%" class="textblack"> URL</td>
<td width="2%"> </td><td width="78%"><INPUT type="text" class=TextBox name="txtURL" size="40" maxlength="100" value="<?php echo htmlentities($txtURL); ?>" /></td></tr>
<tr><td width="100%" colspan="3" align="left" class="darktext">
<span class="boldtextblack"><br> Other Details</span> </td>
</tr>
<tr><td width="20%" class="textblack"> Gender</td>
<td width="2%"> </td><td width="78%"><SELECT class=TextBox name="ddlGender"><OPTION value="M">Male</OPTION><OPTION value="F">Female</OPTION></SELECT></td></tr>
<tr><td width="20%" class="textblack"> Education</td>
<td width="2%"> </td><td width="78%">
<SELECT name="ddlEducation" class=TextBox>
<OPTION value="GP">Graduate/Post Graduate-Professional</OPTION>
<OPTION value="GG">Graduate/Post Graduate-General</OPTION>
<OPTION value="SC">Some College but not Graduate</OPTION>
<OPTION value="SH">SSC/HSC</OPTION>
<OPTION value="SS">Some School</OPTION>
<OPTION value="OT">Other</OPTION>
</SELECT>
</td>
</tr>


<tr><td width="20%" valign="top" class="textblack"> Description</td>
<td width="2%"> </td><td width="78%"><textarea class=TextBox name="txtDescription" rows="10" cols="40" maxlength="400" onKeyDown="limitLength(this.form.txtDescription, 400);" onKeyUp="limitLength(this.form.txtDescription, 400);" wrap><?php echo htmlentities($txtDescription); ?></textarea></td></tr>

<tr><td width="20%" class="textblack"> <b>Fill in the code below *</td><tr><td><b><img src="http://localbusiness.host22.com/CaptchaSecurityImages.php"/>
<input id="security_code" name="security_code" type="text" /></td>
<tr><td width="100%" colspan="3" align="center"> </td></tr>
<tr><td width="100%" colspan="3" align="center"><INPUT type="submit" class=Button name="btnSubmit" value="Register" />  <br> </td></tr>



</table>
</form>

<script>
var County;
var sex;
var quali;
<?
$dis="County=\"$ddlCounty\";\n";
$dis .="sex=\"$ddlGender\";\n";
$dis .="quali=\"$ddlEducation\";\n";
echo $dis;
?>
frm=document.frmRegistration;
for(i=0;i<frm.ddlCounty.options.length;i++){
if(frm.ddlCounty.options.text == County){
frm.ddlCounty.options.selected=true;
break;
}
}
for(i=0;i<frm.ddlEducation.options.length;i++){
if(frm.ddlEducation.options.value == quali){
frm.ddlEducation.options.selected=true;
break;
}
}
for(i=0;i<frm.ddlGender.options.length;i++){
if(frm.ddlGender.options.value == sex){
frm.ddlGender.options.selected=true;
break;
}
}


</script>
</td>
</tr>



</table>

<?php
require("./footer.php");
ob_end_flush();
?>
 

Back
Горе