doujiao3074 2017-11-22 19:37
浏览 74
已采纳

php不会在索引网站上显示数据

I have 3 files, one index.php, one instapic.php and one instapic.sh The php is supposed to execute sh to show an image but it wont work when it is on the "index" site, it worked earlier when it was directed to /instapic.php but i want it to display on main index page.

<html>
<head>
<style>
div {
font family: Ubuntu;
background-color: #F2F2F2;
}
</style>
</head>
<body>
<div>
<h1> <center> Instagram Full Size Profile Picture </center> </h1>
</div>
<center>
<form action="" method="get">
Enter Instagram Username: <input type="text" name="input">
<input type="submit" value="View">
</form>
</center>
</body>

<?php
$name = $_REQUEST['input'];
echo $name;
echo "<br>";
$output = shell_exec("/var/www/html/instapic.sh $name");
echo "<img src=$output>";
?>

-

#!/bin/bash
NAME=$1
#curl -s https://www.instagram.com/$NAME/ | grep image | grep fbma | sed 's,s150x150/,,g' | cut -f 4 -f '"'
curl -s https://www.instagram.com/$NAME/ | grep "og:image" | sed 's,s150x150/,,g' | cut -f 4 -f '"'
  • 写回答

1条回答 默认 最新

  • dsmvovm27249 2017-11-22 20:05
    关注

    To achieve this you need to can add some PHP code on your index and just send your form to the same page. If you don't want to reload the page every time you have to send an ajax call. It could be a solution (not the best at all):

    Include this at the beginning of you index.php file :

    <?php 
      if(isset($_REQUEST['input'])) {
        $name = $_REQUEST['input'];
        $output = shell_exec("/var/www/html/instapic.sh $name");
      }
    >
    

    And Include this where you want to display the images :

    <?php
      if(isset($output)) {
        echo "<img src=$output>";
      }
    >
    

    Also don't forget to add "index.php' on the action attribute of the form

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 拟通过pc下指令到安卓系统,如果追求响应速度,尽可能无延迟,是不是用安卓模拟器会优于实体的安卓手机?如果是,可以快多少毫秒?
  • ¥20 神经网络Sequential name=sequential, built=False
  • ¥16 Qphython 用xlrd读取excel报错
  • ¥15 单片机学习顺序问题!!
  • ¥15 ikuai客户端多拨vpn,重启总是有个别重拨不上
  • ¥20 关于#anlogic#sdram#的问题,如何解决?(关键词-performance)
  • ¥15 相敏解调 matlab
  • ¥15 求lingo代码和思路
  • ¥15 公交车和无人机协同运输
  • ¥15 stm32代码移植没反应