• 0 رای - 0 میانگین
  • 1
  • 2
  • 3
  • 4
  • 5
درخواست راهنمایی
#1
سلامHeart
دوستان من یه مبتدی هستم...
میخواستم کمک کنید یه فایل رو کامل کنم !
کد پی‌اچ‌پی:
<?php ?><?php
include ('header.php');
if (isset(
$_POST['ok'])) {
    if (
$_SESSION['code'] == $_POST['code']) {
        
$jens intval($_POST['for']);
        
$email debug($_POST['email']);
        
$url debug($_POST['url']);
        
$name debug($_POST['name']);
        
$age debug($_POST['age']);
        
$city debug($_POST['city']);
        
$shoghl debug($_POST['shoghl']);
        if (
okurl($url)) {
            if (
okmail($email)) {
                if (!
mysql_num_rows(mysql_query("SELECT `id` FROM `user` WHERE `email`='$email' LIMIT 1"))) {
                    
$url str_replace('http://'''$url);
                    
$url.= '/';
                    
$url explode('/'$url);
                    
$url $url['0'];
                    if (!
mysql_num_rows(mysql_query("SELECT `id` FROM `user` WHERE `url`='$url' LIMIT 1"))) {
                        
$b 1;
                        if (
$b) {
                            
mysql_query("INSERT INTO `user`(`email`, `url`, `name`,`age`,`city`,`shoghl`,`jens`) VALUES ('$email','$url','$name','$age','$city','$shoghl','$jens')");
                            
$show 'ا? د? شما با موفق?ت ثبت شد!</b>';
                            
$e 'عضويت شما در سيستم با موفقيت انجام شد .
<br />
<a href="' 
$configsiteadd['url'] . '">افزا?ش ادد ل?ست ?اهو</a>';
                            
sendmail($email'عضويت شما با موفقيت انجام شد .'$e);
                        }
                    } else {
                        
$show 'آدرس وارد شده قبلا استفاده شده است .';
                    }
                } else {
                    
$show 'ايميل وارد شده قبلا استفاده شده است .';
                }
            } else {
                
$show 'ايميل وارد شده صحيح نمي باشد .';
            }
        } else {
            
$show 'آدرس وارد شده صحيح نمي باشد .';
        }
    } else {
        
$show 'کد امنيتي وارد شده اشتباه است .';
    }
    
$_SESSION['code'] = '';
}
if (
$show) {
    echo 
'

<div class="alert alert-info alert-dismissable">
                                        <i class="fa fa-info"></i>
                                        <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
                                        <b>' 
$show '!</b> 
                                    </div>
 '
;
}
?>
 <div class="row">
                        
                            
                            <div class="col-md-6">
                            <!-- Info box -->
                            <div class="box box-primary">
                                <div class="box-header">
                                    
                                    <h2 dir="rtl" class="box-title"><i class="fa fa-foursquare"></i>&nbsp;  <a href="#" title="فرم ثبت نام" >فرم ثبت نام</a></h2>
                                </div>
                                <div dir="rtl" class="box-body">
                            


  <form  method="post" action="">
  <div class="form-group">
                                            <label for="exampleInputEmail1">ايميل شما:</label>
                                            <input type="email" name="email" class="form-control"  placeholder="[email protected]">
                                        </div>
  <div class="form-group">
                                            <label for="exampleInputEmail1">آدرس سايت:</label>
                                            <input dir="ltr" type="text" class="form-control" name="url" placeholder="http://">
                                        </div> 
                                        <div class="form-group">
                                            <label for="exampleInputEmail1">نام:</label>
                                            <input dir="rtl" type="text" class="form-control" name="name" placeholder="نام">
                                        </div>
                                        <div class="form-group">
                                            <label for="exampleInputEmail1">سن:</label>
                                            <input dir="rtl" type="text" class="form-control" name="age" placeholder="سن">
                                        </div>
                                        <div class="form-group">
                                            <label for="exampleInputEmail1">شهر:</label>
                                            <input dir="rtl" type="text" class="form-control" name="city" placeholder="شهر">
                                        </div>
                                        <div class="form-group">
                                            <label for="exampleInputEmail1">شغل:</label>
                                            <input dir="rtl" type="text" class="form-control" name="shoghl" placeholder="شغل">
                                        </div>
                                        <div class="form-group">
                                            <label for="exampleInputEmail1">جنس?ت:</label>
                                            <select name="for" class="form-control">
                                                
                                                <option value="0">مرد</option>
                                                <option value="1">زن</option>
                                            </select>
                                            </div>


