This is a discussion on help modding a script within the alt.comp.lang.php forums, part of the PHP Programming Forums category; a friend of mine wanted me to have a go at this for him i have a limited knowledge of ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
a friend of mine wanted me to have a go at this for him
i have a limited knowledge of php, mainly because its similar to c/c++ which i understand quite a bit more and also vb and vb.net so i figured i could mode the script the way he wanted i have this code.... in a file called secure.php <?php // Secure multiple user Log-In script by Dave Lauderdale - Originally published at: www.digi-dl.com $filename = "user.log"; $log = fopen($filename, "r"); $contents = fread($log, filesize($filename)); fclose($log); if ($contents == "Phil" || $contents == "Chris" || $contents == "Rick") { $filename = "user.log"; $log = fopen($filename, "w+"); fputs($log,""); fclose($log); include ("test.php"); } else { echo "<center><Br><font color=red face=arial size=3 >Error</font>...<font face=arial size=3 >You will have to log on via the log on form to view this page.<br><br><a href='login.html' style='color:black'>Click here</a> to try again."; } ?> forget about the logging in lets just say thats handled now i include test.php this checks which username is in $contents and then includes a txt file on the page for them individually, this is the part i have written myself, it just an idea and am not sure if it will work.... <?php if($contents = "Phil") { include ("philspage.txt"); } elseif($contents = "Chris") { include ("chrispage.txt"); } elseif($contents = "Rick") { include ("rickpage.txt"); } else { echo "login request cannot be completed, please cntact phil"; ?> anyway back to the secure.php file when i attempt to login with a username and password that is correct i get the following error in secure.php... Parse error: parse error, unexpected $ in /home/www/juttuffi/login/test.php on line 10 im no php wizz but there are NO $ characters on line 10 that shouldnt be there.... so could someone please tell me if they would how i can go about correcting this and making the script work i know its not great using sql and probably a bit rusty bit its only meant for a small amount over users and as long as i can get this to work it would be great so the help will be much appreciated Thanks Christo |
|
|||
|
Christo wrote:
> when i attempt to login with a username and password that is correct > i get the following error in secure.php... > > Parse error: parse error, unexpected $ in > /home/www/juttuffi/login/test.php on line 10 > > im no php wizz but there are NO $ characters on line 10 that shouldnt > be there.... so could someone please tell me if they would how i can > go about correcting this and making the script work > You didn't close the if..else block properly: <?php if($contents = "Phil") { include ("philspage.txt"); } elseif($contents = "Chris") { include ("chrispage.txt"); } elseif($contents = "Rick") { include ("rickpage.txt"); } else { echo "login request cannot be completed, please cntact phil"; } <-- Missing in your code ?> JW |
|
|||
|
I noticed that Message-ID: <3anl88F69a4lvU1@individual.net> from Christo
contained the following: > >Parse error: parse error, unexpected $ in /home/www/juttuffi/login/test.php >on line 10 > >im no php wizz but there are NO $ characters on line 10 that shouldnt be >there.... so could someone please tell me if they would how i can go about >correcting this and making the script work Dunno about the parse error, but the comparison operator is == not = -- Geoff Berrow (put thecat out to email) It's only Usenet, no one dies. My opinions, not the committee's, mine. Simple RFDs http://www.ckdog.co.uk/rfdmaker/ |
|
|||
|
"Geoff Berrow" <blthecat@ckdog.co.uk> wrote in message news:vd9d41pcehl65ljt3hoihk5lh6i41jgm15@4ax.com... >I noticed that Message-ID: <3anl88F69a4lvU1@individual.net> from Christo > contained the following: > >> >>Parse error: parse error, unexpected $ in >>/home/www/juttuffi/login/test.php >>on line 10 >> >>im no php wizz but there are NO $ characters on line 10 that shouldnt be >>there.... so could someone please tell me if they would how i can go about >>correcting this and making the script work > > Dunno about the parse error, but the comparison operator is == not = > > -- > Geoff Berrow (put thecat out to email) > It's only Usenet, no one dies. > My opinions, not the committee's, mine. > Simple RFDs http://www.ckdog.co.uk/rfdmaker/ ahh yeah lol i missed that one, thanks for pointing it out |
|
|||
|
"Janwillem Borleffs" <jw@jwscripts.com> wrote in message news:4246a4de$0$32377$dbd49001@news.euronet.nl... > Christo wrote: >> when i attempt to login with a username and password that is correct >> i get the following error in secure.php... >> >> Parse error: parse error, unexpected $ in >> /home/www/juttuffi/login/test.php on line 10 >> >> im no php wizz but there are NO $ characters on line 10 that shouldnt >> be there.... so could someone please tell me if they would how i can >> go about correcting this and making the script work >> > > You didn't close the if..else block properly: > > <?php > if($contents = "Phil") { > include ("philspage.txt"); > } elseif($contents = "Chris") { > include ("chrispage.txt"); > } elseif($contents = "Rick") { > include ("rickpage.txt"); > } else { > echo "login request cannot be completed, please cntact phil"; > } <-- Missing in your code > ?> > > > JW > > > thanks :) |
|
|||
|
"Christo" <chris@juststuffnospam.co.uk> wrote in message news:3anl88F69a4lvU1@individual.net... >a friend of mine wanted me to have a go at this for him > > i have a limited knowledge of php, mainly because its similar to c/c++ > which i understand quite a bit more and also vb and vb.net so i figured i > could mode the script the way he wanted > > i have this code.... in a file called secure.php > > <?php > > // Secure multiple user Log-In script by Dave Lauderdale - Originally > published at: www.digi-dl.com > > $filename = "user.log"; > $log = fopen($filename, "r"); > $contents = fread($log, filesize($filename)); > fclose($log); > > if ($contents == "Phil" || $contents == "Chris" || $contents == "Rick") { > > $filename = "user.log"; > $log = fopen($filename, "w+"); > fputs($log,""); > fclose($log); > include ("test.php"); > > } else { > echo "<center><Br><font color=red face=arial size=3 >Error</font>...<font > face=arial size=3 >You will have to log on via the log on form to view > this page.<br><br><a href='login.html' style='color:black'>Click here</a> > to try again."; > } > ?> > > forget about the logging in lets just say thats handled > > now i include test.php > > this checks which username is in $contents and then includes a txt file on > the page for them individually, this is the part i have written myself, it > just an idea and am not sure if it will work.... > > > <?php > if($contents = "Phil") { > include ("philspage.txt"); > } elseif($contents = "Chris") { > include ("chrispage.txt"); > } elseif($contents = "Rick") { > include ("rickpage.txt"); > } else { > echo "login request cannot be completed, please cntact phil"; > ?> > > anyway back to the secure.php file > > when i attempt to login with a username and password that is correct i get > the following error in secure.php... > > Parse error: parse error, unexpected $ in > /home/www/juttuffi/login/test.php on line 10 > > im no php wizz but there are NO $ characters on line 10 that shouldnt be > there.... so could someone please tell me if they would how i can go about > correcting this and making the script work > > i know its not great using sql and probably a bit rusty bit its only meant > for a small amount over users and as long as i can get this to work it > would be great > > so the help will be much appreciated > > Thanks > > Christo > after including the missing end of statement block "}" i am now seeing the code on the screen and it is not being implimented as php? using the include ("test.php") will actually include the php code an execute it wont it? |
|
|||
|
"Christo" <chris@juststuffnospam.co.uk> wrote in message news:3anl88F69a4lvU1@individual.net... >a friend of mine wanted me to have a go at this for him > > i have a limited knowledge of php, mainly because its similar to c/c++ > which i understand quite a bit more and also vb and vb.net so i figured i > could mode the script the way he wanted > > i have this code.... in a file called secure.php > > <?php > > // Secure multiple user Log-In script by Dave Lauderdale - Originally > published at: www.digi-dl.com > > $filename = "user.log"; > $log = fopen($filename, "r"); > $contents = fread($log, filesize($filename)); > fclose($log); > > if ($contents == "Phil" || $contents == "Chris" || $contents == "Rick") { > > $filename = "user.log"; > $log = fopen($filename, "w+"); > fputs($log,""); > fclose($log); > include ("test.php"); > > } else { > echo "<center><Br><font color=red face=arial size=3 >Error</font>...<font > face=arial size=3 >You will have to log on via the log on form to view > this page.<br><br><a href='login.html' style='color:black'>Click here</a> > to try again."; > } > ?> > > forget about the logging in lets just say thats handled > > now i include test.php > > this checks which username is in $contents and then includes a txt file on > the page for them individually, this is the part i have written myself, it > just an idea and am not sure if it will work.... > > > <?php > if($contents = "Phil") { > include ("philspage.txt"); > } elseif($contents = "Chris") { > include ("chrispage.txt"); > } elseif($contents = "Rick") { > include ("rickpage.txt"); > } else { > echo "login request cannot be completed, please cntact phil"; > ?> > > anyway back to the secure.php file > > when i attempt to login with a username and password that is correct i get > the following error in secure.php... > > Parse error: parse error, unexpected $ in > /home/www/juttuffi/login/test.php on line 10 > > im no php wizz but there are NO $ characters on line 10 that shouldnt be > there.... so could someone please tell me if they would how i can go about > correcting this and making the script work > > i know its not great using sql and probably a bit rusty bit its only meant > for a small amount over users and as long as i can get this to work it > would be great > > so the help will be much appreciated > > Thanks > > Christo > cheers got it working i forgot to do something i had echo" before |
|
|||
|
"Christo" <chris@juststuffnospam.co.uk> kirjoitti
viestissä:3annanF6bd1j9U1@individual.net... > > "Christo" <chris@juststuffnospam.co.uk> wrote in message > news:3anl88F69a4lvU1@individual.net... >>a friend of mine wanted me to have a go at this for him >> >> i have a limited knowledge of php, mainly because its similar to c/c++ >> which i understand quite a bit more and also vb and vb.net so i figured i >> could mode the script the way he wanted >> >> i have this code.... in a file called secure.php >> >> <?php >> >> // Secure multiple user Log-In script by Dave Lauderdale - Originally >> published at: www.digi-dl.com >> >> $filename = "user.log"; >> $log = fopen($filename, "r"); >> $contents = fread($log, filesize($filename)); >> fclose($log); >> >> if ($contents == "Phil" || $contents == "Chris" || $contents == "Rick") >> { >> >> $filename = "user.log"; >> $log = fopen($filename, "w+"); >> fputs($log,""); >> fclose($log); >> include ("test.php"); >> >> } else { >> echo "<center><Br><font color=red face=arial size=3 >Error</font>...<font >> face=arial size=3 >You will have to log on via the log on form to view >> this page.<br><br><a href='login.html' style='color:black'>Click here</a> >> to try again."; >> } >> ?> >> >> forget about the logging in lets just say thats handled >> >> now i include test.php >> >> this checks which username is in $contents and then includes a txt file >> on the page for them individually, this is the part i have written >> myself, it just an idea and am not sure if it will work.... >> >> >> <?php >> if($contents = "Phil") { >> include ("philspage.txt"); >> } elseif($contents = "Chris") { >> include ("chrispage.txt"); >> } elseif($contents = "Rick") { >> include ("rickpage.txt"); >> } else { >> echo "login request cannot be completed, please cntact phil"; >> ?> >> >> anyway back to the secure.php file >> >> when i attempt to login with a username and password that is correct i >> get the following error in secure.php... >> >> Parse error: parse error, unexpected $ in >> /home/www/juttuffi/login/test.php on line 10 >> >> im no php wizz but there are NO $ characters on line 10 that shouldnt be >> there.... so could someone please tell me if they would how i can go >> about correcting this and making the script work >> >> i know its not great using sql and probably a bit rusty bit its only >> meant for a small amount over users and as long as i can get this to work >> it would be great >> >> so the help will be much appreciated >> >> Thanks >> >> Christo >> > > after including the missing end of statement block "}" i am now seeing the > code on the screen and it is not being implimented as php? using the > > include ("test.php") > > will actually include the php code an execute it wont it? Unless 'test.php' begins with '<?php' and ends with '?>', no, it doesn't. What you described indicates that it doesn't. It's treated as plain txt if there are not php code tags in it. |
![]() |
| Thread Tools | |
| Display Modes | |
|
|