11 Replies - 1266 Views - Last Post: 30 May 2014 - 10:12 AM Rate Topic: -----

#1 chaos1973   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 80
  • Joined: 30-January 12

How to change the color of a link?

Posted 29 May 2014 - 03:37 PM

so im wondering how i would change the color of the link that is produced by this line of code
$filename = "files/".session_id().".doc";
to display that when the info is stored in a file to be something other then the blue that is unreadable almost on my green background?thanks
Is This A Good Question/Topic? 0
  • +

Replies To: How to change the color of a link?

#2 Atli   User is offline

  • Enhance Your Calm
  • member icon

Reputation: 4241
  • View blog
  • Posts: 7,216
  • Joined: 08-June 10

Re: How to change the color of a link?

Posted 29 May 2014 - 03:41 PM

That code doesn't produce a link. It just produces a file path. There is no way for us to know, from this, how you are actually creating your link.

If you want to change the color of a link in HTML, you set the color style.

P.S.
I've updated the thread title. Please try to be more descriptive and on topic when naming your threads.

This post has been edited by Atli: 29 May 2014 - 03:43 PM

Was This Post Helpful? 1
  • +
  • -

#3 chaos1973   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 80
  • Joined: 30-January 12

Re: How to change the color of a link?

Posted 29 May 2014 - 03:48 PM

here is the code i am referring to and line 48 is one im trying to figure out how to change the color of the link, path that is outputed in blue?
<?php session_start(); ?>
<DOCTYPE html>
<html>
	<head>
		<title> Source Harvester </title>
		<link rel="stylesheet" href="harvest.css" media="all" type="text/css" />
		<meta charset="UTF-8">
	</head>
	<body>
		
		<?php
			$url = "";
			if (isset($_POST['url'])) {
				$url = htmlspecialchars($_POST['url']);
			} else {
				$url = "";
			}
		?>
		<div id="wrapper">
			<div id="form">
				<form action="harvest.php" method="post">
					<p>Please enter full URL of the page to harvest sources from (including http://):</p>
					<p><input type="text" name="url" size="65" value="<?php echo $url;  ?>"/></p>
					<p>or enter text directly into textarea below:</p>
					<p><textarea name="text" cols="50" rows="15"></textarea></p>
					<input type="submit" value="Harvest" style="margin-left:60%;"/>
				</form>
			</div>
		<?php
			if (isset($_POST['url']) && !empty($_POST['url'])) {
			  $text = file_get_contents($_POST['url']);
			}
			elseif (isset($_POST['text']) && !empty($_POST['text'])) {
			  $text = $_POST['text'];
			}

			if (!empty($text)) {
				$res = preg_match_all('/(?<=src=").*?(?=")/i', $text, $matches);
				if ($res) {
					echo "<div id='results'>";
						echo "<table>";
						$i = 1;
							foreach(array_unique($matches[0]) as $links) {
								echo "<tr><td>$i</td><td> $links </td></tr>\n";
								++$i;
							}
							$data = "Sources For ".$_POST['url']."\n\n";
							$filename = "files/".session_id().".txt";
							foreach(array_unique($matches[0]) as $links) {
								$data .= ($links."\n");
							}
							if(file_put_contents($filename, $data, FILE_APPEND)>0) {
								echo "Your data has been saved in the file <a href=\"FileDownloader.php?filename=$filename\">".htmlentities($filename)."</a>.\n";
							} else {
								echo "Unable to save your data.";
							}
						echo "</table>";
					echo "</div>";
				}
			} else {
				echo "No sources found.";
			}
		?>
		
		
	</body>
</html>

This post has been edited by chaos1973: 29 May 2014 - 03:51 PM

Was This Post Helpful? 0
  • +
  • -

#4 Atli   User is offline

  • Enhance Your Calm
  • member icon

Reputation: 4241
  • View blog
  • Posts: 7,216
  • Joined: 08-June 10

Re: How to change the color of a link?

Posted 29 May 2014 - 04:02 PM

Like I say, line 48 in that code does not create a link; it just defines the path used in the link. The link is actually created on line 53. The <a> (anchor) tag is the HTML tag used to create standard links. They are always blue by default.

You can change that, as I also mentioned, using the CSS color style. For example:
<!DOCTYPE HTML>
<html>
	<head>
		<title>Link colour example</title>
		<meta charset="UTF-8">
		<style>
		a.special-link {
			color: #FF0000;
		}
		</style>
	</head>
	<body>
		<p>
			<h1>Links!</h1>
			
			<!-- These will be blue as normal -->
			<a href="#page1">Link to page 1</a>
			<a href="#page2">Link to page 2</a>
			
			<!-- 
				But these will be read, thanks to the style
				defined in the header
			-->
			<a href="#page3" class="special-link">Link to page 3</a>
			<a href="#page4" class="special-link">Link to page 4</a>
		</p>
	</body>
</html>



If that doesn't make sense, or you can't see how you would apply the same concept to your code, you need to study the basics of CSS a bit. You won't get very far in web-development without understanding this stuff.
Was This Post Helpful? 1
  • +
  • -

#5 chaos1973   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 80
  • Joined: 30-January 12

Re: How to change the color of a link?

Posted 29 May 2014 - 04:36 PM

solved it , with
<body link="white">
so thanks
Was This Post Helpful? 0
  • +
  • -

#6 ArtificialSoldier   User is offline

  • D.I.C Lover
  • member icon

Reputation: 2760
  • View blog
  • Posts: 8,062
  • Joined: 15-January 14

Re: How to change the color of a link?

Posted 29 May 2014 - 04:51 PM

The link attribute in the body element is not supported in HTML5. If you want to do it the right way, use CSS.

https://www.google.c...=UTF-8&oe=UTF-8
Was This Post Helpful? 1
  • +
  • -

#7 chaos1973   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 80
  • Joined: 30-January 12

Re: How to change the color of a link?

Posted 29 May 2014 - 06:04 PM

View PostArtificialSoldier, on 29 May 2014 - 04:51 PM, said:

The link attribute in the body element is not supported in HTML5. If you want to do it the right way, use CSS.

https://www.google.c...=UTF-8&oe=UTF-8

well looks like it worked to me.............

Attached image(s)

  • Attached Image

Was This Post Helpful? 0
  • +
  • -

#8 Atli   User is offline

  • Enhance Your Calm
  • member icon

Reputation: 4241
  • View blog
  • Posts: 7,216
  • Joined: 08-June 10

Re: How to change the color of a link?

Posted 29 May 2014 - 07:01 PM

That's not the point. Browsers will likely (but not reliably!) still support it for backwards compatibility, but it has been deprecated for almost 15 years now, and the current HTML5 spec makes it officially obsolete.

So yea, it may "work" for now, but you should definitely not be using it. All styling should be done through CSS, like I demonstrated in my example.

There is a right way to do things. This is not it.
Was This Post Helpful? 1
  • +
  • -

#9 chaos1973   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 80
  • Joined: 30-January 12

Re: How to change the color of a link?

Posted 29 May 2014 - 09:51 PM

k understood but im a network major not a programming major and just trying to figure this out the rt way and learn but dont understand how to do in css , ne one explain more please?
Was This Post Helpful? 0
  • +
  • -

#10 Atli   User is offline

  • Enhance Your Calm
  • member icon

Reputation: 4241
  • View blog
  • Posts: 7,216
  • Joined: 08-June 10

Re: How to change the color of a link?

Posted 30 May 2014 - 12:25 AM

I gave you a complete example of how to do this in CSS. What is it exactly you are having trouble understanding about it?

If you are going to be doing web development, even just as a hobby, you should take a few hours and study up on CSS. The basics are not complicated, and you can't really do any web development without it. There are plenty of decent tutorials out there that will give you a good working knowledge in a short amount of time. (I'd try this one.)
Was This Post Helpful? 1
  • +
  • -