<div class="form-group">
                                            <label for="exampleInputEmail1">کد امن?ت?:</label>
                                            <input dir="ltr" class="form-control" type="text" name="code" placeholder="Code ...">
<img alt="کد امنيتي" title="کد امنيتي" src="/captcha"/>
                                            </div>

    


    <input type="submit" class="btn btn-primary" value="ثبت ا? د?" name="ok"/>
    
     </form>
                              </div><!-- /.box-body -->
                                
                            </div><!-- /.box -->
                            </div>  
 
                            
                            <div class="col-md-6">
                            <!-- Info box -->
                            <div class="box box-primary">
                                <div class="box-header">
                                    
                                    
                                    <h2 dir="rtl" class="box-title"><i class="fa fa-foursquare"></i>&nbsp;  <a href="#" title="نکات برا? ثبت نام" >نکات? برا? ثبت نام</a></h2>
                                </div>
                                <div dir="rtl" class="box-body">
                                    
                                    
                                    <p><i class="fa fa-align-right"></i> &nbsp; 
                                    ا?م?ل http:// ندارد
                                    </p><br />
                                    
                                    <p><i class="fa fa-align-right"></i> &nbsp; 
                                    در صورت وارد نکردن نام و سن و شغل و .. مشکل? پ?ش نم? ا?د
                                    </p><br />
                                    
                                    <p><i class="fa fa-align-right"></i> &nbsp; 
                                    هر سا?ت و ا?م?ل فقط ?ک بار م? توانند ثبت نام کنند
                                    </p><br />
                                    
                                    
                                </div><!-- /.box-body -->
                                
                            </div><!-- /.box -->
                            </div>
                            
                            
                    </div>
<?php
include ('footer.php');
?>
کدای بالا مربوط به فایل اصلی هستش..
اما فایلی که من ویرایش کردم تا الان ...
کد پی‌اچ‌پی:
<?php ?><?php
include ('header.php');
if (isset(
$_POST['ok'])) {
    if (
$_SESSION['code'] == $_POST['code']) {
        
$jens intval($_POST['for']);
        
$email debug($_POST['email']);
        
$line debug($_POST['line']);
        
$yahoo debug($_POST['yahoo']);
        
$instagram debug($_POST['instagram']);
        
$tahsil debug($_POST['tahsil']);
        
$url debug($_POST['url']);
        
$name debug($_POST['name']);
        
$age debug($_POST['age']);
        
$city debug($_POST['city']);
        
$shoghl debug($_POST['shoghl']);
            if (
okmail($email)) {
                if (!
mysql_num_rows(mysql_query("SELECT `id` FROM `user` WHERE `email`='$email' LIMIT 1"))) {
                    
$url str_replace('http://'''$url);
                    
$url.= '/';
                    
$url explode('/'$url);
                    
$url $url['0'];

                        
$b 1;
                        if (
$b) {
                            
mysql_query("INSERT INTO `user`(`email`, `url`, `name`,`age`,`city`,`shoghl`,`jens`,`line`,`kik`,`yahoo`,`instagram`,`facebook`,`twitter`,`nimbuzz`,`tahsil`) VALUES ('$email','$url','$name','$age','$city','$shoghl','$jens','$line','$yahoo','$instagram','$tahsil')");
                            
$show 'مشخصات شما با موفقیت ثبت شد</b>';
                            
$e 'عضويت شما در سيستم با موفقيت انجام شد .
<br />
<a href="' 
$configsiteadd['url'] . '">افزایش ادد لیست : تمامی شبکه های اجتماعی و مسنجر ها</a>';
                            
sendmail($email'عضويت شما با موفقيت انجام شد .'$e);
                        }
                } else {
                    
$show 'ايميل وارد شده قبلا استفاده شده است .';
                }
            } else {
                
$show 'ايميل وارد شده صحيح نمي باشد .';
            }

    } else {
        
$show 'کد امنيتي وارد شده اشتباه است .';
    }
    
$_SESSION['code'] = '';
}
if (
$show) {
    echo 
'

<div class="alert alert-info alert-dismissable">
                                        <i class="fa fa-info"></i>
                                        <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
                                        <b>' 
$show '!</b> 
                                    </div>
 '
;
}
?>
  <div class="row">
                        
                            
                            <div class="col-md-6">
                            <!-- Info box -->
                            <div class="box box-primary">
                                <div class="box-header">
                                    
                                    <h2 dir="rtl" class="box-title"><i class="fa fa-foursquare"></i>&nbsp;  <a href="#" title="فرم ثبت نام" >فرم ثبت نام</a></h2>
                                </div>
                                <div dir="rtl" class="box-body">
                            


  <form  method="post" action="">
