Jump to content

[Guide] Basics in PHP (Beginners)


WizZy™

Recommended Posts

Hey guys!I`m bored and have nothing to do,so many people have problems with they'r site coding (php) and i wanted to let u know the basics..

First of all , most of it wants a SQL connection.You can create it using this :

<?php
$user = "root"; //Your MySQL user
$pass = "pass"; //Your MySQL Password
$db = "hack"; //Your MySQL database
$host = "localhost"; // Your MySQL address (its as default)
$connection = mysql_connect($host, $user, $pass) or die("Error with MySQL connecting"); // AIO connect
$db = mysql_select_db($db,$connection)or die("Error with MySQL connecting2"); // database connect
$chars="set character set latin1"; //set chars
mysql_query($chars); // mysql query for chars
?>

Its a simple SQL connector.So we are proceeding.. How to read SQL file thru web? Its simple one ,just configurate it by your needs.

But you need a config file like conf.php and including it in each page ,so this file can connect to mysql.

just type

<?php include "FILE.php"; ?> 

So here just change FILE to conf (like i said) and it will include it in each page you write that.

<?php
include "conf.php";

$query="SELECT * FROM reports ORDER by id DESC LIMIT 1"; // Selection of SQL table and column
$result=mysql_query($query); // Getting query
while ( $r = mysql_fetch_array( $result )){ // The result
$some1=$r['some1']; // Description
$some2=$r['some2']; // Description
$some3=$r['some3']; // Description
$some4=$r['some4']; // Description
echo"<br>$some1";
echo "<br>$some2";
echo "<br>$some3";
echo "<br>$some4";
}
?>

Easy one ,Huh?

So enough mysql.. Lets do some other basics.

Like in other sites they have a config.php file.Why do they need it?

I use it to make a called VARS.These are like

 <?php $var1 = "Hello world!I`m php!"; 
echo "$var1"; ?>

$var1 is the displaying text and this after it is the real text.I am using ECHO to get the var into a text.You can do same for other functions ,but this is basic.

Okay a simple protection i`ll post below.Everyone knows what it means and its useful for some pages you don't want users to view.Here is it

<?php
include('conf.php');
session_start();
$name[] = "user1"; $pass[] = "pass1"; // Username for login 1
$name[] = "user2"; $pass[] = "pass2"; // Username for login 2
//You can add as much users you want.

function loginform(){ //The form that unlogged users will use
echo '<fieldset style="padding: 2">';
echo '<legend>Login</legend>';
echo '<form method=post action="?">';
echo 'Name: <input type=text name=username value="' . $_POST[username] . '">'; //The name
echo '<br>';
echo 'Pass: <input type=password name=pass>'; //The password
echo '<br>';
echo '<input type=submit name="s1" value="Login">'; // The submit button
echo '</form>';
echo '</fieldset>';
}


if($_GET['action'] == "logout"){ // Logging out
$_SESSION['loggedin'] = false;
$_SESSION['username'] = "";
}

if($_SESSION['loggedin'] == false){ // Protection from NULL logins
if(!$_POST['s1']){
loginform();
}else{

$tmpname = $_POST['username']; #the username the user has submitted
$tmppass = $_POST['pass']; #the password the user has submitted

$t = count($name); #count the total users
$i = 0;

while($i <= $t){
if($tmpname == $name[$i] && $tmppass == $pass[$i]){ //Checking

$_SESSION['loggedin'] = true;
$_SESSION['username'] = $name[$i];
header('Location: ?'); #reload the page
}
$i++;
}
echo "Your attempt is invalid."; //If something is wrong
loginform(); #show the form
}
die; // if something is wrong , destroy it
}
?>

<center><br>Welcome <?php echo $_SESSION['username']; ?>
<br><a href="?action=logout">Logout</a> . </center>
<br>

I included some other things like Logout and stuff.. So anyway a simple code ,who records all IP's viewed the page you included it.

<?php
$file = fopen('ipadmin.txt', 'a'); // opens ,create a new file with storage
fwrite($file,$_SERVER['REMOTE_ADDR']."\n"); // Ip storing
fclose($file); // Close the file
echo "<br><b>Your ip was stored successfuly.</b>"; // if successful
?>

This will record every IP viewed your page in a file called ipadmin.txt . You can change it ofcourse.

Okay one more script.I called it Redirecting script ,because its redirecting u :D Here it is :

<?php
$url = ''; // ULR GOES HERE EDIT IT!
while (list($var,$val) = each($HTTP_GET_VARS))
$url .= "&$var=$val";
$i = strpos($url, "&url=");
if ($i !== false)
$url = substr($url, $i + 5);
if (substr($url, 0, 4) == "www.") 
$url = "http://" . $url;
print("<html><head><meta http-equiv=refresh content='0;url=$url'></head><body>\n");
print("<table border=0 width=100% height=100%><tr><td><h2 align=center>Currently moving to:<br>\n");
print("$url</h2></td></tr></table></body></html>\n");
?> 

It can be done alot easyer ,but this is with PHP.Html is ALOT easyer.

How to get some info's from another site? Another simple code.

<?php
$url="http://BLABLA.com/INFO.php"; // Edit this link to get the info from.
$string = file_get_contents($url);
$edno=explode('<div align="left">',$string);
$dve=explode('</div></td>',$edno[1]);
echo $dve[0];
?> 

 

Okay i think you learned the basics.. If you wanna just write them to remember them faster lol :D

Lol i`m making this topic about 16 mins :D Anyway thanks for viewing it.

