cdmafra Posted March 26, 2014 Share Posted March 26, 2014 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") ; ?> Quote Link to comment Share on other sites More sharing options...
trq Posted March 26, 2014 Share Posted March 26, 2014 If the guid is being trimmed from the URL there isn't much you can do. Quote Link to comment Share on other sites More sharing options...
cdmafra Posted March 27, 2014 Author Share Posted March 27, 2014 If the guid is being trimmed from the URL there isn't much you can do. So, what must I change but keeping a website that not needs to create a page per each new article? Quote Link to comment Share on other sites More sharing options...
cdmafra Posted March 27, 2014 Author Share Posted March 27, 2014 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>"; ?> Quote Link to comment Share on other sites More sharing options...
trq Posted March 27, 2014 Share Posted March 27, 2014 Your problem is as clear as mud. Quote Link to comment Share on other sites More sharing options...
cdmafra Posted March 27, 2014 Author Share Posted March 27, 2014 Your problem is as clear as mud. I don't find the problem... I tried different things and nothing works the way I want... Quote Link to comment Share on other sites More sharing options...
SitdGames Posted March 27, 2014 Share Posted March 27, 2014 (edited) 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 March 27, 2014 by SitdGames Quote Link to comment Share on other sites More sharing options...
cdmafra Posted March 27, 2014 Author Share Posted March 27, 2014 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.