Jump to content

2 Questions, Just finding the correct functions


Lamez

Recommended Posts

Question 1:

I am working on a external link checker, but If the user does not add a protocol like http:// or ftp:// or something like that how can I add it to the beginning of the URL?

Example:

-User input: www.google.com

-Code Added: http://www.google.com

 

Question 2

How can I find the address the user came from?

 

-Thanks guys!

Link to comment
Share on other sites

I am sorry, but the code you gave me does not echo anything out.

 

Here is how I integrated it.

<?php
$url = htmlspecialchars($_GET["url"]);
$form = array($url);
if ($form['url'] != '' && strpos(strtolower($form['url']), 'http://') !== 0)
$form['url'] = 'http://'.$form['url'];
$url = $form['url'];

if (!isset($_GET["url"])){
header("Location: http://www.krazypicks.com");
}else{
echo "<center>You are about to leave KrazyPicks! to an external link. <br>Do you want to continue?";
echo "<br>External Link: ".$url."</center>";
?>

 

Thanks!

Link to comment
Share on other sites

I am sorry, but the code you gave me does not echo anything out.

 

Here is how I integrated it.

<?php
$url = htmlspecialchars($_GET["url"]);
$form = $url;
if ($form != '' && strpos(strtolower($form), 'http://') !== 0)
$form = 'http://'.$form;
$url = $form;

if (!isset($_GET["url"])){
header("Location: http://www.krazypicks.com");
}else{
echo "<center>You are about to leave KrazyPicks! to an external link. <br>Do you want to continue?";
echo "<br>External Link: ".$url."</center>";
?>

 

Thanks!

 

 

Try it? The values in the array() shouldn't return anything because they weren't extracted. Should work now.

 

Ugh, man it's 3 am here, and I'm tired. Forgive me for my stupidity.

 

But keep in mind that this quick little fix up will always add http://, it does not interpret the protocol beforehand.

 

Although, I'm not quite sure why you would want to worry about ftp://, etc...?

 

This function should interpret it though, so just incorporate it where necessary. Unless it's for the active protocol only. *shrug* If none of this helped you, I'm sure someone else can. I gotta get some rest, and I'll help you more in the morning if your problem is still unresolved.

 

Good luck.

 

http://us.php.net/manual/en/function.gnupg-getprotocol.php

 

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.