• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

PHP Znote characterprofile url

cryptomeepo

Member
Joined
Aug 11, 2021
Messages
61
Solutions
4
Reaction score
14
Guys I noticed that Znote has a url to character profiles characterprofile.php?name=charactername.

I would like to make a custom one myself.
It would be something like accountprofile.php?test=xxxxx

Does anyone knows where or how I can do it?
 
Solution
This HTML form:
HTML:
<!-- URL param submit form -->
<form action="/test.php" method="GET">
    <input type="text" name="test">
    <input type="submit" value="Send">
</form>

action="/test.php" = which file to submit to, defaults to itself if empty value
method="GET" = Send values as URL params

input elements that has the name attribute will be sent to URL, so name="test" will appear as url.com/file.php?test=value

PHP:
<?php require_once 'engine/init.php'; include 'layout/overall/header.php'; ?>

<h1>Blank</h1>
<p>This is a blank sample page.</p>

<?php
// Send a debug message to page explaining the contents of $_GET
data_dump($_GET, false, "URL Params");

// Initialize test param to a default...
Copy characterprofile.php and rename it.

You will need to edit the PHP in the file to edit the HTML that will be outputted. For example, if you want to show account data that characterprofile.php does not have, you will need to edit the SQL statements to fetch additional data, and handle it.

You will then need to render the HTML. (I have never used or seen Znote, so if it mixes with PHP and HTML, then it will be in the same file, otherwise you will have to locate where the HTML files are).

To get the "test" parameter value of the URL, just edit the $_GET super variable in the PHP file from "name" to "test" or whatever you want the key to be called.

This is all intermediate level stuff, if you have never code HTML or PHP before. I would recommend learning it first before you mess up your server web files.
 
Copy characterprofile.php and rename it.

You will need to edit the PHP in the file to edit the HTML that will be outputted. For example, if you want to show account data that characterprofile.php does not have, you will need to edit the SQL statements to fetch additional data, and handle it.

You will then need to render the HTML. (I have never used or seen Znote, so if it mixes with PHP and HTML, then it will be in the same file, otherwise you will have to locate where the HTML files are).
Until this part I'm fine.

Getting the global is where I'm struggling.
if (isset($_GET['name']) === true && empty($_GET['name']) === false) {
$name = getValue($_GET['name']);
$user_id = user_character_exist($name);
This is what I found at Znote's characterprofile.php

I'll keep trying and let you guys know if I got it.

Thank you @Boy67
 
URL param are represented as an associative array in the $_GET variable. So $_GET['name'] returns the value stored in ?name=value in the URL.
The getValue($value) function tries to validate and transform the value to be safe to handle further, since its grabbed from URL and humans can change the value, its a security risk, so the getValue will do stuff like remove illegal symbols and sanitize the value for SQL queries.

When making a new page, I would start by copying blank.php: (to etc accountprofile.php)
PHP:
<?php require_once 'engine/init.php'; include 'layout/overall/header.php'; ?>

<h1>Blank</h1>
<p>This is a blank sample page.</p>

<?php include 'layout/overall/footer.php'; ?>

And I would edit it and implement the features I want, lets say I want to check all params sent to this page, I would data dump it and add a test paragraph that outputs it:

PHP:
<?php require_once 'engine/init.php'; include 'layout/overall/header.php'; ?>

<h1>Blank</h1>
<p>This is a blank sample page.</p>

<?php
// Send a debug message to page explaining the contents of $_GET
data_dump($_GET, false, "URL Params");

// Initialize test param to a default value
$testparam = "(not set)";

// Override default value if URL param has a value, etc: website.com/accountprofile.php?test=HelloWorld
if (isset($_GET['test'])) {
    $testparam = getValue($_GET['test']);
}
?>

<p>URL param [test] has value: <?php echo $testparam; ?></p>

<?php include 'layout/overall/footer.php'; ?>

Unless you want to copy characterprofile.php and keep its functionality, I don't advice to copy it, it contains so much code that is likely irrelevant to your custom page that it is uneccesary confusing. And this way it becomes easier for us to help you one step at a time.
 
Thank you @Znote
Start from your blank.php is exactly what I'm doing.

I wanted the dynamic urls page and the search form to be on the same page so here is what I've done:

PHP:
<?php require_once 'engine/init.php'; include 'layout/overall/header.php'; ?>

<h1>Blank</h1>
<p>This is a blank sample page.</p>

<form action="testurl.php?=">
<input type="text" name="typedtext" placeholder="Type here" id="txt">
<input type="submit" value="Search">
</form>

<?php
if (isset($_GET['test'])) {
  
$testpage = getValue($_GET['test']);

PAGE CONTENT

}
else echo 'Enter a valid text.';
}
?>
<?php include 'layout/overall/footer.php'; ?>

So now when user fill the search input text and click submit, url changes and he go to where he is supposed to. Else an error shows up.
And if he get there by any testurl.php?=xxxx it's also working and he can search a different xxxx while in this page.

Is it ok or I just found a really newbie alternative? 😂
 
Last edited:
This HTML form:
HTML:
<!-- URL param submit form -->
<form action="/test.php" method="GET">
    <input type="text" name="test">
    <input type="submit" value="Send">
</form>

action="/test.php" = which file to submit to, defaults to itself if empty value
method="GET" = Send values as URL params

input elements that has the name attribute will be sent to URL, so name="test" will appear as url.com/file.php?test=value

PHP:
<?php require_once 'engine/init.php'; include 'layout/overall/header.php'; ?>

<h1>Blank</h1>
<p>This is a blank sample page.</p>

<?php
// Send a debug message to page explaining the contents of $_GET
data_dump($_GET, false, "URL Params");

// Initialize test param to a default value
$testparam = "(not set)";

// Override default value if URL param has a value, etc: website.com/accountprofile.php?test=HelloWorld
if (isset($_GET['test'])) {
    $testparam = getValue($_GET['test']);
}
?>

<p>URL param [test] has value: <?php echo $testparam; ?></p>

<!-- URL param submit form -->
<form action="/test.php" method="GET">
    <input type="text" name="test" value="<?php echo $testparam; ?>">
    <input type="submit" value="Send">
</form>

<?php include 'layout/overall/footer.php'; ?>

1630418536445.png
 
Solution
Back
Top