dongzhao5834 2016-02-18 12:17
浏览 60

提交表单(PHP):提交我的PHP代码后似乎没有执行

I have an issue with my php form. I have an application that manages users in a LDAP server so I want to give the possibility to users to change their password anytime they want to using a form.

In the form we need tree informations (old password, newwpassword and the uid of the concerned ldap entry). We extract the uid from the displayName which can be a complete name: we consider that the first word is always the uid (just to notice it but that's not much important here).

So i have the form with this following code:

<?php
  // echo '<pre>';  
// print_r($_POST);
  // echo '</pre>';

  function str_to_noaccent($str) { 
    $url = $str; 
    $url = preg_replace('#Ç#', 'C', $url); 
    $url = preg_replace('#ç#', 'c', $url); 
    $url = preg_replace('#è|é|ê|ë#', 'e', $url);
    $url = preg_replace('#È|É|Ê|Ë#', 'E', $url);
    $url = preg_replace('#à|á|â|ã|ä|å#', 'a', $url);
    $url = preg_replace('#@|À|Á|Â|Ã|Ä|Å#', 'A', $url);
    $url = preg_replace('#ì|í|î|ï#', 'i', $url);
    $url = preg_replace('#Ì|Í|Î|Ï#', 'I', $url);
    $url = preg_replace('#ð|ò|ó|ô|õ|ö#', 'o', $url);
    $url = preg_replace('#Ò|Ó|Ô|Õ|Ö#', 'O', $url);
    $url = preg_replace('#ù|ú|û|ü#', 'u', $url);
    $url = preg_replace('#Ù|Ú|Û|Ü#', 'U', $url);
    $url = preg_replace('#ý|ÿ#', 'y', $url);
    $url = preg_replace('#Ý#', 'Y', $url);
    return ($url);
  }

  if(isset($_POST['soumission']))
  {
     if(isset($_POST['oldpassword']) && isset($_POST['newpassword']) && isset($_POST['displayName']))
     {
     $oldpasswd = $_POST['oldpassword'];
         $newpassd = $_POST['newpassword'];
         $arr = explode('',$_POST['displayName']);
     $user_uid = str_to_noaccent(strtolower($arr[0]));

         $cmd = exec('script.sh '.$oldpasswd.' '.$newpassd.' '.$user_uid);
     if($cmd)
     {
       echo '<script language="text/javascript">';
       echo 'alert("Mot de passe changé avec succès!")';
       echo '</script>';
     }
     else
     {
       echo '<script language="text/javascript">';
       echo 'alert("Impossible de changer de mot de passe!")';
       echo '</script>';
     }
    }
   }
?>

<form class="section" method="post" action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']); ?>">
    <h2>Mot de passe</h2>
    <input type="password" name="oldpassword" placeholder="Ancien mot de passe" autocomplete="off" autocapitalize="off" autocorrect="off" />
    <input type="password" id="pass2" data-typetoggle="#personal-show" name="newpassword" placeholder="Nouveau mot de passe" autocomplete="off" autocapitalize="off" autocorrect="off" />
    <input type="checkbox" id="personal-show" name="show" /><label for="personal-show"></label>
    <input type="hidden" id="displayName" name="displayName"
    value="<?php p($_['displayName']) ?>"
    autocomplete="on" autocapitalize="off" autocorrect="off" readonly />
    <input type="submit" name="soumission" value="Changer le mot de passe"/>
   <div class="strengthify-wrapper"></div>
</form>
<?php
?>

The content of the script.sh is as follows:

#! /bin/bash
/usr/bin/ldappasswd -h @IP_ldap_server -p 389 -x -D 'cn=admin,dc=xxxxx,dc=xxxxx,dc=xx' -w xxxxxx -a $1 -s $2 uid=$3,ou=xxxx,dc=xxxx,dc=xxxx,dc=xx

Everything like script.sh, str_to_noaccent, etc. have been tested individually and works perfectly. Even the print_r($_POST); shows that form values are well get.

But it seems that the php code is not executed (from the if(isset($_POST['soumission'])) to the end of the first php block). It's been days but I still can figure out why. Can sombebody here help to find what's wrong?

Thank you all very much in advance.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
    • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
    • ¥15 手机接入宽带网线,如何释放宽带全部速度
    • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
    • ¥15 ETLCloud 处理json多层级问题
    • ¥15 matlab中使用gurobi时报错
    • ¥15 这个主板怎么能扩出一两个sata口
    • ¥15 不是,这到底错哪儿了😭
    • ¥15 2020长安杯与连接网探
    • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么