doukan6564 2014-08-25 02:00
浏览 45
已采纳

PHP链接提交循环

I came up with a app idea that allows Link Searches for a website. I am trying to get the app to automatically save searches for the user.

Here is some of my code that is written up. What I am trying to achieve is the ability to enter random links from websites that I like and display the links within the app and automatically save the inputs.

Is there a way to save links within a page in PHP? Fairly new to PHP. Sorry!

Here is a link - http://www.andulicsdesign.com/Blakes/Index.php

<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>Indeed Link Search App</title>
<script type="text/javascript">
$(document).ready(function() {
      $('#formid form').submit(function(){
              $.get('result.php', $(this).serialize(), function(data){
                      $('#result').html(data);

              });                             
              return false;
      });
});
</script>
</head>

<body>
<div id="container>
<div id="formid">
<form> 
Job Title<input type="text" name="message" value="" /> 
<input type="submit" value="Submit" /> 
</form>
</div>

<div id="result">
<?php 
echo '<div style="background-color:#fff; padding:20px">' . $_POST['message'] . '</div>'; 
?>
<?php

$message=$_REQUEST['message'];

echo $message;
?>
</div>
</div>
</body>
</html>
  • 写回答

2条回答 默认 最新

  • dpkajqd31574096 2014-08-25 02:34
    关注

    There are some options for saving information.

    The simplest is save in the session, but the list will be cleared when you close your browser.

    session_start(); //in the begin of file
    
    $_SESSION['links'][] = $_REQUEST['message']; //add to array of links
    $_SESSION['links'] = array_unique($_SESSION['links']); //removes duplicate links
    
    foreach($_SESSION['links'] as $link) {
      // do something with each link in array
    }
    

    To keep the information between sessions you need to use a database like MySQL.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 相敏解调 matlab
  • ¥15 求lingo代码和思路
  • ¥15 公交车和无人机协同运输
  • ¥15 stm32代码移植没反应
  • ¥15 matlab基于pde算法图像修复,为什么只能对示例图像有效
  • ¥100 连续两帧图像高速减法
  • ¥15 如何绘制动力学系统的相图
  • ¥15 对接wps接口实现获取元数据
  • ¥20 给自己本科IT专业毕业的妹m找个实习工作
  • ¥15 用友U8:向一个无法连接的网络尝试了一个套接字操作,如何解决?