Jump to content


Photo

Newbie in need of help


  • Please log in to reply
7 replies to this topic

#1 Ishamael

Ishamael
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 12 April 2006 - 03:20 AM

Ok simply here goes. Im new to php, as in started 5 hours ago(and only learnt html on monday css tuesday). so if i come across as bad sorry. My problem is i want to use css type of things in php. for instance ive made this website which when you typed things in, select from drop down boxes etc then submit it makes you a makeshift website.
so far it can make the background/font color(drop down), upload a image(file selector), place text(textarea), align the text area's and title's(drop down), and make links. however one thing i cant do is figure how to change link colors etc. if it was css id just use good old a:link{color:red;} and visited/hover.
But php doesnt like this the way ive been doing it, and i dont know if php has a way to do it.
All i want is to insert the color from the drop box in the creation page $link1color(for example) into the css inda thing a:link{color:$link1color;}. which of course wont work. anyone want to teach me? been searching for a hour, either im plain blind or just unlucky at finding things

Thanks and sorry for the spelling

#2 shortj75

shortj75
  • Members
  • PipPipPip
  • Advanced Member
  • 118 posts
  • LocationPort Huron,mi

Posted 12 April 2006 - 06:22 AM

your best bet would probably make a seperate css stylesheet like so


<style><!--
           scrollbar-3d-light-color:lightblue;
           scrollbar-arrow-color:lightblue;
           scrollbar-base-color:lightblue;
           scrollbar-dark-shadow-color:navy;
           scrollbar-face-color:blue;
           scrollbar-highlight-color:black;
           scrollbar-shadow-color:black;
}
a:link {  text-decoration: none; color:blue}
a:active { text-decoration: none; color:green}
a:visited { text-decoration: none; color:navy}
a:hover { font: italic; color:red;}

--></style>


and name it style.css then use the php include function to add it to your php page




<?
include 'style.css';

the rest of your php code here

?>

that is basically it
to see that it works [a href=\"http://tfws.dynu.com/software/download.php\" target=\"_blank\"]T.F.W.S Scripts[/a]
The Short One

hopfully this helps if it doesn't sorry
i won't write the code for you!!! you don't learn that way

#3 Ishamael

Ishamael
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 12 April 2006 - 06:56 AM

thanks.
so nothing even simalar to
<style type="text/css">
a:link{color:$linkcolor>};
</style>

exists?
and is there a way to print the outputed html from a php into a txt document.
I basicaly have a interface page where you have area's for typing in names and selecting alignments etc. once you submit it to my php it gets the posted values and they are used to make the website
from the title, text area's, a image, wether to or not to display links, and the destinations and visable link of each one.
I know its nothing flashy but its all i could think of making.
So yeh, just want to be able to write it to a file which they name in the interface then is made with
$filename = $siten_string . ".html";
so makes a empty html doco, just no idea if its even posible to put the html into it.
well anyway i stoped blue backgrounds so the link thing isnt a huge hassle

#4 ToonMariner

ToonMariner
  • Members
  • PipPipPip
  • Advanced Member
  • 3,342 posts
  • LocationNewcastle upon Tyne, UK

Posted 12 April 2006 - 07:04 AM

you can do this:
<style type="text/css">
a:link{color:<?php echo $linkcolor; ?>};
</style>

But I would look to creating a whole style sheet on teh fly and caching it.
follow me on twitter @PHPsycho

#5 shortj75

shortj75
  • Members
  • PipPipPip
  • Advanced Member
  • 118 posts
  • LocationPort Huron,mi

Posted 12 April 2006 - 07:14 AM

yes you can do that here is an example form
createpageform.php


<form name="create" method="post" action="createpage.php">
Title: <input type="text" name="title"> please do not add extentions like .html or .php or any other<br>
<textarea name="body"  rows="20" cols="100">
</textarea><BR> 
<input type="submit" value="Save">
</form>
</body>

and here is the code you use to create the page
ceatepage.php


$filename = "$_POST['title'].html";
$body = $_POST['body'];



   if (!$handle = fopen($filename, 'a')) {
         echo "Cannot open file ($filename)";
         exit;
   }

   if (fwrite($handle, $body) === FALSE) {
       echo "Cannot write to file ($filename)";
       exit;
   }
   
  
   
   fclose($handle);



The Short One

hopfully this helps if it doesn't sorry
i won't write the code for you!!! you don't learn that way

#6 Ishamael

Ishamael
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 12 April 2006 - 08:18 AM

thanks ToonMariner works great
shortj75, you have me all confused :( i get the first part.. well except for the need for name="create". but the second bit is a bit out there for me. would that write the html from the original page? ie the text area.
the page i have it kinda messy and complex and propley to long to put onto here so i wont, but the original page is prety much a place to type some words and select options for the formatting the php does.

$filename = "$_POST['title'].html"; #create a filename from what they typed and +.html, this i already had
$body = $_POST['body']; #create a thingy called body with the text from the text area


if (!$handle = fopen($filename, 'a')) { #not to sure, looks like open the file for append writing
echo "Cannot open file ($filename)"; #if not then display the msg with the filename
exit; #never seen that.. dont laugh. exit the php?
}

if (fwrite($handle, $body) === FALSE) { #if you cant write display and exit? and whats with ===
echo "Cannot write to file ($filename)";
exit;
}



fclose($handle); #close the file


sorry for not knowing


#7 Ishamael

Ishamael
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 13 April 2006 - 12:18 AM

Well still havnt figured this thing out. i dont now if im ment to do this but heres the links for it all
[a href=\"http://pastebin.com/656786\" target=\"_blank\"]http://pastebin.com/656786[/a]
[a href=\"http://pastebin.com/656791\" target=\"_blank\"]http://pastebin.com/656791[/a]

the html(index.html) one is the interface the php(process.php) is well the php. the top text box is ment to provide space for them to type the file name into(minus the .html bit) they select this's and thats and it makes a very basic website, the data i want in the html document that is created(well isnt with that code there, removed it) is the end html. so they essentially could take that file and they have a very basic page already done(of course i dont think the image would work).

well anyone who can help me do this(if its posible) is welcome to try, just remember its my second day so im no expert

#8 shortj75

shortj75
  • Members
  • PipPipPip
  • Advanced Member
  • 118 posts
  • LocationPort Huron,mi

Posted 13 April 2006 - 05:28 PM

the code i gave you will create a new page on you server
The Short One

hopfully this helps if it doesn't sorry
i won't write the code for you!!! you don't learn that way




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users