<div class="form-group">
                                            <label for="exampleInputEmail1">نام:*</label>
                                            <input dir="rtl" type="text" class="form-control" name="name" placeholder="نام">
                                       <div class="alert alert-info alert-dismissable">
                                        
                                       
                                        <b>وارد کردن نام اجباري است</b> 
                                    </div>
                                        </div>
  <div class="form-group">
                                            <label for="exampleInputEmail1">ايميل شما:*</label>
                                            <input type="email" name="email" class="form-control"  placeholder="[email protected]">
                                            <div class="alert alert-info alert-dismissable">
                                        
                                       
                                        <b>ايميل را کامل و دقيق وارد کنيد</b> 
                                    </div>
                                        </div>
                        
<div class="form-group">
                                            <label for="exampleInputEmail1">آي دي لاين:</label>
                                            <input dir="ltr" type="text" class="form-control" name="line" placeholder="LINE ID">
                                            <div class="alert alert-info alert-dismissable">
                                       
                                       
                                        <b>آي دي خود در لاين را وارد کنيد</b> 
                                    </div>
                                        </div> 

<div class="form-group">
                                            <label for="exampleInputEmail1">آي دي ياهو:</label>
                                            <input dir="ltr" type="text" class="form-control" name="yahoo" placeholder="YAHOO ID">
                                            <div class="alert alert-info alert-dismissable">
                                       
                                       
                                        <b>براي مثال : [email protected]</b> 
                                        <b>براي مثال : [email protected]</b> 
                                    </div>
                                        </div> 

<div class="form-group">
                                            <label for="exampleInputEmail1">اکانت اينستاگرام:</label>
                                            <input dir="ltr" type="text" class="form-control" name="instagram" placeholder="INSTAGRAM ACCOUNT">
                                            <div class="alert alert-info alert-dismissable">
                                       
                                       
                                        <b>اکانت خود در اينستاگرام را وارد کنيد</b> 
                                    </div>
                                        </div> 

                
  <div class="form-group">
                                            <label for="exampleInputEmail1">آدرس سايت:</label>
                                            <input dir="ltr" type="text" class="form-control" name="url" placeholder="http://">
                                            <div class="alert alert-info alert-dismissable">
                                       
                                       
                                        <b>آدرس سايت را با http:// وارد کنيد</b> 
                                    </div>
                                        </div> 

                                        
                                        <div class="form-group">
                                            <label for="exampleInputEmail1">سن:</label>
                                            <input dir="rtl" type="text" class="form-control" name="age" placeholder="سن">
                                        </div>
                                        <div class="form-group">
                                            <label for="exampleInputEmail1">شهر:</label>
                                            <input dir="rtl" type="text" class="form-control" name="city" placeholder="شهر">
                                        </div>
                                        <div class="form-group">
                                            <label for="exampleInputEmail1">شغل:</label>
                                            <input dir="rtl" type="text" class="form-control" name="shoghl" placeholder="شغل">
                                        </div>
