۱۳۸۷ اسفند ۱۱, ۰۲:۱۹ ق.ظ
این کل کد برنامه منه البته توی صفحه ثبت نام.
که شاید یه جنبه آموزشی هم برای مبتدی ها داشته باشه چون توش خیلی کدهای غیر بهینه کارکردم.
شما اساتید عزیز اشکالات من رو بهم گوش زد کنین تا هم به درد مبتدی ها بخوره و همچنین من از همین ابتدای کار متد برنامه نویسیم رو درست کنم.
جالب این جاست با این که COLLATION بانک من UTF8- PERSIAN _CI هست ولی خیلی داده ها رو بد نشون میده .یعنی یک سری کراکترهای عجیب غریب .
اشکال از کجاست؟
جناب آقا میلاد عزیز بابت زحمات شما ممنونم ولی هر چه کردم کدی که شما دادین با اون مشخصات درست نشد اگر رو مثال بالا برام شرح بدین ممنون میشم.
که شاید یه جنبه آموزشی هم برای مبتدی ها داشته باشه چون توش خیلی کدهای غیر بهینه کارکردم.
شما اساتید عزیز اشکالات من رو بهم گوش زد کنین تا هم به درد مبتدی ها بخوره و همچنین من از همین ابتدای کار متد برنامه نویسیم رو درست کنم.
کد پیاچپی:
<?php
//include("db_config_inc.php");
//tarifat avalie data base;
//***********************************************************************************************
$db_host="localhost";
$db_name="pooyasharif";
$db_username="root";
$db_pass="";
$db=mysql_connect($db_host,$db_username,$db_pass) or die ( " Can not connect to data base " );
$link=mysql_select_db($db_name);
//start
//***********************************************************************************************
$totalerror=0;//jam error ha
$errshsh="";//err shomare shenasname
$errni="";//err code melli
$errpc="";//error postal code
$errtel=""; //erroe telephone
$errmobile="";//err mobile
$errcitycode="";//err code shahr
$un=$_POST[un];//user name
$pass=$_POST[pass];
$pass1=$_POST[pass1];
$name=$_POST[name];
$family=$_POST[family];
$father=$_POST[father];
$shsh=$_POST[shsh];//shomare shenasname
$sodoor=$_POST[sodoor];//mahal sodoor
$mtavallod=$_POST[mtavallod];
$day=$_POST[day];
$month=$_POST[month];
$year=$_POST[year];
$nationalid=$_POST[nationalid];
$gender=$_POST[gender];
$religion=$_POST[religion];
$degree=$_POST[degree];
$soldier=$_POST[soldier];//vaziat sarbazi
$citycode=$_POST[citycode];
$province=$_POST[province];
$bigcity=$_POST[bigcity];
$city=$_POST[city];
$area=$_POST[area];
$address=$_POST[address];
$postalcode=$_POST[postalcode];
$tel=$_POST[tel];
$mobile=$_POST[mobile];
$email=$_POST[email];
// check kardan sehat dade haye voroodi
if (ereg ("([0-9]{1,11}$)", $shsh, $regs)) {
echo "$regs[1]"."<br>";
} else {
$errshsh="errshsh=errshsh";
$totalerror+=1;
}
if (ereg ("([0-9]{7,8}$)", $tel, $regs)) {
echo "$regs[1]";
} else {
$errtel="errtel=errtel";
$totalerror+=1;
}
if (ereg ("([0-9]{4}$)", $citycode, $regs)) {
echo "$regs[1]";
} else {
$errcitycode="errcitycode=errcitycode";
$totalerror+=1;
}
if (ereg ("([0-9]{10}$)", $postalcode, $regs)) {
echo "$regs[1]";
} else {
$errpc="errpc=errpc";
$totalerror+=1;
}
if (ereg ("([0-9]{10}$)", $nationalid, $regs)) {
echo "$regs[1]";
} else {
$errni="errni=errni";
$totalerror+=1;
}
if (ereg ("([0-9]{11}$)", $mobile, $regs)) {
echo "$regs[1]";
} else {
$totalerror+=1;
$errmoblie="errmobile=errmoblile";
}
//check kardan sehate ramz
if ($pass!=$pass1)
{
$errpass=errpass;
$totalerror+=1;
}
// check kardan khali nabaoodan field ha
if ($un=="" || $pass=="" || $pass1=="" ||$name=="" ||$family==""
||$father=="" ||$shsh=="" ||$sodoor=="" ||$mtavallod=="" ||$day==""
||$month=="" ||$year=="" ||$nationalid=="" ||$gender=="" ||$religion==""
||$degree=="" ||$soldier=="" ||$province=="" ||$bigcity=="" ||$address==""
||$postalcode=="" ||$tel=="" ||$citycode=="" ||$mobile=="" )
{
$errfill="errfill=errfill";
$totalerror+=1;
}
if($totalerror!=0)
{
$params = array
(
errshsh=>$errshsh,
errni => $errni,
errtel=>$errtel,
errmobile =>$errmobile,
errcitycode=>$errcitycode,
errpc=>$errpc,
errfill=>$errfill,
errpass=>$errpass
);
$url = '../register.php?'.http_build_query($params);
echo "
<script type='text/javascript'>
window.location='{$url}';
</script>
";
}
else
{
$birthday=$year."/".$month."/".$day;//chasbandan tarikh tavalod
// start of database operation
$q="INSERT INTO register ( name,
family ,
father ,
shsh ,
sodoor ,
birthday ,
nationalid ,
gender ,
religion ,
degree ,
soldier ,
mtavallod ,
province,
city ,
bigcity ,
area ,
address ,
postalcode ,
tel ,
citycode ,
mobile ,
email ,
userid ,
userpass ,
username
)
VALUES ('$name','$family','$father','$shsh','$sodoor','$birthday','$nationalid',
'$gender','$religion','$degree','$soldier','$mtavallod','$province','$city','$bigcity',
'$area','$address','$postalcode','$tel','$citycode','$mobile','$email','','$pass','$un')";
$result=mysql_query($q,$db);
if(mysql_affected_rows()>0)
{
echo "عملیات با موفقیت انجام شد";
}
else
{
echo "عملیات ناقص انجام شد";
}
}
/// end of data base operation
?>
اشکال از کجاست؟
جناب آقا میلاد عزیز بابت زحمات شما ممنونم ولی هر چه کردم کدی که شما دادین با اون مشخصات درست نشد اگر رو مثال بالا برام شرح بدین ممنون میشم.