Jump to content

Newbie in need of help


Ishamael

Recommended Posts

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
Link to comment
Share on other sites

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

[code]

<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>

[/code]

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



[code]

<?
include 'style.css';

the rest of your php code here

?>
[/code]

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]
Link to comment
Share on other sites

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
Link to comment
Share on other sites

yes you can do that here is an example form
[code]
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>
[/code]

and here is the code you use to create the page
[code]
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);


[/code]
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
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.