<div class="form-group">
                                            <label for="exampleInputEmail1">تحصیلات:</label>
                                            <input dir="rtl" type="text" class="form-control" name="tahsil" placeholder="تحصیلات">
                                        </div>
                                        <div class="form-group">
                                            <label for="exampleInputEmail1">جنسيت:</label>
                                            <select name="for" class="form-control">
                                                
                                                <option value="0">مرد</option>
                                                <option value="1">زن</option>
                                            </select>
                                            </div>




<div class="form-group">
                                            <label for="exampleInputEmail1">کد امنیتی:</label>
                                            <input dir="ltr" class="form-control" type="text" name="code" placeholder="Code ...">
<img alt="کد امنيتي" title="کد امنيتي" src="/captcha"/>
                                            </div>


    




    <input type="submit" class="btn btn-primary" value="ثبت مشخصات" name="ok"/>
    
     </form>
                              </div><!-- /.box-body -->
                                
                            </div><!-- /.box -->
                            </div>  
 
                            
                            <div class="col-md-6">
                            <!-- Info box -->
                            <div class="box box-primary">
                                <div class="box-header">
                                    
                                    
                                    <h2 dir="rtl" class="box-title"><i class="fa fa-foursquare"></i>&nbsp;  <a href="#" title=" نکاتي براي ثبت نام" > نکاتي براي ثبت نام </a></h2>
                                </div>
                                <div dir="rtl" class="box-body">
                                    
                                    
                                    <p><i class="fa fa-align-right"></i> &nbsp; 
                                    ايميل http:// و wwww ندارد
                                    </p><br />
                                    
                                    <p><i class="fa fa-align-right"></i> &nbsp; 
                                    در صورت وارد نکردن سن شغل شهر و اي دي ها مشکلي پيش نمي آيد
                                    </p><br />
                                    
                                    <p><i class="fa fa-align-right"></i> &nbsp; 
                                    هر ايميل فقط يک بار مي تواند ثبت نام کند
                                    </p><br />
                                    
                                    
                                </div><!-- /.box-body -->

                                
                            </div><!-- /.box -->
                            </div>
                            
                            
                    </div>
<?php
include ('footer.php');
?>
من این فایلو ویرایش کردم و اجباری کردن وارد کردن سایت و درباره سایت رو برداشتم
حالا میخوام برای نام و ای دی لاین کمک کنید , با چه دستوری میشه که اگر این دو خالی بود و یا تکراری بود برای کاربر ارور ثبت بشه .
پیشاپیش مرسیHeart
  پاسخ
تشکر شده توسط :
#2
Huhیعنی کسی نبود جوابی به من بده !
  پاسخ
تشکر شده توسط :
#3
سلام .
برای خالی بودن نام و ایدی میتونی یه شرط ساده بذاری.
اما برای سرچ کردن داخل دیتابیس و چک کردن این که آیا تکراری هست یا نه از این کر میتونید استفاده کنید.
کد:
if(($username == "") || ($line == "")){
        $message = '<span style="color: #c32500" class="glyphicon glyphicon-exclamation-sign"></span>     لطفا تمامی اطلاعات را تکمیل فرمایید.     ';
    }
    else{
        $query = mysqli_query($connection, "SELECT * FROM table_name WHERE line='$line' AND username='$username'");
        $rows = mysqli_num_rows($query);
        if ($rows == 1) {
                $message = '<span style="color: #c32500" class="glyphicon glyphicon-exclamation-sign"></span>     نام کاربری یا ایدی لاین تکراری میباشد.     ';
        } else {
             کد هاتون.
        }
    }
echo $message;

فقط $connection رو باید کانکشن خودت بذاری بعدم table_name رو هم اسم جدولت بدار
هیچی دگ :|
  پاسخ
تشکر شده توسط :


پرش به انجمن:


کاربران در حال بازدید این موضوع: 1 مهمان