how to validate a rss feed address

Problems with the Windows version of XAMPP, questions, comments, and anything related.

how to validate a rss feed address

Postby ym_chaitu » 21. November 2009 16:53

Hai
i am building a site for validation of the RSS feeds and adding it in the database.
When a user enters a rss web address i need to validate the address and if it contains a rss then i need to enter it into the site or else i need to mention a message..
how do i do it.
i think the easy way is to pass the feed address to this address http://validator.w3.org/feed/check.cgi?url=

but how can i check what result is it giving..
do any one have an idea or else if u have any validation things available. kindly help me out..
Code: Select all
<html>
<body>
<form action="subscription.php" method="post">
<b>Add New Subscription URL :</b><input name="subscr" value="" size="50">
<input type="submit" name="submit" value="Add" />
</form>
</body>
</html>

<?php
//include("login.php");
include("access.php");
mysql_select_db($dbname);
if (isset($_COOKIE['user']))
{
   echo "Welcome $_COOKIE[user]<br>";
   $username="$_COOKIE[user]";
   //echo "<p>$username</p>";
   $query = mysql_query("SELECT email,password FROM userlogin WHERE username = '$username'") or die(mysql_error());
   $data = mysql_result($query,0);
   //echo $data;
}
else
{
   echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"1; URL=login.php\">";
}

$subscr=$_REQUEST['subscr'];
if($subscr)
{
   //url validation

if (preg_match('|^http(s)?://[a-z0-9-]+(.[a-z0-9-]+)*(:[0-9]+)?(/.*)?$|i', $subscr))
{
    //print "$subscr url OK.";
   mysql_select_db($dbname);
   $re=mysql_query("select * from usubs where url='$subscr'");
   $rows=mysql_num_rows($re);
   if($rows==0)
      {
         mysql_query("Insert into usubs(email,url) values('$data','$subscr')");   
         //echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"1; URL=all.html\">";
      }
   else
      {
         echo "The $subscr url already exists with your login";
         //echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"1; URL=subscription.php\">";
      }
   
}
 else
 {

    print "$subscr url not valid!";
}
}
else
{
   //echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"1; URL=subscription.php\">";
   //echo("$subscr");
}
?>


this is my code
presently i am using the regular expression of the website address but how do i use it to verify the rss feed address..
as the present one is validating the www.google.com also as a valid feed..
--
Chaitanya Babu Yanamadala
www.drvirusindia.co.cc
User avatar
ym_chaitu
 
Posts: 33
Joined: 13. November 2009 08:26
Location: Bangalore,India

Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 50 guests