Jump to content


Php help


6 replies to this topic

#1 rideth3

    Young Padawan

  • Members
  • Pip
  • 9 posts

Posted 26 June 2006 - 11:36 PM

Im trying to make a profile system, and I use mkdir(), fopen(), and then fwrite(). All is good so far, except I need a way to have php in it, and I don't know how. Can you have the <? ?> tags inside a php script? Is there any other ways to do this? I know how to make the whole html part (it imports the stylesheet). Thanks! :)

#2 coolaid

    P2L Jedi Master

  • Members
  • PipPipPipPip
  • 1,435 posts
  • Gender:Male
  • Interests:i wonder..

Posted 27 June 2006 - 12:01 AM

i'm confused on the question, so i'm guessin most others will to.

Quote

except I need a way to have php in it

so when you say 'it' you mean.... ???

#3 rideth3

    Young Padawan

  • Members
  • Pip
  • 9 posts

Posted 27 June 2006 - 01:42 AM

Heres the code

$info=$_POST['info'];
$cdir=$_POST['cdir'];
$name=$_POST['name'];
$stringData = "<html><head><title>$name</title><style>@import url(/whatever/style.css);</style></head><body><center><br><Br><Br><b>Hello $name</b><Br><Br>$info</center></body></html>";
$dir = "/home/whatever/public_html/whatever/$cdir";
mkdir("/home/whatever/public_html/whatever/$cdir", 0755);
$FileName = "/home/whatever/public_html/whatever/$cdir/index.php";
$FileHandle = fopen($FileName, 'w') or die("can't open file");
echo "<br><a href='/whateverl/$cdir'>Click here to go to it'</a>";
$fh = fopen($FileName, 'w') or die("can't open file");
fwrite($fh, $stringData);
fclose($fh);

I that creates the directory, file, etc, but I need php code to go here:
$stringData = "<html><head><title>$name</title><style>@import url(/daniel/style.css);</style></head><body><center><br><Br><Br><b>Hello $name</b><Br><Br>$info</center></body></html>";

I get a parse error if I have it like this
$stringData = "<title><? echo "$name"; ?></title>";

Hopefully you know what I mean now :)

#4 Mr. Matt

    Moderator

  • P2L Staff
  • PipPipPipPip
  • 1,945 posts
  • Gender:Not Telling

Posted 27 June 2006 - 01:51 AM

$stringData = '<title><? echo "$name"; ?></title>';

#5 Matthew.

    Official Spammer .Matt

  • Members
  • PipPipPipPip
  • 2,749 posts
  • Gender:Male
  • Location:England

Posted 27 June 2006 - 07:05 AM

umm....

$stringData = '<title>'. $name .'</title>';

I'm confused as coolaid is....

#6 coolaid

    P2L Jedi Master

  • Members
  • PipPipPipPip
  • 1,435 posts
  • Gender:Male
  • Interests:i wonder..

Posted 27 June 2006 - 12:52 PM

oh i get it....

$stringData = "<title><? echo \"$name\"; ?></title>";

yes you can have open/close php tags within strings. and the reason you got the parse error is because you didn't escape the doublequotes.

#7 rideth3

    Young Padawan

  • Members
  • Pip
  • 9 posts

Posted 27 June 2006 - 02:45 PM

Ohhh ok I see. Thanks!





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users