将href属性传递到另一个php页面 [英] passing href attributes to another php page

查看:51
本文介绍了将href属性传递到另一个php页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

.一点帮助..

我有一个index.php页面,其中包含标签,这些标签在单击时会打开picture.php..my picture.php是一个页面,可根据idno从某个数据库检索图像.

.我要做的是在我的锚标签上添加一个"idno"属性,当用户单击某个标签时,index.php将idno发送给我的picture.php,以便picture.php知道什么图像从数据库中获取.请帮助!

解决方案

那么对于您的锚标记,您可以做这样的事情吗?

 <?php$ url ="pictures.php?idno =".证件号码;echo< a href = \".$ url." \>点击我</a>";?> 

现在在您的 pictures.php 文件中,您可以像这样读取ID:

  $ idno = $ _GET ['idno']; 

唯一需要注意的是在将输入传递给数据库查询之前确保对输入进行清理,这样您就不会受到SQL注入攻击的攻击.<​​/p>

.a little help guys..

I have an index.php page which contains tags which when clicked opens up picture.php. .my picture.php is a page that retrieves images from a certain database depending on what is the idno.

.what i want to do is to add an "idno" attribute on my anchor tag that when the user clicks a certain tag the index.php sends the idno to my picture.php so that the picture.php knows what image to fetch from the database. help pls!

解决方案

So for your anchor tag, could you do something like this?

<?php
    $url = "pictures.php?idno=" . idno;
    echo "<a href=\"" . $url . "\">Click Me</a>";
?>

Now in your pictures.php file, you can read the ID like this:

$idno = $_GET['idno'];

The only thing to watch out for is to make sure you sanitize that input, before you pass it off to a database query so you aren't vulnerable to a SQL injection attack.

这篇关于将href属性传递到另一个php页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