drdyf42880 2014-10-07 12:57
浏览 7

在为用户博客创建动态网址时,我需要为用户指定他们可以创建的网址的可用性吗?

May i know how to check the dynamic url availability for the user within the domain, so that they are allowed to create their own site-url's

Steps that I am following: 1) Through text box they will be able to write their nickname/personal_identity eg: say Custom_Blog

2) So, my website domain would be http://example.com/Custom_Blog/ for the specified user.

3)Conflict: But I do have a tab "http://example.com/Custom_Blog" link created in the htaccess which is used for editing the Blog detailed page of the user.

So, while user entering in the text box i need to validate the availability of the url whether the url is already in use or not ? I tried this code which was not helpful because it was getting the code 302 for the url's that are already used(exists):

$handle = curl_init($url);
curl_setopt($handle,  CURLOPT_RETURNTRANSFER, TRUE);

/* Get the HTML or whatever is linked in $url. */
$response = curl_exec($handle);

/* Check for 404 (file not found). */
$httpCode = curl_getinfo($handle, CURLINFO_HTTP_CODE);
if($httpCode == 404 || $httpCode == 302) {
    /* Handle 404 here. */
}

curl_close($handle);
  • 写回答

1条回答 默认 最新

  • dongsigan2044 2014-10-07 13:03
    关注

    you can use ajax for the validation

    onchange on that input field make request to the php file

    in php file send the response about availability.

    var dataString = {'url':value};
        $.ajax({
            type: "POST",
            url: "somefile.php",
            data: dataString,
            success: function(data) {
        // do some stuff here
        }
    

    in php file get the url and check it

    评论

报告相同问题?

悬赏问题

  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图