PDA

View Full Version : حرفه ای: مشکل در پردازش سمت سرور در php



farshid1994
پنج شنبه 14 خرداد 1394, 11:12 صبح
یک pageی دارم که در اون کاربر رجیستر میکند و اطلاعات فرم نیز به همان صفحه ارسال می شود ولی زمانی که به این شرط می رسد دیگر بقیه را بررسی نمی کند این لینک (https://goo.gl/uUQ9O8)پروژه بنده برای دانلود است. لطفا راهنمایی کننید.
البته این سوال رو در stackoverflow هم مطرح کردم این هم لینک سوال:
http://stackoverflow.com/questions/30631276/if-server-request-method-post-dont-work-when-form-post

لطفا کمک کنید این مساله رو حل کنم!

under22
پنج شنبه 14 خرداد 1394, 11:14 صبح
لطفا کدتون رو اینجا بزارید

farshid1994
پنج شنبه 14 خرداد 1394, 11:40 صبح
من تو این پروژه از securimage captcha استفاده کرده ام:

<?PHP session_start();$err='';
if ($_SERVER['REQUEST_METHOD'] == 'POST'){ include_once dirname(__FILE__).'/process/dbconfig.php';
$flag=true;
if(isset($_POST['captcha_code'])){ include_once dirname(__FILE__) . '/captcha/securimage.php'; $captcha = $_POST['captcha_code']; $image = new Securimage();
if ($image->check($captcha) == false) { $flag=false; $_SESSION['caperr']='Invalid captcha code'; //$err='Invalid captcha code'; header('Location: '.'reister.php'); } //print_r($_SESSION['caperr']); if(isset($_POST['firstname']) && isset($_POST['lastname']) && isset($_POST['username']) && isset($_POST['password1']) && isset($_POST['password2']) && isset($_POST['day']) && isset($_POST['year']) && isset($_POST['month']) && isset($_POST['cell']) && isset($_POST['agree']) && isset($_POST['gen']) && ($_POST['password1']==$_POST['password2']) && $flag && isset($_POST['agree'])){
$conn = new PDO("mysql:host=$host;dbname=$dbname", $username, $password); $sql = $conn->prepare('Insert into users(firstname,lastname,username,password,birthda y,gender,phone)values(:firstname,:lastname,:user,: pass,:birth,:gen,:phone)'); $user=$_POST['username']; $firstname=$_POST['firstname']; $lastname=$_POST['lastname']; $pass=md5($_POST['password1']); $birth=$_POST['day'].'-'.$_POST['month'].'-'.$_POST['year']; $gen=$_POST['gen']; $phone=$_POST['cell'];
$sql->bindParam(':user',$user,PDO::PARAM_STR,60); $sql->bindParam(':firstname',$firstname,PDO::PARAM_STR,5 0); $sql->bindParam(':lastname',$lastname,PDO::PARAM_STR,80) ; $sql->bindParam(':pass',$pass,PDO::PARAM_STR,60); $sql->bindParam(':gen',$gen,PDO::PARAM_BOOL); $sql->bindParam(':birth',$birth,PDO::PARAM_STR,10); $sql->bindParam(':phone',$phone,PDO::PARAM_STR,11); if($sql->execute()){ $_SESSION['success']='Your register is successful! '; } } else{ if(!($_POST['password1']==$_POST['password2'])){ $_SESSION['errsubmitp']='Your passwords must same!'; } else $_SESSION['errsubmit']='Please fill all inputs!'; $_SESSION['caperr']='Invalid captcha code';
header('Location: '.'reister.php'); } } else{ echo "uuuuuuuuuuuuuuuuuuu"; $_SESSION['captchafill']='Please Fill captcha code'; header('Location: '.'reister.php');
}}?>
<html><head> <title>Register</title> <link href="content/css/main.css" rel="stylesheet" /> <script src="content/js/jquery.js"></script> <script src="content/js/jBox.min.js"></script> <link href="content/css/jBox.css" rel="stylesheet" /> <script src="content/js/icheck.js"></script> <link href="content/css/minimal.css" rel="stylesheet" /> <script src="content/js/js.js"></script> <link href="content/css/chosen.min.css" rel="stylesheet" /> <script src="content/js/chosen.jquery.min.js"></script>
</head>
<body> <div id="page"> <div id="head"> <h2>Create your account</h2> </div>
<div id="content"> <div id="lefthalf"> <span id="ajax_user" class="ajax_username"></span>
<?php if(isset($_SESSION['success'])) {?> <div id="success" style="height: 60px;background-color: #53a642; text-align: center;"> <div> <p style=" margin-left: 62px; float: left;"><?= $_SESSION['success']?></p> <a href="login.php" style="text-decoration: none;color: #ff0; margin-left: 7px; margin-top: 15px; float: left;">Login</a> </div> </div> <?php unset($_SESSION['success']); }?>
<form action="" method="post" name="register">
<?php if(isset($_SESSION['errsubmit'])){ ?> <span id="all"><?=$_SESSION['errsubmit'];?></span> <?php unset($_SESSION['errsubmit']); }?>
<div id="name"> <label>Name</label> <input type="text" class="tooltip" name="firstname" placeholder="First" id="first" title="Please Enter Your FirstName!" style="margin-right:10px;" /> <input type="text" class="tooltip" name="lastname" placeholder="Last" id="last" title="Please Enter Your LastName!" /> <span id="firsterr"></span> <span id="lasterr"></span> </div> <div id="username"> <label>Choose your username</label> <input type="text" id="usernamef" name="username" class="tooltip" title="Please Enter Your UserName!" placeholder="Enter Username" /> <span id="usernameerr" class="tooltip"></span> <span id="valid"></span> <label>Create a password</label> <input type="password" name="password1" id="pass" class="tooltip" title="Please Enter Your Password!" placeholder="Enter Your password" /> <span id="passerr"></span> <label>Confirm your password</label> <input type="password" id="conf" name="password2" class="tooltip" title="Please Confirm Your Password!" placeholder="Confirm Your password" /> <span id="conferr"></span>
<?php if(isset($_SESSION['errsubmitp'])){?> <span id="confierr2"><?=$_SESSION['errsubmitp'];?></span> <?php unset($_SESSION['errsubmitp']); }?>
<span id="confierr"></span> </div> <div id="born"> <label>Birthday</label> <div id="test"> <select class="my_select_box chosen-select-no-results" tabindex="-1" id="month" data-placeholder="Month" name="month"> <option></option> <option value="1">January</option> <option value="2">February</option> <option value="3">March</option> <option value="4">April</option> <option value="5">May</option> <option value="6">June</option> <option value="7">July</option> <option value="8">August</option> <option value="9">September</option> <option value="10">October</option> <option value="11">November</option> <option value="12">December</option> </select> </div>
<input type="text" placeholder="Day" name="day" id="day" class="tooltip" title="Please Enter Your Born Day!" maxlength="2" onkeydown="prevent('#day');" />
<input type="text" placeholder="Year" name="year" id="year" class="tooltip" title="Please Enter Your Born Year!" maxlength="4" onkeydown="prevent('#year');" />
<span id="montherr"></span> <span id="dayerr"></span> <span id="yearerr"></span> </div> <div id="info"> <label>Gender</label> <select id="gen" class="my_select_box chosen-select-no-results" name="gen"> <option value="13">I am ...</option> <option value="Male">Male</option> <option value="Fmale">Fmale</option> </select> <span id="gendererr"></span> <label>Mobile phone</label> <div id="cell"> <span>+98</span> <input type="tel" id="tel" name="cell" class="tooltip" title="Please Enter Your Mobile!" maxlength="11" onkeydown="prevent('#tel');" /> </div> <span id="tellerr"></span> </div> <div id="captcha1"> <?php // show captcha HTML using Securimage::getCaptchaHtml() require_once 'captcha/securimage.php'; $options = array(); $options['input_name'] = 'captcha_code'; // change name of input element for form post
echo Securimage::getCaptchaHtml($options); ?> </div>

<?php if(isset($_SESSION['captchafill'])){?> <span id="chaperr1"><?php $_SESSION['captchafill'];?></span> <?php }unset($_SESSION['captchafill']);?>
<span id="chaperr"></span> <div id="agree"> <input type="checkbox" id="agg" name="agree"/> <span style="margin-left:5px;">I agree to the term of services ...</span> </div> <div id="register"> <input type="submit" value="Register" id="reg" disabled="disabled" /> </div> </form> </div> </div>
</div></body>
</html>

farshid1994
پنج شنبه 14 خرداد 1394, 11:43 صبح
من تو این پروژه از securimage captcha استفاده کرده ام و اینم کد صفحه registre:


<?PHP session_start();
$err='';


if ($_SERVER['REQUEST_METHOD'] == 'POST')
{
include_once dirname(__FILE__).'/process/dbconfig.php';


$flag=true;


if(isset($_POST['captcha_code'])){
include_once dirname(__FILE__) . '/captcha/securimage.php';
$captcha = $_POST['captcha_code'];
$image = new Securimage();


if ($image->check($captcha) == false) {
$flag=false;
$_SESSION['caperr']='Invalid captcha code';
//$err='Invalid captcha code';
header('Location: '.'reister.php');
}
//print_r($_SESSION['caperr']);
if(isset($_POST['firstname']) && isset($_POST['lastname']) && isset($_POST['username']) && isset($_POST['password1'])
&& isset($_POST['password2']) && isset($_POST['day']) && isset($_POST['year']) && isset($_POST['month'])
&& isset($_POST['cell']) && isset($_POST['agree']) && isset($_POST['gen']) && ($_POST['password1']==$_POST['password2']) && $flag && isset($_POST['agree'])){


$conn = new PDO("mysql:host=$host;dbname=$dbname", $username, $password);
$sql = $conn->prepare('Insert into users(firstname,lastname,username,password,birthda y,gender,phone)values(:firstname,:lastname,:user,: pass,:birth,:gen,:phone)');
$user=$_POST['username'];
$firstname=$_POST['firstname'];
$lastname=$_POST['lastname'];
$pass=md5($_POST['password1']);
$birth=$_POST['day'].'-'.$_POST['month'].'-'.$_POST['year'];
$gen=$_POST['gen'];
$phone=$_POST['cell'];


$sql->bindParam(':user',$user,PDO::PARAM_STR,60);
$sql->bindParam(':firstname',$firstname,PDO::PARAM_STR,5 0);
$sql->bindParam(':lastname',$lastname,PDO::PARAM_STR,80) ;
$sql->bindParam(':pass',$pass,PDO::PARAM_STR,60);
$sql->bindParam(':gen',$gen,PDO::PARAM_BOOL);
$sql->bindParam(':birth',$birth,PDO::PARAM_STR,10);
$sql->bindParam(':phone',$phone,PDO::PARAM_STR,11);
if($sql->execute()){
$_SESSION['success']='Your register is successful! ';
}
}
else{
if(!($_POST['password1']==$_POST['password2'])){
$_SESSION['errsubmitp']='Your passwords must same!';
}
else
$_SESSION['errsubmit']='Please fill all inputs!';
$_SESSION['caperr']='Invalid captcha code';


header('Location: '.'reister.php');
}
}
else{
echo "uuuuuuuuuuuuuuuuuuu";
$_SESSION['captchafill']='Please Fill captcha code';
header('Location: '.'reister.php');


}
}
?>


<html>
<head>
<title>Register</title>
<link href="content/css/main.css" rel="stylesheet" />
<script src="content/js/jquery.js"></script>
<script src="content/js/jBox.min.js"></script>
<link href="content/css/jBox.css" rel="stylesheet" />
<script src="content/js/icheck.js"></script>
<link href="content/css/minimal.css" rel="stylesheet" />
<script src="content/js/js.js"></script>
<link href="content/css/chosen.min.css" rel="stylesheet" />
<script src="content/js/chosen.jquery.min.js"></script>


</head>


<body>
<div id="page">
<div id="head">
<h2>Create your account</h2>
</div>


<div id="content">
<div id="lefthalf">
<span id="ajax_user" class="ajax_username"></span>


<?php if(isset($_SESSION['success'])) {?>
<div id="success" style="height: 60px;background-color: #53a642; text-align: center;">
<div> <p style=" margin-left: 62px; float: left;"><?= $_SESSION['success']?></p>
<a href="login.php" style="text-decoration: none;color: #ff0; margin-left: 7px; margin-top: 15px; float: left;">Login</a>
</div>
</div>
<?php unset($_SESSION['success']); }?>


<form action="" method="post" name="register">


<?php if(isset($_SESSION['errsubmit'])){ ?>
<span id="all"><?=$_SESSION['errsubmit'];?></span>
<?php unset($_SESSION['errsubmit']); }?>


<div id="name">
<label>Name</label>
<input type="text" class="tooltip" name="firstname" placeholder="First" id="first" title="Please Enter Your FirstName!" style="margin-right:10px;" />
<input type="text" class="tooltip" name="lastname" placeholder="Last" id="last" title="Please Enter Your LastName!" />
<span id="firsterr"></span>
<span id="lasterr"></span>
</div>
<div id="username">
<label>Choose your username</label>
<input type="text" id="usernamef" name="username" class="tooltip" title="Please Enter Your UserName!" placeholder="Enter Username" />
<span id="usernameerr" class="tooltip"></span>
<span id="valid"></span>
<label>Create a password</label>
<input type="password" name="password1" id="pass" class="tooltip" title="Please Enter Your Password!" placeholder="Enter Your password" />
<span id="passerr"></span>
<label>Confirm your password</label>
<input type="password" id="conf" name="password2" class="tooltip" title="Please Confirm Your Password!" placeholder="Confirm Your password" />
<span id="conferr"></span>


<?php if(isset($_SESSION['errsubmitp'])){?>
<span id="confierr2"><?=$_SESSION['errsubmitp'];?></span>
<?php unset($_SESSION['errsubmitp']); }?>


<span id="confierr"></span>
</div>
<div id="born">
<label>Birthday</label>
<div id="test">
<select class="my_select_box chosen-select-no-results" tabindex="-1" id="month" data-placeholder="Month" name="month">
<option></option>
<option value="1">January</option>
<option value="2">February</option>
<option value="3">March</option>
<option value="4">April</option>
<option value="5">May</option>
<option value="6">June</option>
<option value="7">July</option>
<option value="8">August</option>
<option value="9">September</option>
<option value="10">October</option>
<option value="11">November</option>
<option value="12">December</option>
</select>
</div>


<input type="text" placeholder="Day" name="day" id="day" class="tooltip" title="Please Enter Your Born Day!" maxlength="2" onkeydown="prevent('#day');" />


<input type="text" placeholder="Year" name="year" id="year" class="tooltip" title="Please Enter Your Born Year!" maxlength="4" onkeydown="prevent('#year');" />


<span id="montherr"></span>
<span id="dayerr"></span>
<span id="yearerr"></span>
</div>
<div id="info">
<label>Gender</label>
<select id="gen" class="my_select_box chosen-select-no-results" name="gen">
<option value="13">I am ...</option>
<option value="Male">Male</option>
<option value="Fmale">Fmale</option>
</select>
<span id="gendererr"></span>
<label>Mobile phone</label>
<div id="cell">
<span>+98</span>
<input type="tel" id="tel" name="cell" class="tooltip" title="Please Enter Your Mobile!" maxlength="11" onkeydown="prevent('#tel');" />
</div>
<span id="tellerr"></span>
</div>
<div id="captcha1">
<?php
// show captcha HTML using Securimage::getCaptchaHtml()
require_once 'captcha/securimage.php';
$options = array();
$options['input_name'] = 'captcha_code'; // change name of input element for form post


echo Securimage::getCaptchaHtml($options);
?>
</div>




<?php if(isset($_SESSION['captchafill'])){?>
<span id="chaperr1"><?php $_SESSION['captchafill'];?></span>
<?php }unset($_SESSION['captchafill']);?>


<span id="chaperr"></span>
<div id="agree">
<input type="checkbox" id="agg" name="agree"/>
<span style="margin-left:5px;">I agree to the term of services ...</span>
</div>
<div id="register">
<input type="submit" value="Register" id="reg" disabled="disabled" />
</div>
</form>
</div>
</div>


</div>
</body>


</html>