PHP command creation help

leafypiggy

Manager of Pens and Office Supplies
Staff member
Messages
3,819
Reaction score
163
Points
63
I need some help with a script I am working on. It is to make a command for a RuneScape Private server.

The code output should look like this:

Code:
if (command.equalsIgnoreCase("userinput") && playerRights >= UserInput ) {
       addItem("userinput , userinput");
      sendMessage("userinput");
}

here is my PHP code:

Code:
<html>
<body>
<form action="cmdmaker.php" method="post">
<table width="100%" border="0" cellpadding="5">
<tr>
<td width="25%" valign="top"><p><b>Command name:</b></p></td>
<td width="75%"><input type="text" name="cmdname"></td>
</tr>
<tr>
<td width="25%" valign="top"><p><b>Rights:</b></p></td>
<td width="75%"><input type="text" name="rights" class="fields"/></td>
</tr>
<tr>
<td width="25%" valign="top"><p><b>Message:</b></p></td>
<td width="75%"><input type="text" name="msg"></td>
</tr>
<tr>
<td width="25%" valign="top"><p><b>Item ID:</b></p></td>
<td width="75%"><input type="text" name="itemid"></td>
</tr>
<tr>
<td width="25%" valign="top"><p><b>Item Amount:</b></p></td>
<td width="75%"><input type="text" name="amount"></td>
</tr>
<tr>
<td><p></p></td>
<td><input value="Create" name="create" type="submit" />  
</td>
</tr>
</table>
</form>
<?php
$cmdname = $_POST['cmdname'];
$rights = $_POST['rights'];
$msg = $_POST['msg'];
$itemid = $_POST['itemid'];
$itemamount = $_POST['amount'];

echo (" if (command.equalsIgnoreCase(" . ");
echo $cmdname;
echo (" . ") && playerRights >= ");
echo $rights;
echo  (" .  ") {") <br /> ");
echo   addItem(";
echo $itemid;
echo (",");
echo $itemamount;
echo (" . ") (";") <br /> ");
echo  (" sendMessage(" . ");
echo $msg;
echo (" . ")(";")<br /> ");
echo  ("}");
 
?>

</body>
</html>
 

woiwky

New Member
Messages
390
Reaction score
0
Points
0
Try using just one echo statement and the heredoc syntax:

PHP:
echo <<<COMMAND
if (command.equalsIgnoreCase("$cmdname") && playerRights >= $rights) {<br />
    addItem("$itemid", "$itemamount");<br />
    sendMessage("$msg");<br />
}
COMMAND;

Remember that a heredoc's closing line(COMMAND; in this case) can't contain anything else, including whitespace.
 

leafypiggy

Manager of Pens and Office Supplies
Staff member
Messages
3,819
Reaction score
163
Points
63
the whoy what? lol..

ill try it.

EDIT: can I put in a <pre> ??
 
Last edited:

woiwky

New Member
Messages
390
Reaction score
0
Points
0
Yeah, you can take out the <br />'s and just put a <pre> around the if block. I was just basically copying what you were using.
 

leafypiggy

Manager of Pens and Office Supplies
Staff member
Messages
3,819
Reaction score
163
Points
63
cool. thanks. i gots its nows. :D never heard of the heredoc syntax before.
 
Top