Correct my codes please.

Started on the old forum in March 2009 · view the original in the archive · old links redirect here

4 replies · 487 views · started 17 years ago · 1 min read

3 participants
infested13 Junior · 19 posts #1

hello seniors. im making an experience calculator for an online game.

please help me with this script. i cant output the correct data.

<?
include("../include/session.php");
include("../include/protect.php");
?>
<html>
<head>
<title>Exp Generator</title>
<link rel="stylesheet" type="text/css" href="/1.css">
<link rel="shortcut icon" href="/tibia.ico">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta name="description" content="Armada TibiaME - One of the best TibiaME fansite!">
<meta name="keywords" content="tibia, tibiame, fansite, microspec, armada">
</head>
<div align="center">
<font size="1" face="Century Gothic">
<img src="/logo.png"/><br><br>
<body>

<form action="experience.php" method="post">
<b>Enter Level</b><br><br>
<input type="text" name="level" maxlength="2" size="3"><br><br>
<input type="radio" name="char" value="warrior"> Warrior
<br>
<input type="radio" name="char" value="wizard"> Wizard
<br><br>
<input type="submit" value="Calculate">
</form>

<a href="/home.php">Main Menu</a><br><br>
</div>
</body>
</html>

example of experience.php

<?
include("../include/session.php");
include("../include/protect.php");
?>
<html>
<head>
<title>Exp Generator</title>
<link rel="stylesheet" type="text/css" href="/1.css">
<link rel="shortcut icon" href="/tibia.ico">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta name="description" content="Armada TibiaME - One of the best TibiaME fansite!">
<meta name="keywords" content="tibia, tibiame, fansite, microspec, armada">
</head>
<div align="center">
<font size="1" face="Century Gothic">
<img src="/logo.png"/><br><br>
<body>

<?
if ($_POST['level'] = "1" & $_POST['char'] = "warrior"){
   echo "<b>Experience Needed:</b><br>";
   echo "0<br>";
   echo "<b>Health:</b><br>";
   echo "100";
}
else if ($_POST['level'] = "1" & $_POST['char'] = "wizard"){
   echo "<b>Experience Needed:</b><br>";
   echo "0<br>";
   echo "<b>Health:</b><br>";
   echo "100";
}
else if ($_POST['level'] = "2" & $_POST['char'] = "warrior"){
   echo "<b>Experience Needed:</b><br>";
   echo "10<br>";
   echo "<b>Health:</b><br>";
   echo "110";
}
else if ($_POST['level'] = "2" & $_POST['char'] = "wizard"){
   echo "<b>Experience Needed:</b><br>";
   echo "10<br>";
   echo "<b>Health:</b><br>";
   echo "104";
}
?>

<br><br>
<a href="/home.php">Main Menu</a><br><br>
</div>
</body>
</html>

hahah. dont laugh. im just a beginner, hmm. whats wrong with my experience.php. it

ori Lead · 512 posts #2

whats the error/glitch ?

infested13 Junior · 19 posts #3

ori wrote: whats the error/glitch ?

if i type 2 here:

<form action="experience.php" method="post"> 
<b>Enter Level</b><br><br> 
<input type="text" name="level" maxlength="2" size="3"><br><br> 
<input type="radio" name="char" value="warrior"> Warrior 
<br> 
<input type="radio" name="char" value="wizard"> Wizard 
<br><br> 
<input type="submit" value="Calculate"> 
</form>

the result is:

if ($_POST['level'] = "1" & $_POST['char'] = "warrior"){ 
   echo "<b>Experience Needed:</b><br>"; 
   echo "0<br>"; 
   echo "<b>Health:</b><br>"; 
   echo "100";

even if the code for two is

else if ($_POST['level'] = "2" & $_POST['char'] = "warrior"){ 
   echo "<b>Experience Needed:</b><br>"; 
   echo "10<br>"; 
   echo "<b>Health:</b><br>"; 
   echo "110";
GumSlone Administrator Principal · 1,690 posts #4

there should be 2 equal and & signs, everywhere

if ($_POST['level'] == "1" && $_POST['char'] == "warrior")

Advertise your mobile site for FREE with AdTwirl

External image (may be gone)

infested13 Junior · 19 posts #5

thanks for your replies. i already fixed it.

if ( $level == "1" && $char == "warrior" )

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close