We hope you enjoy your visit.

You're currently viewing our forum as a guest. This means you are limited to certain areas of the board and there are some features you can't use. If you join our community, you'll be able to access member-only sections, and use many member-only features such as customizing your profile, sending personal messages, and voting in polls. Registration is simple, fast, and completely free.


Join our community!


If you're already a member please log in to your account to access all of our features:

Username:   Password:
Add Reply
  • Pages:
  • 1
Modding PHP Files
Topic Started: May 2 2005, 01:28 AM (633 Views)
Das
Member Avatar
Smells of rich mahogany
[ *  *  *  *  *  *  * ]
Few question:
1) Is there a php script that would allow you to change a php file
2) Is there a php script that creates a new php page
3) Can you run an if statement through an if statment
EX
 
if ($something == $example) {
and if ($something2 == $example2)
Offline Profile Quote Post Goto Top
 
Seth
Member Avatar
I has a pony
[ *  *  *  *  *  *  *  *  * ]
http://php.net/fopen
http://php.net/fwrite

Quote:
 
if ($user == 1) {
if ($points > 100) {
echo ("Hi Das Ein, you have enough points for a cookie!");
} else {
echo ("Hi Das Ein, you don't have enough points for a cookie yet!");
}
} else {
echo ("You're not Das Ein! No cookies!");
}
Offline Profile Quote Post Goto Top
 
Das
Member Avatar
Smells of rich mahogany
[ *  *  *  *  *  *  * ]
Quote:
 
$points = 200

I get two ... wait no just one

Is there a way to replace text with a script? Like change <a href="stuff.com">stuff</a> to <a href="bob.com">bob</a> ?
Offline Profile Quote Post Goto Top
 
kingy
1 in 10 people understands binary, the other 1 doesn't
[ *  *  *  *  *  * ]
To check 2 variables, you could also do this
Code:
 

if ($user = 1 && $points > 200)
{
echo "Hello user 1, you have enough points for a cookie";
}
Offline Profile Quote Post Goto Top
 
Jory
Member Avatar
Member
[ *  *  *  *  *  * ]
Das Ein
May 2, 2005 07:16 AM
Is there a way to replace text with a script? Like change <a href="stuff.com">stuff</a> to <a href="bob.com">bob</a> ?

Sure there is.
http://www.php.net/manual/en/function.preg-replace.php
That shows you how to.
Offline Profile Quote Post Goto Top
 
Seth
Member Avatar
I has a pony
[ *  *  *  *  *  *  *  *  * ]
kingy
May 2, 2005 03:32 AM
To check 2 variables, you could also do this
Code:
 

if ($user = 1 && $points > 200)
{
echo "Hello user 1, you have enough points for a cookie";
}

But my script has more cases. It outputs different messages if User 1 is not logged in and if User 1 is logged in but doesn't have enough points ;)
Offline Profile Quote Post Goto Top
 
Seth
Member Avatar
I has a pony
[ *  *  *  *  *  *  *  *  * ]
Das Ein
May 2, 2005 01:16 AM
Quote:
 
$points = 200

I get two ... wait no just one

Is there a way to replace text with a script? Like change <a href="stuff.com">stuff</a> to <a href="bob.com">bob</a> ?

Although note that PHP is not dynamic. All work must be done before you send the page to the user.
Offline Profile Quote Post Goto Top
 
Das
Member Avatar
Smells of rich mahogany
[ *  *  *  *  *  *  * ]
Quote:
 

<?php
$filename = 'logincheck.php';
$name = $_POST["UserName"];
$pass = $_POST["Password"];
$content = "<? $name = $name $pass = $pass if ($name == $_POST["Name"];) { if ($pass == $_POST["Pass"];) { echo ("Hi" . $name . ", your logged in!"); } else { echo ("Your pass word was incorect."); } } else { echo ("You're not" . $name . "No login for you!"); } ?>"

if (is_writable($filename)) {

  if (!$handle = fopen($filename, 'a')) {
        echo "Unsucessfull opening ($filename)";
        exit;
  }


  if (fwrite($handle, $content) === FALSE) {
      echo "Unsucessfull writing ($filename)";
      exit;
  }
 
  echo "Success," . $name . "you have been registered";
 
  fclose($handle);

} else {
  echo "Unsucessfull";
}
?>

I am trying to transfer a user's registration over. I get a parse error on line 5. I think I am missing something blantantly odvious, but I got to go to school. can anyone see my problem?
Offline Profile Quote Post Goto Top
 
Seth
Member Avatar
I has a pony
[ *  *  *  *  *  *  *  *  * ]
I'm so confused. That's like the completely wrong way to go about what you're doing. For example:

"<? $name = $name $pass = $pass if ($name == $_POST["

There's the parse error since you have two double quotes. The string ends there.
Offline Profile Quote Post Goto Top
 
Das
Member Avatar
Smells of rich mahogany
[ *  *  *  *  *  *  * ]
Seth
May 2, 2005 07:24 AM
I'm so confused. That's like the completely wrong way to go about what you're doing. For example:

"<? $name = $name $pass = $pass if ($name == $_POST["

There's the parse error since you have two double quotes. The string ends there.

Then what would be the right way to write that infromation to the other file?


If the answer to this question is yes it would make things alot easier. Can you have a global variable? Like $cat = "dog" on all page in a domain, or in all pages in a folder?
Offline Profile Quote Post Goto Top
 
Seth
Member Avatar
I has a pony
[ *  *  *  *  *  *  *  *  * ]
No. :P

What info are you trying to write? Take a peek at IdioPoll, functions.php, writeconfig() for an example of writing to file.
Offline Profile Quote Post Goto Top
 
Das
Member Avatar
Smells of rich mahogany
[ *  *  *  *  *  *  * ]
Seth
May 2, 2005 11:08 AM
No. :PWith

With Sql?
Offline Profile Quote Post Goto Top
 
JCink
Member
[ *  *  *  *  * ]
2) Is there a php script that creates a new php page
Code:
 

$fnew = fopen("newpage.php", "w+");
flock($fnew, 1);


yes. thats it.
Offline Profile Quote Post Goto Top
 
Das
Member Avatar
Smells of rich mahogany
[ *  *  *  *  *  *  * ]
Do you know if SQL can create a global variable?
Offline Profile Quote Post Goto Top
 
Dennis
Member Avatar
Member
[ *  *  *  *  *  *  * ]
SQL is a database, not a language. So no, it cannot.

You can, however, pull a row out of the database, and assign it to a PHP variable, if that's what you mean.
Offline Profile Quote Post Goto Top
 
1 user reading this topic (1 Guest and 0 Anonymous)
Go to Next Page
« Previous Topic · Technology Chat · Next Topic »
Add Reply
  • Pages:
  • 1