更正代码

时间:2016-11-24 10:46:50

标签: php html

我需要你的帮助

我已经完成了目前没有运行的代码显示和演示

我会把代码放进去,希望你能理解它的重要性

此代码

<form method="POST" action=<?php ($_SERVER["PHP_SELF"]); ?>>
    <p>chose url: <select size="1" name="D1">
    <option url="https://drive.google.com/file/d/$google/view" value="google_drive">google drive</option>
    <option url="https://www.cloudy.ec/embed.php?id=$cloudy" value="clody">clody</option>
    </select>    <input type="text" name="T1" size="40" value="insert code">    <input type="submit" value="go" name="B1"><input type="reset" value="reset" name="B2"></p>
</form>

demo

谢谢大家

2 个答案:

答案 0 :(得分:0)

我想你想要这样的东西?

<?php
if(!empty($_POST['D1']) && !empty($_POST['T1'])){
    $providers = array(
        'google_drive' => 'https://drive.google.com/file/d/{replace}/view',
        'clody' => 'https://www.cloudy.ec/embed.php?id={replace}'
    );

    if(isset($providers[$_POST['D1']])){

        $url =  str_replace('{replace}', $_POST['T1'], $providers[$_POST['D1']]);
        echo "Your url is $url";
    }


}
?>

<form method="POST" action=<?php ($_SERVER["PHP_SELF"]); ?>>
    <p>chose url: 
    <select size="1" name="D1">
        <option value="google_drive">google drive</option>
        <option value="clody">clody</option>
    </select>    
    <input type="text" name="T1" size="40" value="insert code">    
    <input type="submit" value="go" name="B1"><input type="reset" value="reset" name="B2">
    </p>
</form>

答案 1 :(得分:0)

你应该这样做。

<?php
if(isset($_POST['B1'])){
     $arrUrl = array(
      'google_drive' => 'https://drive.google.com/file/d/'.$_POST['T1'].'/view',
      'clody' => 'https://www.cloudy.ec/embed.php?id='.$_POST['T1']
    );

   $url = $arrUrl[$_POST['D1']];
   //echo  $url = $arrUrl[$_POST['D1']];
   //exit();
   header('location:'.$url); 


}
?>
<form method="POST" action=<?=$_SERVER["PHP_SELF"]?> >
    <p>chose url: <select size="1" name="D1">
    <option value="google_drive">google drive</option>
    <option value="clody">clody</option>
    </select>
     <input type="text" name="T1" size="40" placeholder="insert code">  
       <input type="submit" value="go" name="B1">
       <input type="reset" value="reset" name="B2"></p>
</form>

从选项中删除url =“http:link”

请找到附件。 image

三江源。