Jump to content

"Static" URL php/mysql


cdmafra

Recommended Posts

I have a problem when I share a link of my website, that remains "static".
I mean: when I share an article (link www.mysite.net/?guid=VALUE) in social networks, the post text is normal, but when I click in the article picture or title, the link that opens is the "normal" of my website (www.mysite.net). The title and description not change too. Code:
<META ITEMPROP="name" CONTENT="text/html; charset=utf-8">
 <?php include("login/db_connect_open.php") ;
 ?>




<?php 
if (isset($_REQUEST["guid"]))
{
    $guid = mysql_real_escape_string($_REQUEST["guid"]); // sanitize the guid 
    $query = "SELECT * FROM news WHERE news_guid='".$guid."'"; 
    $result = mysql_query($query); $row = mysql_fetch_array($result); ?>




<div class="twelve columns">
<div class="row"><h3 class="n3"><?php echo $row["news_title"]; ?></h3>
</div>
</div>
<div class="row"><!-- Row interior-->
<div class="twelve columns">
<div class="panel">
<p id="data"><?php echo $row["news_date"]; ?>, <?php echo $row["hour"];?> GMT</p>
<p><?php echo $row["news_post"]; ?></p>
</div></div></div>
<?php
}
else
?>
<div class="twelve columns">
<div class="row"><h3 class="n3">Destaques</h3>
</div>
<div class="row">
<?php
{
$query = "SELECT * FROM news WHERE destaque='Sim' and publicado='sim' ORDER BY news_id DESC LIMIT 4";
$result = mysql_query($query);


while ($row = mysql_fetch_array($result))




{
echo "<div class='three columns'>";
echo "<a href='?guid=".$row["news_guid"]."' class='div-link'>";
  echo "<div class='desc-new'>";
  //imagem
  echo "<div class='img-block'><img src='".$row['news_image']."' title='".$row["news_title"]."' alt='".$row["news_title"]."'/></div>";
  //texto
  echo "<h4 class='new-title' onmouseover='none'>".$row["news_title"]."</h4>";
echo "<h4 class='new-subtitle' onmouseover='none'>".$row["news_subtitle"]."</h4>";
echo "<aside><p>".$row["news_desc"]."</p><p class='datapeq'>".$row["news_date"].", ".$row["hour"]."</p></aside>";
  echo "</div>";
echo "</a>";
echo "</div>";
}


}
?>
</div></div>
        


<!-- Fim de row interior -->
 <?php include("login/db_connect_close.php") ;
 ?>

 

Link to comment
Share on other sites

I have solved part of my problem, creating a page to generate the news (now, the link works properly: "http://www.mysite.net/NEWS.PHP?guid=VALUE"). However, I have another problem now: I can't take apart the "news.php" from the URL when I open an article, I mean: the pages are shown correctly, but with URL "http://www.mysite.net/NEWS.PHP?p=7".

 

Code that generates the menu:

<?php
$query = "select * from menu order by ordem";
$result = mysql_query($query);


echo "<ul>";


while ($row = mysql_fetch_array($result))


{ 
if ($p==$row["id"]) 
{
echo  "<li class='menu'>".$row["element"]."</li>";
}
else
{
echo  "<li><a href=?'p=".$row["id"]."' class='menu'>".$row["element"]."</a></li>";
}


}


echo "</ul>";
?>
Link to comment
Share on other sites

I think I know what you want... you want the trailing part, the "guid?=###" to be removed, right?

 

This is a bit tricky, but here's how I would handle it:

 

Have a landing php script, like redirect.php. Have it capture the variable, and after sanitation store it in the session.

<?php
session_start();

$link = filter_var($_REQUEST["guid"], FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW);
$_SESSION['guid'] = $link;

header( 'Location: http://www.yoursite.com/index.php' )
?>

And then on your main index page, you'll have to pull the link out of the session with:

<?php
session_start()

$link = $_SESSION['guid'];

... 

The only issues with this is that there's really no way to bookmark it, but it will give you the www.yoursite.com/ for all of your news articles. If you're looking for something else, please elaborate.

Edited by SitdGames
Link to comment
Share on other sites

I think I know what you want... you want the trailing part, the "guid?=###" to be removed, right?

 

This is a bit tricky, but here's how I would handle it:

 

Have a landing php script, like redirect.php. Have it capture the variable, and after sanitation store it in the session.

<?php
session_start();

$link = filter_var($_REQUEST["guid"], FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW);
$_SESSION['guid'] = $link;

header( 'Location: http://www.yoursite.com/index.php' )
?>

And then on your main index page, you'll have to pull the link out of the session with:

<?php
session_start()

$link = $_SESSION['guid'];

... 

The only issues with this is that there's really no way to bookmark it, but it will give you the www.yoursite.com/ for all of your news articles. If you're looking for something else, please elaborate.

 

No, no. I need the ?guid=### .

When I open an article, the link is as follow : mysite.net/news.php?guid=###

Once inside an article, all links are "mysite.net/news.php?", being an article or not. In "main" pages, all is working normally until open an article. 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.