I`ll make an advanced guide after a few days.

Link to comment
Share on other sites

Thanks for the comments guys, i'll continue it on monday because im typing from my iPhone , so cant make it now. I'll create advanced one too, just to come back to home :/ thanks again for comments.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Posts

    • Has anyone use their services?Their website looks super fishy.
    • Two Factions , An Endless War. Which Side Will You Choose? The legendary faction server, that everyone was waiting for, Koofs Vs Noobs is back! 24 hours pvp , no farm , fascinating rotating pvp zones! Koof vs Noob will fight each other day and night in order to gain their lost respect! Are you ready to feel the excitement? Rates: * EXP/SP x9999 * Faction Server   General Rates: * Start up Player System Instant LvL 80 * Choose For What Faction You Love To Fight [Koofs - Noobs] * Koofs Base: Dark Elf Village * Noobs Base: Elven Village * Prepare You Character Scheme Buff Or Choose Auto Buff * PrePare Your Character Equipment From KvN Shop * Killing spree systems * Full GM shop. * Free class change and Subclass * All NPCs available in town. * Custom Items Balanced. * Community Board BugReport/RaidInfo/TopPvP-Online 1 PvP = 1 Adena (2 If Premium)   Enchant Rates: Safe Enchant +6 Max Enchant +21 Normal Scroll Chance: 100% (+0 to +6) Blessed Scroll Chance: 85% (+6 to +21) Ex: If +14 failed for +15, return +14 LifeStones Rates: High Lifestone Chance: 5% Top  Lifestone Chance: 10%   Faction Bosses: Lilith Koofs Respawn 3H +1Random(there is a chance to spawn in 2H or 4H) Drops Adena+Bless Anakim Noobs Respawn 3H +1Random(there is a chance to spawn in 2H or 4H) Drops Adena+Bless   Grand Bosses: Queen Ant 8H +1Random (there is a chance to spawn in 7H or 9H) Drops RB Ring/LS/BOGS Baium     8H +1Random (there is a chance to spawn in 7H or 9H) Drops RB Ring/LS/BOGS Zaken     8H +1Random (there is a chance to spawn in 7H or 9H) Drops RB Ring/LS/BOGS Antharas  8H +1Random (there is a chance to spawn in 7H or 9H) Drops RB Ring/LS/BOGS Valakas   8H +1Random (there is a chance to spawn in 7H or 9H) Drops RB Ring/LS/BOGS      KvN Maps: Rune Castle Gludin Town   Website: Coming Soon Discord: https://discord.gg/8gmAcjEgFw Beta: 12/8/24 Join in discord group for more information New discord link: https://discord.gg/unn2XBhwef please mods update it because i cant edit my topic.
    • Classic-Interluede  Based on L2off Platform server files  and played with modern game client. Our main goal is to provide our players a fair and  stable retail game environment with less bugs possible and no pay to win game!   Phaedra Opening  :31.08.2024 20:00utc +1 No pay to win                 No Wipe             No Bots Phaedra Server Rates 𝐓𝐚𝐤𝐢𝐧𝐠 𝐢𝐧𝐭𝐨 𝐚𝐜𝐜𝐨𝐮𝐧𝐭, 𝐭𝐡𝐚𝐭 𝐰𝐞 𝐮𝐬𝐞 𝐨𝐟𝐟𝐢𝐜𝐢𝐚𝐥 𝐩𝐭𝐬 𝐢𝐧𝐭𝐞𝐫𝐥𝐮𝐝𝐞 𝐟𝐢𝐥𝐞𝐬, 𝐭𝐡𝐞 𝐠𝐚𝐦𝐞 𝐢𝐬 𝐫𝐞𝐭𝐚𝐢𝐥 𝐰𝐢𝐭𝐡 𝐬𝐨𝐦𝐞 𝐢𝐦𝐩𝐫𝐨𝐯𝐞𝐦𝐞𝐧𝐭𝐬 𝐛𝐫𝐨𝐮𝐠𝐡𝐭 𝐭𝐨 𝐨𝐮𝐫 𝐛𝐞𝐥𝐨𝐯𝐞𝐝 𝐢𝐧𝐭𝐞𝐫𝐥𝐮𝐝𝐞 𝐜𝐡𝐫𝐨𝐧𝐢𝐜𝐥𝐞 𝐬𝐮𝐜𝐡 𝐚𝐬 𝐚𝐭𝐭𝐞𝐧𝐝𝐚𝐧𝐜𝐞 𝐬𝐲𝐬𝐭𝐞𝐦, 𝐦𝐚𝐢𝐥 𝐬𝐲𝐬𝐭𝐞𝐦, 𝐭𝐡𝐞 𝐩𝐨𝐬𝐬𝐢𝐛𝐢𝐥𝐢𝐭𝐲 𝐭𝐨 𝐥𝐞𝐚𝐫𝐧 𝐬𝐤𝐢𝐥𝐥𝐬 𝐟𝐫𝐨𝐦 𝐭𝐡𝐞 𝐬𝐤𝐢𝐥𝐥 𝐩𝐚𝐧𝐞𝐥 (𝐚𝐥𝐭+𝐤) 𝐚𝐧𝐝 𝐚𝐥𝐬𝐨 𝐭𝐨 𝐞𝐧𝐜𝐡𝐚𝐧𝐭 𝐭𝐡𝐞𝐦 𝐚𝐧𝐝 𝐬𝐨 𝐨𝐧. 𝐀𝐬 𝐰𝐞𝐥𝐥 𝐚𝐬 𝐭𝐡𝐞 𝐩𝐨𝐬𝐬𝐢𝐛𝐢𝐥𝐢𝐭𝐲 𝐨𝐟 𝐮𝐬𝐢𝐧𝐠 𝐭𝐡𝐞 𝐧𝐞𝐰 𝐚𝐧𝐝 𝐦𝐨𝐝𝐞𝐫𝐧 𝐜𝐥𝐢𝐞𝐧𝐭 (𝐜𝐥𝐚𝐬𝐬𝐢𝐜 𝐜𝐥𝐢𝐞𝐧𝐭) 𝐰𝐡𝐢𝐜𝐡 𝐨𝐟𝐟𝐞𝐫𝐬 𝐛𝐞𝐭𝐭𝐞𝐫 𝐠𝐫𝐚𝐩𝐡𝐢𝐜𝐬, 𝐦𝐚𝐧𝐲 𝐨𝐟 𝐭𝐡𝐞 𝐬𝐤𝐢𝐥𝐥𝐬 𝐡𝐚𝐯𝐞 𝐧𝐞𝐰 𝐚𝐧𝐢𝐦𝐚𝐭𝐢𝐨𝐧𝐬 𝐚𝐧𝐝 𝐬𝐨 𝐨𝐧.   🔸Exp/SP-3x 🔸Adena -2x 🔸Spoil -1x 🔸Drop -1x 🔸Quests-1x 🔸Manor -1x 🔸Seal Stones -x1 Other Information 🔸Two(2) game clients per ip. 🔸35 sec spawn protection 🔸Buff slots:20+4 🔸Retail Buff Duration:20mins Buffs ,5mins Pow/cov summon buffs, 2 mins Dances/Songs 🔸No Auto Learn Skills 🔸No Auto Pick up Items Donate coin and Vote coin cannot be sold/drop/trade/destruct, but you can store them in your warehouse. 🔸Skills Require spell books to be lerned (alt+k) 🔸You Can Delevel up to 8 Lvls To Keep The Skills 🔸ALT+K to enchant your skills (Require SP+Book of giants) 🔸Safe Enchant: Weapons:+3 /Armors +3 ,Fullbody Armor +4 🔸Enchant Rate: Magic Weapons:From +0 to +3: 100 % - +3 to +15: 40 % - From +15 to +16: 20 % 🔸Enchant Rate: Fighter Weapons:From +0 to +3: 100 % - From +3 to +15: 70 % - From +15 to +16: 35 % 🔸Enchant Rate: Armor:From +0 to +3: 100 %-From +3 to +4: 66.6 %-From +4 to +5: 33.3 % - From +5 to +6: 25 % - From +6 to +7: 20 % - From +7 to +8: 16.6 % - From +8 to +9: 14.2 % - From +9 to +10: 12.5 % 🔸Augument: One active*One Passive 🔸Augument Rate To Get Skill : Top LS-14%;High LS-10%;Mid LS-6%; Normal LS-1% 🔸The quest "Kamel window to the feature" is disabled. 🔸Cursed weapons are disabled till first server heros. 🔸Olympiad will start when there are minimum 40 players nobless. 🔸Wedding system is disabled for now (will be actived later on) . 🔸Clan hall rent fee per week was increased with 300% for better server economy in late game. 🔸Shadow weapons B grade ,shadow weapons C and D are moved to ShadowWeapon Manager( will be in each town and village!) 🔸Adventurer's Guide (Miss Queen) is Spawned in all towns and villages and works retail like. 🔸Class-option to advance your class job with (1st,2nd) class change ticket. option to trade your shadow weapon tickets after you complete you class advancing (D, C grade tickets) like retail. an option to buy change class ticket with adena and donation coins. 🔸Chance to update soul crystal lvl to Anakazel Rift Raid Boss is 25%(retail value). 🔸Quest Enhance weapon is required to lvl up soul crystals. 🔸You need to have in your inventory just 1 (one) soul crystal to be able to lvl it up. 🔸To lvl soul crystals in Pi(Primeval isle) is not required to hit Tyrannosaurus with soul crystal to capture his soul to lvl soul crystal up. 🔸Party Lvl Gap to gain experience is 14 lvls Difference: 💠1 lvl Difference ~98% 💠2 lvl Difference ~95% 💠3 lvl Difference ~93% 💠4 lvl Difference ~91% 💠5 lvl Difference ~88% 💠6 lvl Difference ~86% 💠7 lvl Difference ~83% 💠8 lvl Difference ~81% 💠9 lvl Difference ~78% 💠10 lvl Difference ~23% 💠11 lvl Difference ~22% 💠12 lvl Difference ~21% 💠13 lvl Difference ~20% 💠14 lvl Difference ~19% 💠15 lvl Difference ~ 0% 🔸XP bonus. The more people in a party, the more XP bonus: 💠2 party members — x1.6 💠3 party members — х1.65 💠4 party members — х1.7 💠5 party members — х1.8 💠6 party members — х1.9 💠7 party members — х2.0 💠8 party members — х2.1 💠9 party members — х2.2 🔸Reward for logging into the game daily. 🔸Vote Reward System(12h Bonus rune will increase your Exp, adena, sp, spoil, drop by 15%.) 🔸Stream Reward 🔸Our donation curency is Donate coins with donation coins you can only buy: -5€-Bonus rune 30days will increase your Exp, adena, sp, spoil, drop by 15%. -10€-Costume Ticket (.dressme)-has no bonus just for look. -5€-Hats-has no bonus just for look. -5€-Title Color -8€-World Chat Card-Your Messeges would be seen by everyone. -5€-1st class transfer tiket./-10€-2nd class transfer tiket. -9€-Clan Quest item for clan LVL4. -10€-Clan Quest item for clan LVL5. -5€- Epic Raid boss Join quest -25€- Unique Cloaks -3€- Delete Karma -10€- Delete PK Counter 🔸Alt+click on Buff to remove it !(if you want to remove a buff, don't work to remove your debuffs). 🔸ALT+K For Skill Panel (To Learn Skills or To Enchant skills) 🔸Drop/Spoil shift+click on mob to see he's info. 🔸To Stop Gain experience (.exp on) and to gain experience(.exp off) 🔸Set an character in sell/buy mode and exit game (offlineshop) 🔸Captcha system by killing monsters(150) to pop up,for better security Website: https://classic-interlude.com Discord : https://discord.com/invite/gBUdDPufwE FaceBook https://www.facebook.com/L2ClassicInterlude
  • Topics

×
×
  • Create New...