#11 chaos1973   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 80
  • Joined: 30-January 12

Re: How to change the color of a link?

Posted 30 May 2014 - 10:00 AM

Understood, and got it i think with this:
a:link {color:white;} /* unvisited link */
a:visited {color:#00FF00;}  /* visited link */
a:hover {color:#FF00FF;}  /* mouse over link */
a:active {color:#0000FF;}  /* selected link */


is this right?

my next problem is this
if (isset($_POST['url']) && !empty($_POST['url'])) 

	{
	 echo "<th><br>pic sources Found:</th>";
	 $text = @file_get_contents($_POST['url']);// I know putting the @ here is a bad pratice to supress the error I get here when it is gone? which is Warning: file_get_contents(lanecc.edu/contact): failed to open stream: No such file or directory in C:\wamp\www\cs295p\lab8\emailharvester.php on line 58...
	}



when i dont use http as a strt in the url and try to harvest jpg or pics from it i get this error, with http works fine.ne ideas?
Was This Post Helpful? 0
  • +
  • -

#12 ArtificialSoldier   User is offline

  • D.I.C Lover
  • member icon

Reputation: 2760
  • View blog
  • Posts: 8,062
  • Joined: 15-January 14

Re: How to change the color of a link?

Posted 30 May 2014 - 10:12 AM

When you don't use something like http://, then you are essentially telling the server that it is a local file. When you use lanecc.edu/contact you are telling the server to look inside the lanecc.edu folder inside the same folder as the PHP code, and then a file inside that folder called contact.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1