Jump to content

Why doesnt this work...


Neptunus Maris

Recommended Posts

why doesnt this work...Ive seen similar codes like this in books and on other sites than phpfreaks.

 

when i click the submit button to test the error messages...the screen is blank(im using the $_SERVER

[php_SELF] in the form action.  and even when i submit the info it does the same thing.

to view http://www.rdrvision.com/medievalkingdoms/join_england.php

<?php
//Include mklib.php and main_style.css and connnect to the database
include "engine/mklib.php";
include "engine/main_style.css";
connect();

//Start Code

//check submitted info
//get aray values from mklib.php for character physical features
global $join_sex_sel, $eye_color_sel, $hair_color_sel, $skin_tone_sel;
//sex
foreach ($join_sex_sel as $sex) {
$sex_option .= "<option value = \"$sex\">$sex</option>";
} //end foreach
//eye color
foreach ($eye_color_sel as $eye_color) {
$eye_color_option .= "<option value = \"$eye_color\">$eye_color</option>";
} //end foreach
//hair color
foreach ($hair_color_sel as $hair_color) {
$hair_color_option .= "<option value = \"$hair_color\">$hair_color</option>";
} //end foreach
//skin tone
foreach ($skin_tone_sel as $skin_tone) {
$skin_tone_option .= "<option value = \"$skin_tone\">$skin_tone</option>";
} //end foreach
$display = "<center>\n";
$display .= "<form action = \"$_SERVER[php_SELF]\" method = \"post\">\n";
$display .= "<table border = 0>\n";
$display .= "<tr>\n";
$display .= "<td align = \"right\">First Name:</td>\n";
$display .= "<td><input type =\"text\" name = \"f_name\" size = 15 maxlength = 50></td>\n";
$display .= "</tr>\n\n";
$display .= "<tr>\n";
$display .= "<td align = \"right\">Last Name:</td>\n";
$display .= "<td><input type = \"text\" name = \"l_name\" size = 15 maxlength = 50></td>\n";
$display .= "</tr>\n\n";
$display .= "<td align = \"right\">Email:</td>\n";
$display .= "<td><input type = \"text\" name = \"email\" size = 15 maxlength = 100></td>\n";
$display .= "</tr>\n\n";
$display .= "<tr>\n";
$display .= "<td align = \"right\">Sex:</td>\n";
$display .= "<td><select name = \"sex\">$sex_option</select>\n";
$display .= "</tr>\n\n";
$display .= "<tr>\n";
$display .= "<td align = \"right\">Height:</td>\n";
$display .= "<td><input type = \"text\" name = \"height\" size = 4 maxlength = 4></td>\n";
$display .= "</tr>\n\n";
$display .= "<tr>\n";
$display .= "<td align = \"right\">Weight:</td>\n";
$display .= "<td><input type = \"text\" name = \"weight\" size = 3 maxlength = 3></td>\n";
$display .= "</tr>\n\n";
$display .= "<tr>\n";
$display .= "<td align = \"right\">Eye Color:</td>\n";
$display .= "<td><select name = \"eye_color\">$eye_color_option</select></td>\n";
$display .= "</tr>\n\n";
$display .= "<tr>\n";
$display .= "<td align = \"right\">Hair Color:</td>\n";
$display .= "<td><select name = \"hair_color\">$hair_color_option</select></td>\n";
$display .= "</tr>\n\n";
$display .= "<tr>\n";
$display .= "<td align = \"right\">Skin Tone:</td>\n";
$display .= "<td><select name = \"skin_tone\">$skin_tone_option</select></td>\n";
$display .= "</tr>\n\n";
$display .= "<tr>\n";
$display .= "<td align = \"right\">Birth Place:</td>\n";
$display .= "<td><input type = \"text\" name = \"place_birth\" size = 15 maxlength = 100 value = \"London, England\"></td>\n";
$display .= "</tr>\n\n";
$display .= "<tr>\n";
$display .= "<td></td>\n";
$display .= "<td><input type = \"submit\" name = \"submit\" value = \"Join MK\"></td>\n";
$display .= "</tr>\n";
$display .= "</table>\n";
$display .= "</form>\n";
$display .= "</center>\n";

if (!isset($_POST[submit])) {
$show_form = "yes";
} elseif (isset($_POST[submit])) {
$errorlist = 0;
$error = "";
//check fist name and last name
$query = "SELECT * FROM e_character WHERE f_name = '$_POST[f_name]' AND l_name = '$_POST[l_name]'";
$result = mysql_query($query) or die(mysql_error());
$check_name = mysql_num_rows($result) or die(mysql_error());
if ($check_name > 0) {
	$errorlist++;
	$error .= "ERROR: That name already in use.<br>\n";
	$show_form = "yes";
}
if (empty($_POST[f_name])) {
	$errorlist++;
	$error .= "ERROR: You must have a first name for your character.<br>\n";
	$show_form = "yes";
}
if (empty($_POST[l_name])) {
	$errorlist++;
	$error .= "ERROR: You must have a last name for your character.<br>\n";
	$show_form = "yes";
}
//check email
$query = "SELECT * FROM e_character WHERE email = '$_POST[email]'";
$result = mysql_query($query) or die(mysql_error());
$check_email = mysql_num_rows($result) or die(mysql_error());
if ($check_email > 0) {
	$errorlist++;
	$error .= "ERROR: That email is already in use.<br>\n";
	$show_form = "yes";
}
if (empty($_POST[email])) {
	$errorlist++;
	$error .= "ERROR: You must enter a valid email address.<br>\n";
	$show_form = "yes";
}
//check other fields
if (empty($_POST[height])) {
	$errorlist++;
	$error .= "ERROR: You must enter a height for your character.<br>\n";
	$show_form = "yes";
}
if (empty($_POST[weight])) {
	$errorlist++;
	$error .= "ERROR: You must enter a weight for your character.<br>\n";
	$show_form = "yes";
}
if (!is_numeric($_POST[weight])) {
	$errorlist++;
	$error .= "ERROR: The weight field must be numeric.<br>\n";
	$show_form = "yes";
}
if (empty($_POST[place_birth])) {
	$errorlist++;
	$error .= "ERROR: You must enter a birth place for your character.<br>\n";
	$show_form = "yes";
}

if ($errorlist == 0){
	$show_success = "yes";
}
} //end if

//get the form is show form == yes
if ($show_form == "yes") {
$display_block = $display;
} elseif ($show_success == "yes") {
$f_name = $_POST[f_name];
$l_name = $_POST[l_name];
$email = chop($_POST[email]);
$sex = $_POST[sex];
$height = chop($_POST[height]);
$weight = chop(round($_POST[weight]));
$eye_color = $_POST[eye_color];
$hair_color = $_POST[hair_color];
$skin_tone = $_POST[skin_tone];
$place_birth = chop($_POST[place_birth]);

//give the new player a password
$code = rand(100000,999999);
$password = md5($code);

//get the current year for birth year
$query = "SELECT * FROM time WHERE timeID = '1'";
$result = mysql_query($query) or die(mysql_error());
$time = mysql_fetch_array($result) or die(mysql_error());
$birth_year = $time[year] - 16;

//get the new player's ip address
$ip = getenv("REMOTE_ADDR");

//finally insert the new player into the database
$query = "INSERT INTO e_character (e_characterID, f_name, l_name, email, password, sex, height, weight, eye_color, hair_color, skin_tone, place_birth, birth_year, ip, family, reg_date) VALUES('', '$f_name', '$l_name', '$email', '$password', '$sex', '$height', '$weight', '$eye_color', '$hair_color', '$skin_tone', '$place_birth', '$birth_year', '$ip', '$l_name', NOW())";
$result = mysql_query($query) or die(mysql_error());

//send email with password and a message
$to = $email;
$subject = "MK Verification.";
$headers = "From: Medieval Kingdoms <medievalkingdoms@hotmail.com>";
$message = "SENT FROM MEDIEVAL ADMINISTRATION\n";
$message .= "Subject: User Verification.\n";
$message .= "Message: Thank you for joining Medieval Kingdoms, your password is $code. Make sure you join the forums to get masked at z10.invisionfree.com/MKS, again thank you and enjoy playing Medieval Kingdoms.\n\n";

mail($to, $subject, $message, $headers);

$display_block = "You have successfully joined Medieval Kingdoms! Check your email for password. Make sure you go to the forums and get masked.\n";
$display_block .= "If you are absolutely new to MK please read the <a href = 'rules.php'>Rules</a> and if needed <a href = 'faqs.php'>FAQs</a> pages.\n";
}
?>

<html>
<head>
	<title>MKtemplate</title>
</head>
<body bgcolor="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<!-- ImageReady Slices (MKtemplate.psd) -->
<center>
<table width="901" height="500" border="0" cellpadding="0" cellspacing="0">
<tr>
	<td colspan="2" background = "images/MKtemplate_01.gif" width="900" height="168" align = "right" valign = "bottom"><?php print time_display(); print month();?></td>
<td>
<img src="spacer.gif" width="1" height="168" alt=""></td>
</tr>
<tr>
	<td rowspan="3" valign = "top">
		<img src="images/MKtemplate_02.gif" width="242" height="299" border="0" usemap="#Map">
<map name="Map">
  <area shape="rect" coords="134,90,175,101" href="index.php">
  <area shape="rect" coords="119,116,195,127" href="join.php">
  <area shape="rect" coords="115,144,199,156" href="rules.php">
  <area shape="rect" coords="117,171,195,183" href="faqs.php">
  <area shape="rect" coords="89,199,222,210" href="z10.invisionfree.com/MKS" target = "_blank">
  <area shape="rect" coords="88,224,225,235" href="credits.php">
  <area shape="rect" coords="81,252,237,264" href="nations.php">
  <area shape="rect" coords="123,279,192,291" href="mkmap.php">
</map></td>
	<td background = "images/MKtemplate_03.gif" width="658" height="53" align = "center">
		<h3>Join English</h3></td>
	<td>
		<img src="spacer.gif" width="1" height="53" alt=""></td>
</tr>
<tr>
	<td background = "images/MKtemplate_04.gif" width="658" height="224" align = "center" valign = "top" style = "background-repeat:repeat-y;">
		<?php print "$error"; print "$display_block"; ?></td>
	<td>
		<img src="spacer.gif" width="1" height="224" alt=""></td>
</tr>
<tr>
	<td rowspan="2" background = "images/MKtemplate_05.gif" width="658" height="55" align = "center" valign = "top">
		[<a href = "index.php">Home</a>] [<a href = "join.php">Join M.K.</a>] [<a href = "rules.php">M.K. Rules</a>] [<a href = "faqs.php">M.K. FAQs</a>] [<a href = "z10.invisionfree.com/MKS" target = "_blank">M.K. Forums</a>] [<a href = "credits.php">M.K. Credits</a>] [<a href = "nations.php">Nations</a>] [<a href = "mkmap.php">M.K. Map</a>]<br>[[<a href = "rdrvision.com" target = "_blank">RDRvision</a>]] ---- [<a href = "admin_login.php">Admin.</a>]       Version 1.0     <?php print "$hits"; ?></td>
	<td>
		<img src="spacer.gif" width="1" height="22" alt=""></td>
</tr>
<tr>
	<td background = "images/MKtemplate_06.gif" width="242" height="33" align = "center" valign = "top" style = "background-position:top; background-repeat:repeat-y;">
		</td>
	<td>
		<img src="spacer.gif" width="1" height="33" alt=""></td>
</tr>
</table>
</center>
<!-- End ImageReady Slices -->
</body>
</html>

 

(edited by kenrbnsn to get the code between


tags)

Link to comment
Share on other sites

That is a mess, I looked over it, I know it's not going blank because of an error without error reporting being on or it would show a blank screen.  That is highly unreadable.

 

With the jumbled mess of code, I am guessing it's something to do with a "logic" error.  You might want to rewrite some of it, put some indentation.  Echo out the following for (after) the form is submitted and tell me what happens.

echo "Post";

echo "<br />";

print_r($_POST);

exit;

 

Put that onto the screen right after you check if submit is set for the form submission.  Put here what comes up.

Link to comment
Share on other sites

That is a mess, I looked over it, I know it's not going blank because of an error without error reporting being on or it would show a blank screen.  That is highly unreadable.

 

With the jumbled mess of code, I am guessing it's something to do with a "logic" error.  You might want to rewrite some of it, put some indentation.  Echo out the following for (after) the form is submitted and tell me what happens.

echo "Post";

echo "<br />";

print_r($_POST);

exit;

 

Put that onto the screen right after you check if submit is set for the form submission.  Put here what comes up.

 

What...i didnt get what you are saying...make a psuedo code so i know where exactly to put it.

Link to comment
Share on other sites

As I mentioned right below

if (isset($_POST['submit'])) {

 

Also in order to make it easier for other people, put code tag's, like this.

 

<?php
//Include mklib.php and main_style.css and connnect to the database
include "engine/mklib.php";
include "engine/main_style.css";
connect();

//Start Code

//check submitted info
//get aray values from mklib.php for character physical features
global $join_sex_sel, $eye_color_sel, $hair_color_sel, $skin_tone_sel;
//sex
foreach ($join_sex_sel as $sex) {
   $sex_option .= "<option value = \"$sex\">$sex</option>";
} //end foreach
//eye color
foreach ($eye_color_sel as $eye_color) {
   $eye_color_option .= "<option value = \"$eye_color\">$eye_color</option>";
} //end foreach
//hair color
foreach ($hair_color_sel as $hair_color) {
   $hair_color_option .= "<option value = \"$hair_color\">$hair_color</option>";
} //end foreach
//skin tone
foreach ($skin_tone_sel as $skin_tone) {
   $skin_tone_option .= "<option value = \"$skin_tone\">$skin_tone</option>";
} //end foreach
$display = "<center>\n";
$display .= "<form action = \"$_SERVER[php_SELF]\" method = \"post\">\n";
$display .= "<table border = 0>\n";
$display .= "<tr>\n";
$display .= "<td align = \"right\">First Name:</td>\n";
$display .= "<td><input type =\"text\" name = \"f_name\" size = 15 maxlength = 50></td>\n";
$display .= "</tr>\n\n";
$display .= "<tr>\n";
$display .= "<td align = \"right\">Last Name:</td>\n";
$display .= "<td><input type = \"text\" name = \"l_name\" size = 15 maxlength = 50></td>\n";
$display .= "</tr>\n\n";
$display .= "<td align = \"right\">Email:</td>\n";
$display .= "<td><input type = \"text\" name = \"email\" size = 15 maxlength = 100></td>\n";
$display .= "</tr>\n\n";
$display .= "<tr>\n";
$display .= "<td align = \"right\">Sex:</td>\n";
$display .= "<td><select name = \"sex\">$sex_option</select>\n";
$display .= "</tr>\n\n";
$display .= "<tr>\n";
$display .= "<td align = \"right\">Height:</td>\n";
$display .= "<td><input type = \"text\" name = \"height\" size = 4 maxlength = 4></td>\n";
$display .= "</tr>\n\n";
$display .= "<tr>\n";
$display .= "<td align = \"right\">Weight:</td>\n";
$display .= "<td><input type = \"text\" name = \"weight\" size = 3 maxlength = 3></td>\n";
$display .= "</tr>\n\n";
$display .= "<tr>\n";
$display .= "<td align = \"right\">Eye Color:</td>\n";
$display .= "<td><select name = \"eye_color\">$eye_color_option</select></td>\n";
$display .= "</tr>\n\n";
$display .= "<tr>\n";
$display .= "<td align = \"right\">Hair Color:</td>\n";
$display .= "<td><select name = \"hair_color\">$hair_color_option</select></td>\n";
$display .= "</tr>\n\n";
$display .= "<tr>\n";
$display .= "<td align = \"right\">Skin Tone:</td>\n";
$display .= "<td><select name = \"skin_tone\">$skin_tone_option</select></td>\n";
$display .= "</tr>\n\n";
$display .= "<tr>\n";
$display .= "<td align = \"right\">Birth Place:</td>\n";
$display .= "<td><input type = \"text\" name = \"place_birth\" size = 15 maxlength = 100 value = \"London, England\"></td>\n";
$display .= "</tr>\n\n";
$display .= "<tr>\n";
$display .= "<td></td>\n";
$display .= "<td><input type = \"submit\" name = \"submit\" value = \"Join MK\"></td>\n";
$display .= "</tr>\n";
$display .= "</table>\n";
$display .= "</form>\n";
$display .= "</center>\n";

if (!isset($_POST[submit])) {
   $show_form = "yes";
} elseif (isset($_POST[submit])) {
   $errorlist = 0;
   $error = "";
   //check fist name and last name
   $query = "SELECT * FROM e_character WHERE f_name = '$_POST[f_name]' AND l_name = '$_POST[l_name]'";
   $result = mysql_query($query) or die(mysql_error());
   $check_name = mysql_num_rows($result) or die(mysql_error());
   if ($check_name > 0) {
      $errorlist++;
      $error .= "ERROR: That name already in use.
\n";
      $show_form = "yes";
   }
   if (empty($_POST[f_name])) {
      $errorlist++;
      $error .= "ERROR: You must have a first name for your character.
\n";
      $show_form = "yes";
   }
   if (empty($_POST[l_name])) {
      $errorlist++;
      $error .= "ERROR: You must have a last name for your character.
\n";
      $show_form = "yes";
   }
   //check email
   $query = "SELECT * FROM e_character WHERE email = '$_POST[email]'";
   $result = mysql_query($query) or die(mysql_error());
   $check_email = mysql_num_rows($result) or die(mysql_error());
   if ($check_email > 0) {
      $errorlist++;
      $error .= "ERROR: That email is already in use.
\n";
      $show_form = "yes";
   }
   if (empty($_POST[email])) {
      $errorlist++;
      $error .= "ERROR: You must enter a valid email address.
\n";
      $show_form = "yes";
   }
   //check other fields
   if (empty($_POST[height])) {
      $errorlist++;
      $error .= "ERROR: You must enter a height for your character.
\n";
      $show_form = "yes";
   }
   if (empty($_POST[weight])) {
      $errorlist++;
      $error .= "ERROR: You must enter a weight for your character.
\n";
      $show_form = "yes";
   }
   if (!is_numeric($_POST[weight])) {
      $errorlist++;
      $error .= "ERROR: The weight field must be numeric.
\n";
      $show_form = "yes";
   }
   if (empty($_POST[place_birth])) {
      $errorlist++;
      $error .= "ERROR: You must enter a birth place for your character.
\n";
      $show_form = "yes";
   }
   
   if ($errorlist == 0){
      $show_success = "yes";
   }
} //end if

//get the form is show form == yes
if ($show_form == "yes") {
   $display_block = $display;
} elseif ($show_success == "yes") {
   $f_name = $_POST[f_name];
   $l_name = $_POST[l_name];
   $email = chop($_POST[email]);
   $sex = $_POST[sex];
   $height = chop($_POST[height]);
   $weight = chop(round($_POST[weight]));
   $eye_color = $_POST[eye_color];
   $hair_color = $_POST[hair_color];
   $skin_tone = $_POST[skin_tone];
   $place_birth = chop($_POST[place_birth]);

   //give the new player a password
   $code = rand(100000,999999);
   $password = md5($code);

   //get the current year for birth year
   $query = "SELECT * FROM time WHERE timeID = '1'";
   $result = mysql_query($query) or die(mysql_error());
   $time = mysql_fetch_array($result) or die(mysql_error());
   $birth_year = $time[year] - 16;

   //get the new player's ip address
   $ip = getenv("REMOTE_ADDR");

   //finally insert the new player into the database
   $query = "INSERT INTO e_character (e_characterID, f_name, l_name, email, password, sex, height, weight, eye_color, hair_color, skin_tone, place_birth, birth_year, ip, family, reg_date) VALUES('', '$f_name', '$l_name', '$email', '$password', '$sex', '$height', '$weight', '$eye_color', '$hair_color', '$skin_tone', '$place_birth', '$birth_year', '$ip', '$l_name', NOW())";
   $result = mysql_query($query) or die(mysql_error());
   
   //send email with password and a message
   $to = $email;
   $subject = "MK Verification.";
   $headers = "From: Medieval Kingdoms <medievalkingdoms@hotmail.com>";
   $message = "SENT FROM MEDIEVAL ADMINISTRATION\n";
   $message .= "Subject: User Verification.\n";
   $message .= "Message: Thank you for joining Medieval Kingdoms, your password is $code. Make sure you join the forums to get masked at z10.invisionfree.com/MKS, again thank you and enjoy playing Medieval Kingdoms.\n\n";
   
   mail($to, $subject, $message, $headers);
   
   $display_block = "You have successfully joined Medieval Kingdoms! Check your email for password. Make sure you go to the forums and get masked.\n";
   $display_block .= "If you are absolutely new to MK please read the <a href = 'rules.php'>Rules[/url] and if needed <a href = 'faqs.php'>FAQs[/url] pages.\n";
}
?>

<html>
<head>
      <title>MKtemplate</title>
</head>
<body bgcolor="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<!-- ImageReady Slices (MKtemplate.psd) -->
<center>
<table width="901" height="500" border="0" cellpadding="0" cellspacing="0">
   <tr>
      <td colspan="2" background = "images/MKtemplate_01.gif" width="900" height="168" align = "right" valign = "bottom"><?php print time_display(); print month();?></td>
   <td>
   <img src="spacer.gif" width="1" height="168" alt=""></td>
   </tr>
   <tr>
      <td rowspan="3" valign = "top">
         <img src="images/MKtemplate_02.gif" width="242" height="299" border="0" usemap="#Map">
<map name="Map">
  <area shape="rect" coords="134,90,175,101" href="index.php">
  <area shape="rect" coords="119,116,195,127" href="join.php">
  <area shape="rect" coords="115,144,199,156" href="rules.php">
  <area shape="rect" coords="117,171,195,183" href="faqs.php">
  <area shape="rect" coords="89,199,222,210" href="z10.invisionfree.com/MKS" target = "_blank">
  <area shape="rect" coords="88,224,225,235" href="credits.php">
  <area shape="rect" coords="81,252,237,264" href="nations.php">
  <area shape="rect" coords="123,279,192,291" href="mkmap.php">
</map></td>
      <td background = "images/MKtemplate_03.gif" width="658" height="53" align = "center">
         <h3>Join English</h3></td>
      <td>
         <img src="spacer.gif" width="1" height="53" alt=""></td>
   </tr>
   <tr>
      <td background = "images/MKtemplate_04.gif" width="658" height="224" align = "center" valign = "top" style = "background-repeat:repeat-y;">
         <?php print "$error"; print "$display_block"; ?></td>
      <td>
         <img src="spacer.gif" width="1" height="224" alt=""></td>
   </tr>
   <tr>
      <td rowspan="2" background = "images/MKtemplate_05.gif" width="658" height="55" align = "center" valign = "top">
         [<a href = "index.php">Home[/url]] [<a href = "join.php">Join M.K.[/url]] [<a href = "rules.php">M.K. Rules[/url]] [<a href = "faqs.php">M.K. FAQs[/url]] [<a href = "z10.invisionfree.com/MKS" target = "_blank">M.K. Forums[/url]] [<a href = "credits.php">M.K. Credits[/url]] [<a href = "nations.php">Nations[/url]] [<a href = "mkmap.php">M.K. Map[/url]]
[[<a href = "rdrvision.com" target = "_blank">RDRvision[/url]]] ---- [<a href = "admin_login.php">Admin.[/url]]       Version 1.0     <?php print "$hits"; ?></td>
      <td>
         <img src="spacer.gif" width="1" height="22" alt=""></td>
   </tr>
   <tr>
      <td background = "images/MKtemplate_06.gif" width="242" height="33" align = "center" valign = "top" style = "background-position:top; background-repeat:repeat-y;">
         </td>
      <td>
         <img src="spacer.gif" width="1" height="33" alt=""></td>
   </tr>
</table>
</center>
<!-- End ImageReady Slices -->
</body>
</html>

 

Link to comment
Share on other sites

See, I don't understand what you are doing with some of this.

 

For instance

global $join_sex_sel, $eye_color_sel, $hair_color_sel, $skin_tone_sel;

Why do these need to be global, what is the purpose for all for for statements at the beginning of the document.

 

You may have to clean that up just a little, put in some indentation. I can make out some of the logic behind the code, but it's hard telling what does what, I know it's part of a game it looks like, but I can't tell, you have a lot of things all over hte page.

Link to comment
Share on other sites

This is an edited part i cleaned up the table a little...i still cant find where you wanted me to put that code.  And the reason why i have the globals...is because i have arrays for the option values in mklib.php

 

<?php
//=========================================================
//	Join England
//	-----------------------------------------
//	This program allows the visitor to join
//	this nation. Here he/she will fill in the
//	blanks for a valid join.
//	-----------------------------------------
//	Created by RDRvision Games (c) 2007
//	All Rights Reserved.
//	-----------------------------------------
//	Programmed by: Rashaud Teague
//=========================================================

//Include mklib.php and main_style.css and connnect to the database
include "engine/mklib.php";
include "engine/main_style.css";
connect();

//Start Code

//check submitted info
//get aray values from mklib.php for character physical features
global $join_sex_sel, $eye_color_sel, $hair_color_sel, $skin_tone_sel;
//sex
foreach ($join_sex_sel as $sex) {
$sex_option .= "<option value = \"$sex\">$sex</option>";
} //end foreach
//eye color
foreach ($eye_color_sel as $eye_color) {
$eye_color_option .= "<option value = \"$eye_color\">$eye_color</option>";
} //end foreach
//hair color
foreach ($hair_color_sel as $hair_color) {
$hair_color_option .= "<option value = \"$hair_color\">$hair_color</option>";
} //end foreach
//skin tone
foreach ($skin_tone_sel as $skin_tone) {
$skin_tone_option .= "<option value = \"$skin_tone\">$skin_tone</option>";
} //end foreach
$display = "<center>\n";
$display .= "<form action = \"$_SERVER[php_SELF]\" method = \"post\">\n";
$display .= "<table border = 0>\n";
$display .= "<tr>\n";
$display .= "<td align = \"right\">First Name:</td>\n";
$display .= "<td><input type =\"text\" name = \"f_name\" size = 15 maxlength = 50></td>\n";
$display .= "</tr>\n\n";
$display .= "<tr>\n";
$display .= "<td align = \"right\">Last Name:</td>\n";
$display .= "<td><input type = \"text\" name = \"l_name\" size = 15 maxlength = 50></td>\n";
$display .= "</tr>\n\n";
$display .= "<td align = \"right\">Email:</td>\n";
$display .= "<td><input type = \"text\" name = \"email\" size = 15 maxlength = 100></td>\n";
$display .= "</tr>\n\n";
$display .= "<tr>\n";
$display .= "<td align = \"right\">Sex:</td>\n";
$display .= "<td><select name = \"sex\">$sex_option</select>\n";
$display .= "</tr>\n\n";
$display .= "<tr>\n";
$display .= "<td align = \"right\">Height:</td>\n";
$display .= "<td><input type = \"text\" name = \"height\" size = 4 maxlength = 4></td>\n";
$display .= "</tr>\n\n";
$display .= "<tr>\n";
$display .= "<td align = \"right\">Weight:</td>\n";
$display .= "<td><input type = \"text\" name = \"weight\" size = 3 maxlength = 3></td>\n";
$display .= "</tr>\n\n";
$display .= "<tr>\n";
$display .= "<td align = \"right\">Eye Color:</td>\n";
$display .= "<td><select name = \"eye_color\">$eye_color_option</select></td>\n";
$display .= "</tr>\n\n";
$display .= "<tr>\n";
$display .= "<td align = \"right\">Hair Color:</td>\n";
$display .= "<td><select name = \"hair_color\">$hair_color_option</select></td>\n";
$display .= "</tr>\n\n";
$display .= "<tr>\n";
$display .= "<td align = \"right\">Skin Tone:</td>\n";
$display .= "<td><select name = \"skin_tone\">$skin_tone_option</select></td>\n";
$display .= "</tr>\n\n";
$display .= "<tr>\n";
$display .= "<td align = \"right\">Birth Place:</td>\n";
$display .= "<td><input type = \"text\" name = \"place_birth\" size = 15 maxlength = 100 value = \"London, England\"></td>\n";
$display .= "</tr>\n\n";
$display .= "<tr>\n";
$display .= "<td></td>\n";
$display .= "<td><input type = \"submit\" name = \"submit\" value = \"Join MK\"></td>\n";
$display .= "</tr>\n";
$display .= "</table>\n";
$display .= "</form>\n";
$display .= "</center>\n";

if (!isset($_POST[submit])) {
$show_form = "yes";
} elseif (isset($_POST[submit])) {
$errorlist = 0;
$error = "";
//check fist name and last name
$query = "SELECT * FROM e_character WHERE f_name = '$_POST[f_name]' AND l_name = '$_POST[l_name]'";
$result = mysql_query($query) or die(mysql_error());
$check_name = mysql_num_rows($result) or die(mysql_error());
if ($check_name > 0) {
	$errorlist++;
	$error .= "ERROR: That name already in use.<br>\n";
	$show_form = "yes";
} elseif (empty($_POST[f_name])) {
	$errorlist++;
	$error .= "ERROR: You must have a first name for your character.<br>\n";
	$show_form = "yes";
} elseif (empty($_POST[l_name])) {
	$errorlist++;
	$error .= "ERROR: You must have a last name for your character.<br>\n";
	$show_form = "yes";
}
//check email
$query = "SELECT * FROM e_character WHERE email = '$_POST[email]'";
$result = mysql_query($query) or die(mysql_error());
$check_email = mysql_num_rows($result) or die(mysql_error());
if ($check_email > 0) {
	$errorlist++;
	$error .= "ERROR: That email is already in use.<br>\n";
	$show_form = "yes";
} elseif (empty($_POST[email])) {
	$errorlist++;
	$error .= "ERROR: You must enter a valid email address.<br>\n";
	$show_form = "yes";
}
//check other fields
if (empty($_POST[height])) {
	$errorlist++;
	$error .= "ERROR: You must enter a height for your character.<br>\n";
	$show_form = "yes";
} elseif (empty($_POST[weight])) {
	$errorlist++;
	$error .= "ERROR: You must enter a weight for your character.<br>\n";
	$show_form = "yes";
} elseif (!is_numeric($_POST[weight])) {
	$errorlist++;
	$error .= "ERROR: The weight field must be numeric.<br>\n";
	$show_form = "yes";
} elseif (empty($_POST[place_birth])) {
	$errorlist++;
	$error .= "ERROR: You must enter a birth place for your character.<br>\n";
	$show_form = "yes";
}

if ($errorlist == 0) {
	$show_success = "yes";
}
} //end if

//get the form is show form == yes
if ($show_form == "yes") {
$display_block = $display;
} elseif ($show_success == "yes") {
$f_name = $_POST[f_name];
$l_name = $_POST[l_name];
$email = chop($_POST[email]);
$sex = $_POST[sex];
$height = chop($_POST[height]);
$weight = chop(round($_POST[weight]));
$eye_color = $_POST[eye_color];
$hair_color = $_POST[hair_color];
$skin_tone = $_POST[skin_tone];
$place_birth = chop($_POST[place_birth]);

//give the new player a password
$code = rand(100000,999999);
$password = md5($code);

//get the current year for birth year
$query = "SELECT * FROM time WHERE timeID = '1'";
$result = mysql_query($query) or die(mysql_error());
$time = mysql_fetch_array($result) or die(mysql_error());
$birth_year = $time[year] - 16;

//get the new player's ip address
$ip = getenv("REMOTE_ADDR");

//finally insert the new player into the database
$query = "INSERT INTO e_character (e_characterID, f_name, l_name, email, password, sex, height, weight, eye_color, hair_color, skin_tone, place_birth, birth_year, ip, family, reg_date) VALUES('', '$f_name', '$l_name', '$email', '$password', '$sex', '$height', '$weight', '$eye_color', '$hair_color', '$skin_tone', '$place_birth', '$birth_year', '$ip', '$l_name', NOW())";
$result = mysql_query($query) or die(mysql_error());

//send email with password and a message
$to = $email;
$subject = "MK Verification.";
$headers = "From: Medieval Kingdoms <medievalkingdoms@hotmail.com>";
$message = "SENT FROM MEDIEVAL ADMINISTRATION\n";
$message .= "Subject: User Verification.\n";
$message .= "Message: Thank you for joining Medieval Kingdoms, your password is $code. Make sure you join the forums to get masked at z10.invisionfree.com/MKS, again thank you and enjoy playing Medieval Kingdoms.\n\n";

mail($to, $subject, $message, $headers);

$display_block = "You have successfully joined Medieval Kingdoms! Check your email for password. Make sure you go to the forums and get masked.\n";
$display_block .= "If you are absolutely new to MK please read the <a href = 'rules.php'>Rules</a> and if needed <a href = 'faqs.php'>FAQs</a> pages.\n";
}
?>

<html>
<head>
	<title>Join English</title>
</head>
<body bgcolor="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<center>
<table width="901" height="500" border="0" cellpadding="0" cellspacing="0">
<tr>
<td colspan="2" background = "images/MKtemplate_01.gif" width="900" height="168" align = "right" valign = "bottom"><?php print time_display(); print month();?></td>
<td><img src="spacer.gif" width="1" height="168" alt=""></td>
</tr>
<tr>
<td rowspan="3" valign = "top">
<img src="images/MKtemplate_02.gif" width="242" height="299" border="0" usemap="#Map">
<map name="Map">
  <area shape="rect" coords="134,90,175,101" href="index.php">
  <area shape="rect" coords="119,116,195,127" href="join.php">
  <area shape="rect" coords="115,144,199,156" href="rules.php">
  <area shape="rect" coords="117,171,195,183" href="faqs.php">
  <area shape="rect" coords="89,199,222,210" href="z10.invisionfree.com/MKS" target = "_blank">
  <area shape="rect" coords="88,224,225,235" href="credits.php">
  <area shape="rect" coords="81,252,237,264" href="nations.php">
  <area shape="rect" coords="123,279,192,291" href="mkmap.php">
</map>
</td>
<td background = "images/MKtemplate_03.gif" width="658" height="53" align = "center"><h3>Join English</h3></td>
<td>
	<img src="spacer.gif" width="1" height="53" alt=""></td>
</tr>
<tr>
<td background = "images/MKtemplate_04.gif" width="658" height="224" align = "center" valign = "top" style = "background-repeat:repeat-y;"><?php print "$error"; print "$display_block"; ?></td>
<td><img src="spacer.gif" width="1" height="224" alt=""></td>
</tr>
<tr>
<td rowspan="2" background = "images/MKtemplate_05.gif" width="658" height="55" align = "center" valign = "top">[<a href = "index.php">Home</a>] [<a href = "join.php">Join M.K.</a>] [<a href = "rules.php">M.K. Rules</a>] [<a href = "faqs.php">M.K. FAQs</a>] [<a href = "z10.invisionfree.com/MKS" target = "_blank">M.K. Forums</a>] [<a href = "credits.php">M.K. Credits</a>] [<a href = "nations.php">Nations</a>] [<a href = "mkmap.php">M.K. Map</a>]<br>[[<a href = "rdrvision.com" target = "_blank">RDRvision</a>]] ---- [<a href = "admin_login.php">Admin.</a>]       Version 1.0    </td>
<td><img src="spacer.gif" width="1" height="22" alt=""></td>
</tr>
<tr>
<td background = "images/MKtemplate_06.gif" width="242" height="33" align = "center" valign = "top" style = "background-position:top; background-repeat:repeat-y;">
</td>
<td><img src="spacer.gif" width="1" height="33" alt=""></td>
</tr>
</table>
</center>
</body>
</html>

Link to comment
Share on other sites

Then the problem is something to do with your form.  The post variables are not passing, and I can't begin to tell you how.  I think you placed that code in teh wrong place because when I go to the url, I see the array, it should be I see the form, then when you click submit, it sends the post.

 

I just took the thing off you told me to put back on. but yeah i dont know whats going on.

Link to comment
Share on other sites

Let's do this systematically.

 

First remove everything that isn't related to the form.  Take just the form itself, and put it on a seperate test page.  Test.php.

Then have it submit it to itself, with nothing but

 

if (isset($_POST['submit'])) {

print_r($_POST);

}

put that at the top of the page, in php tags for the page that the form is on.

 

Once we try this we'll know if it's the form or not.  Once we rule that out we can test the other half of the script.

Link to comment
Share on other sites

Also just to rule it out, on the 2 includes, change include to require_once this will verify for sure if it's an issue with one of those includes.

 

its not...if changed the code around alittle different.

 

<?php
//=========================================================
//	Join England
//	-----------------------------------------
//	This program allows the visitor to join
//	this nation. Here he/she will fill in the
//	blanks for a valid join.
//	-----------------------------------------
//	Created by RDRvision Games (c) 2007
//	All Rights Reserved.
//	-----------------------------------------
//	Programmed by: Rashaud Teague
//=========================================================

//Include mklib.php and main_style.css and connnect to the database
include "engine/mklib.php";
include "engine/main_style.css";
connect();

//Start Code

if (!isset($_POST[submit])) {
$show_form = "yes";
} elseif (isset($_POST[submit])) {
$errorlist = 0;
$error = "";
//check fist name and last name
$query = "SELECT * FROM e_character WHERE f_name = '$_POST[f_name]' AND l_name = '$_POST[l_name]'";
$result = mysql_query($query) or die(mysql_error());
$check_name = mysql_num_rows($result) or die(mysql_error());
if ($check_name > 0) {
	$errorlist++;
	$error .= "ERROR: That name already in use.<br>\n";
	$show_form = "yes";
} elseif (empty($_POST[f_name])) {
	$errorlist++;
	$error .= "ERROR: You must have a first name for your character.<br>\n";
	$show_form = "yes";
} elseif (empty($_POST[l_name])) {
	$errorlist++;
	$error .= "ERROR: You must have a last name for your character.<br>\n";
	$show_form = "yes";
}
//check email
$query = "SELECT * FROM e_character WHERE email = '$_POST[email]'";
$result = mysql_query($query) or die(mysql_error());
$check_email = mysql_num_rows($result) or die(mysql_error());
if ($check_email > 0) {
	$errorlist++;
	$error .= "ERROR: That email is already in use.<br>\n";
	$show_form = "yes";
} elseif (empty($_POST[email])) {
	$errorlist++;
	$error .= "ERROR: You must enter a valid email address.<br>\n";
	$show_form = "yes";
}
//check other fields
if (empty($_POST[height])) {
	$errorlist++;
	$error .= "ERROR: You must enter a height for your character.<br>\n";
	$show_form = "yes";
} elseif (empty($_POST[weight])) {
	$errorlist++;
	$error .= "ERROR: You must enter a weight for your character.<br>\n";
	$show_form = "yes";
} elseif (!is_numeric($_POST[weight])) {
	$errorlist++;
	$error .= "ERROR: The weight field must be numeric.<br>\n";
	$show_form = "yes";
} elseif (empty($_POST[place_birth])) {
	$errorlist++;
	$error .= "ERROR: You must enter a birth place for your character.<br>\n";
	$show_form = "yes";
}

if ($errorlist == 0) {
	$show_success = "yes";
}
} //end if

//get the form is show form == yes
if ($show_success == "yes") {
$f_name = $_POST[f_name];
$l_name = $_POST[l_name];
$email = chop($_POST[email]);
$sex = $_POST[sex];
$height = chop($_POST[height]);
$weight = chop(round($_POST[weight]));
$eye_color = $_POST[eye_color];
$hair_color = $_POST[hair_color];
$skin_tone = $_POST[skin_tone];
$place_birth = chop($_POST[place_birth]);

//give the new player a password
$code = rand(100000,999999);
$password = md5($code);

//get the current year for birth year
$query = "SELECT * FROM time WHERE timeID = '1'";
$result = mysql_query($query) or die(mysql_error());
$time = mysql_fetch_array($result) or die(mysql_error());
$birth_year = $time[year] - 16;

//get the new player's ip address
$ip = getenv("REMOTE_ADDR");

//finally insert the new player into the database
$query = "INSERT INTO e_character (e_characterID, f_name, l_name, email, password, sex, height, weight, eye_color, hair_color, skin_tone, place_birth, birth_year, ip, family, reg_date) VALUES('', '$f_name', '$l_name', '$email', '$password', '$sex', '$height', '$weight', '$eye_color', '$hair_color', '$skin_tone', '$place_birth', '$birth_year', '$ip', '$l_name', NOW())";
$result = mysql_query($query) or die(mysql_error());

//send email with password and a message
$to = $email;
$subject = "MK Verification.";
$headers = "From: Medieval Kingdoms <medievalkingdoms@hotmail.com>";
$message = "SENT FROM MEDIEVAL ADMINISTRATION\n";
$message .= "Subject: User Verification.\n";
$message .= "Message: Thank you for joining Medieval Kingdoms, your password is $code. Make sure you join the forums to get masked at z10.invisionfree.com/MKS, again thank you and enjoy playing Medieval Kingdoms.\n\n";

mail($to, $subject, $message, $headers);

$display = "You have successfully joined Medieval Kingdoms! Check your email for password. Make sure you go to the forums and get masked.\n";
$display .= "If you are absolutely new to MK please read the <a href = 'rules.php'>Rules</a> and if needed <a href = 'faqs.php'>FAQs</a> pages.\n";
} elseif ($show_form == "yes") {
//check submitted info
//get aray values from mklib.php for character physical features
global $join_sex_sel, $eye_color_sel, $hair_color_sel, $skin_tone_sel;
//sex
foreach ($join_sex_sel as $sex) {
	$sex_option .= "<option value = \"$sex\">$sex</option>";
} //end foreach
//eye color
foreach ($eye_color_sel as $eye_color) {
	$eye_color_option .= "<option value = \"$eye_color\">$eye_color</option>";
} //end foreach
//hair color
foreach ($hair_color_sel as $hair_color) {
	$hair_color_option .= "<option value = \"$hair_color\">$hair_color</option>";
} //end foreach
//skin tone
foreach ($skin_tone_sel as $skin_tone) {
	$skin_tone_option .= "<option value = \"$skin_tone\">$skin_tone</option>";
} //end foreach
$display = "<center>\n";
$display .= "<form action = \"$_SERVER[php_SELF]\" method = \"post\">\n";
$display .= "<table border = 0>\n";
$display .= "<tr>\n";
$display .= "<td align = \"right\">First Name:</td>\n";
$display .= "<td><input type =\"text\" name = \"f_name\" size = 15 maxlength = 50></td>\n";
$display .= "</tr>\n\n";
$display .= "<tr>\n";
$display .= "<td align = \"right\">Last Name:</td>\n";
$display .= "<td><input type = \"text\" name = \"l_name\" size = 15 maxlength = 50></td>\n";
$display .= "</tr>\n\n";
$display .= "<td align = \"right\">Email:</td>\n";
$display .= "<td><input type = \"text\" name = \"email\" size = 15 maxlength = 100></td>\n";
$display .= "</tr>\n\n";
$display .= "<tr>\n";
$display .= "<td align = \"right\">Sex:</td>\n";
$display .= "<td><select name = \"sex\">$sex_option</select>\n";
$display .= "</tr>\n\n";
$display .= "<tr>\n";
$display .= "<td align = \"right\">Height:</td>\n";
$display .= "<td><input type = \"text\" name = \"height\" size = 4 maxlength = 4></td>\n";
$display .= "</tr>\n\n";
$display .= "<tr>\n";
$display .= "<td align = \"right\">Weight:</td>\n";
$display .= "<td><input type = \"text\" name = \"weight\" size = 3 maxlength = 3></td>\n";
$display .= "</tr>\n\n";
$display .= "<tr>\n";
$display .= "<td align = \"right\">Eye Color:</td>\n";
$display .= "<td><select name = \"eye_color\">$eye_color_option</select></td>\n";
$display .= "</tr>\n\n";
$display .= "<tr>\n";
$display .= "<td align = \"right\">Hair Color:</td>\n";
$display .= "<td><select name = \"hair_color\">$hair_color_option</select></td>\n";
$display .= "</tr>\n\n";
$display .= "<tr>\n";
$display .= "<td align = \"right\">Skin Tone:</td>\n";
$display .= "<td><select name = \"skin_tone\">$skin_tone_option</select></td>\n";
$display .= "</tr>\n\n";
$display .= "<tr>\n";
$display .= "<td align = \"right\">Birth Place:</td>\n";
$display .= "<td><input type = \"text\" name = \"place_birth\" size = 15 maxlength = 100 value = \"London, England\"></td>\n";
$display .= "</tr>\n\n";
$display .= "<tr>\n";
$display .= "<td></td>\n";
$display .= "<td><input type = \"submit\" name = \"submit\" value = \"Join MK\"></td>\n";
$display .= "</tr>\n";
$display .= "</table>\n";
$display .= "</form>\n";
$display .= "</center>\n";
}
?>

<html>
<head>
	<title>Join English</title>
</head>
<body bgcolor="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<center>
<table width="901" height="500" border="0" cellpadding="0" cellspacing="0">
<tr>
<td colspan="2" background = "images/MKtemplate_01.gif" width="900" height="168" align = "right" valign = "bottom"><?php print time_display(); print month();?></td>
<td><img src="spacer.gif" width="1" height="168" alt=""></td>
</tr>
<tr>
<td rowspan="3" valign = "top">
<img src="images/MKtemplate_02.gif" width="242" height="299" border="0" usemap="#Map">
<map name="Map">
  <area shape="rect" coords="134,90,175,101" href="index.php">
  <area shape="rect" coords="119,116,195,127" href="join.php">
  <area shape="rect" coords="115,144,199,156" href="rules.php">
  <area shape="rect" coords="117,171,195,183" href="faqs.php">
  <area shape="rect" coords="89,199,222,210" href="z10.invisionfree.com/MKS" target = "_blank">
  <area shape="rect" coords="88,224,225,235" href="credits.php">
  <area shape="rect" coords="81,252,237,264" href="nations.php">
  <area shape="rect" coords="123,279,192,291" href="mkmap.php">
</map>
</td>
<td background = "images/MKtemplate_03.gif" width="658" height="53" align = "center"><h3>Join English</h3></td>
<td>
	<img src="spacer.gif" width="1" height="53" alt=""></td>
</tr>
<tr>
<td background = "images/MKtemplate_04.gif" width="658" height="224" align = "center" valign = "top" style = "background-repeat:repeat-y;"><?php print "$error"; print "$display"; ?></td>
<td><img src="spacer.gif" width="1" height="224" alt=""></td>
</tr>
<tr>
<td rowspan="2" background = "images/MKtemplate_05.gif" width="658" height="55" align = "center" valign = "top">[<a href = "index.php">Home</a>] [<a href = "join.php">Join M.K.</a>] [<a href = "rules.php">M.K. Rules</a>] [<a href = "faqs.php">M.K. FAQs</a>] [<a href = "z10.invisionfree.com/MKS" target = "_blank">M.K. Forums</a>] [<a href = "credits.php">M.K. Credits</a>] [<a href = "nations.php">Nations</a>] [<a href = "mkmap.php">M.K. Map</a>]<br>[[<a href = "rdrvision.com" target = "_blank">RDRvision</a>]] ---- [<a href = "admin_login.php">Admin.</a>]       Version 1.0    </td>
<td><img src="spacer.gif" width="1" height="22" alt=""></td>
</tr>
<tr>
<td background = "images/MKtemplate_06.gif" width="242" height="33" align = "center" valign = "top" style = "background-position:top; background-repeat:repeat-y;">
</td>
<td><img src="spacer.gif" width="1" height="33" alt=""></td>
</tr>
</table>
</center>
</body>
</html>

Link to comment
Share on other sites

Yes, but why are you asking for help if you aren't going to try it.

 

That is all the advice I can offer unless you try it.

 

My advice is change

include => require_once

 

Remove the form into a seperate form and tested it as I mentioned.

 

I can't help you any more until you try those, let me know if you try those.  I have looked over evertying, I have given all the generaly help I can without some effort from you to help me hunt down the problem.

 

All I can do now is help you isolate and find the problem, once found I can help you fix it.

Link to comment
Share on other sites

Yes, but why are you asking for help if you aren't going to try it.

 

That is all the advice I can offer unless you try it.

 

My advice is change

include => require_once

 

Remove the form into a seperate form and tested it as I mentioned.

 

I can't help you any more until you try those, let me know if you try those.  I have looked over evertying, I have given all the generaly help I can without some effort from you to help me hunt down the problem.

 

All I can do now is help you isolate and find the problem, once found I can help you fix it.

 

I did try that...did not work

Link to comment
Share on other sites

If you removed the form and put it on a page (example.php)

Then at the top of the page above the form all you put is

<?php

if (isset($_POST['submit'])) {

print_r($_POST);

}

?>

show me the page with the test form and that above. None of the other code, not the layout, not anything but the form and that code at the top. if show, then show me the layout, and the code behind the page.  ONLY the test page, shouldn't have anything bu tthe form with that above it.

Link to comment
Share on other sites

If you removed the form and put it on a page (example.php)

Then at the top of the page above the form all you put is

<?php

if (isset($_POST['submit'])) {

print_r($_POST);

}

?>

show me the page with the test form and that above. None of the other code, not the layout, not anything but the form and that code at the top. if show, then show me the layout, and the code behind the page.  ONLY the test page, shouldn't have anything bu tthe form with that above it.

 

 

I did it... http://www.rdrvision.com/medievalkingdoms/example.php

 

<?php
require_once "engine/mklib.php";
require_once "engine/main_style.css";
if (isset($_POST[submit])) {
print_r($_POST);
}
?>
//example.php
//check submitted info
//get aray values from mklib.php for character physical features
global $join_sex_sel, $eye_color_sel, $hair_color_sel, $skin_tone_sel;
//sex
foreach ($join_sex_sel as $sex) {
$sex_option .= "<option value = \"$sex\">$sex</option>";
} //end foreach
//eye color
foreach ($eye_color_sel as $eye_color) {
$eye_color_option .= "<option value = \"$eye_color\">$eye_color</option>";
} //end foreach
//hair color
foreach ($hair_color_sel as $hair_color) {
$hair_color_option .= "<option value = \"$hair_color\">$hair_color</option>";
} //end foreach
//skin tone
foreach ($skin_tone_sel as $skin_tone) {
$skin_tone_option .= "<option value = \"$skin_tone\">$skin_tone</option>";
} //end foreach
$display = "<center>\n";
$display .= "<form action = \"$_SERVER[php_SELF]\" method = \"post\">\n";
$display .= "<table border = 0>\n";
$display .= "<tr>\n";
$display .= "<td align = \"right\">First Name:</td>\n";
$display .= "<td><input type =\"text\" name = \"f_name\" size = 15 maxlength = 50></td>\n";
$display .= "</tr>\n\n";
$display .= "<tr>\n";
$display .= "<td align = \"right\">Last Name:</td>\n";
$display .= "<td><input type = \"text\" name = \"l_name\" size = 15 maxlength = 50></td>\n";
$display .= "</tr>\n\n";
$display .= "<td align = \"right\">Email:</td>\n";
$display .= "<td><input type = \"text\" name = \"email\" size = 15 maxlength = 100></td>\n";
$display .= "</tr>\n\n";
$display .= "<tr>\n";
$display .= "<td align = \"right\">Sex:</td>\n";
$display .= "<td><select name = \"sex\">$sex_option</select>\n";
$display .= "</tr>\n\n";
$display .= "<tr>\n";
$display .= "<td align = \"right\">Height:</td>\n";
$display .= "<td><input type = \"text\" name = \"height\" size = 4 maxlength = 4></td>\n";
$display .= "</tr>\n\n";
$display .= "<tr>\n";
$display .= "<td align = \"right\">Weight:</td>\n";
$display .= "<td><input type = \"text\" name = \"weight\" size = 3 maxlength = 3></td>\n";
$display .= "</tr>\n\n";
$display .= "<tr>\n";
$display .= "<td align = \"right\">Eye Color:</td>\n";
$display .= "<td><select name = \"eye_color\">$eye_color_option</select></td>\n";
$display .= "</tr>\n\n";
$display .= "<tr>\n";
$display .= "<td align = \"right\">Hair Color:</td>\n";
$display .= "<td><select name = \"hair_color\">$hair_color_option</select></td>\n";
$display .= "</tr>\n\n";
$display .= "<tr>\n";
$display .= "<td align = \"right\">Skin Tone:</td>\n";
$display .= "<td><select name = \"skin_tone\">$skin_tone_option</select></td>\n";
$display .= "</tr>\n\n";
$display .= "<tr>\n";
$display .= "<td align = \"right\">Birth Place:</td>\n";
$display .= "<td><input type = \"text\" name = \"place_birth\" size = 15 maxlength = 100 value = \"London, England\"></td>\n";
$display .= "</tr>\n\n";
$display .= "<tr>\n";
$display .= "<td><input type = \"hidden\" name = \"op\" value = \"ds\"></td>\n";
$display .= "<td><input type = \"submit\" name = \"submit\" value = \"Join MK\"></td>\n";
$display .= "</tr>\n";
$display .= "</table>\n";
$display .= "</form>\n";
$display .= "</center>\n";
?>

<html>
<head>
	<title>Example</title>
</head>
<body>
	<h3>Example Form</h3>
<p><?php print "$display"; ?></p>

</body>
</html>

Link to comment
Share on other sites

Now i've tried this ...i did rearranging in my code ...yeah id ont think $_SERVER

[php_SELF] works...because there is nothing wrong with this code, i dont know what the hell is going on with my code.

<?php
//=========================================================
//	Join England
//	-----------------------------------------
//	This program allows the visitor to join
//	this nation. Here he/she will fill in the
//	blanks for a valid join.
//	-----------------------------------------
//	Created by RDRvision Games (c) 2007
//	All Rights Reserved.
//	-----------------------------------------
//	Programmed by: Rashaud Teague
//=========================================================

//Include mklib.php and main_style.css and connnect to the database
include "engine/mklib.php";
include "engine/main_style.css";
connect();

//Start Code

if (!isset($_POST[submit])) {
//check submitted info
//get aray values from mklib.php for character physical features
global $join_sex_sel, $eye_color_sel, $hair_color_sel, $skin_tone_sel;
//sex
foreach ($join_sex_sel as $sex) {
	$sex_option .= "<option value = \"$sex\">$sex</option>";
} //end foreach
//eye color
foreach ($eye_color_sel as $eye_color) {
	$eye_color_option .= "<option value = \"$eye_color\">$eye_color</option>";
} //end foreach
//hair color
foreach ($hair_color_sel as $hair_color) {
	$hair_color_option .= "<option value = \"$hair_color\">$hair_color</option>";
} //end foreach
//skin tone
foreach ($skin_tone_sel as $skin_tone) {
	$skin_tone_option .= "<option value = \"$skin_tone\">$skin_tone</option>";
} //end foreach
$display = "<center>\n";
$display .= "<form action = \"$_SERVER[php_SELF]\" method = \"post\">\n";
$display .= "<table border = 0>\n";
$display .= "<tr>\n";
$display .= "<td align = \"right\">First Name:</td>\n";
$display .= "<td><input type =\"text\" name = \"f_name\" size = 15 maxlength = 50></td>\n";
$display .= "</tr>\n\n";
$display .= "<tr>\n";
$display .= "<td align = \"right\">Last Name:</td>\n";
$display .= "<td><input type = \"text\" name = \"l_name\" size = 15 maxlength = 50></td>\n";
$display .= "</tr>\n\n";
$display .= "<td align = \"right\">Email:</td>\n";
$display .= "<td><input type = \"text\" name = \"email\" size = 15 maxlength = 100></td>\n";
$display .= "</tr>\n\n";
$display .= "<tr>\n";
$display .= "<td align = \"right\">Sex:</td>\n";
$display .= "<td><select name = \"sex\">$sex_option</select>\n";
$display .= "</tr>\n\n";
$display .= "<tr>\n";
$display .= "<td align = \"right\">Height:</td>\n";
$display .= "<td><input type = \"text\" name = \"height\" size = 4 maxlength = 4></td>\n";
$display .= "</tr>\n\n";
$display .= "<tr>\n";
$display .= "<td align = \"right\">Weight:</td>\n";
$display .= "<td><input type = \"text\" name = \"weight\" size = 3 maxlength = 3></td>\n";
$display .= "</tr>\n\n";
$display .= "<tr>\n";
$display .= "<td align = \"right\">Eye Color:</td>\n";
$display .= "<td><select name = \"eye_color\">$eye_color_option</select></td>\n";
$display .= "</tr>\n\n";
$display .= "<tr>\n";
$display .= "<td align = \"right\">Hair Color:</td>\n";
$display .= "<td><select name = \"hair_color\">$hair_color_option</select></td>\n";
$display .= "</tr>\n\n";
$display .= "<tr>\n";
$display .= "<td align = \"right\">Skin Tone:</td>\n";
$display .= "<td><select name = \"skin_tone\">$skin_tone_option</select></td>\n";
$display .= "</tr>\n\n";
$display .= "<tr>\n";
$display .= "<td align = \"right\">Birth Place:</td>\n";
$display .= "<td><input type = \"text\" name = \"place_birth\" size = 15 maxlength = 100 value = \"London, England\"></td>\n";
$display .= "</tr>\n\n";
$display .= "<tr>\n";
$display .= "<td></td>\n";
$display .= "<td><input type = \"submit\" name = \"submit\" value = \"Join MK\"></td>\n";
$display .= "</tr>\n";
$display .= "</table>\n";
$display .= "</form>\n";
$display .= "</center>\n";
} elseif (isset($_POST[submit])) {
$errorlist = 0;
$error = "";
//check fist name and last name
$query = "SELECT * FROM e_character WHERE f_name = '$_POST[f_name]' AND l_name = '$_POST[l_name]'";
$result = mysql_query($query) or die(mysql_error());
$check_name = mysql_num_rows($result) or die(mysql_error());
if ($check_name > 0) {
	$errorlist++;
	$error .= "ERROR: That name already in use.<br>\n";
	$show_form = "yes";
} elseif (empty($_POST[f_name])) {
	$errorlist++;
	$error .= "ERROR: You must have a first name for your character.<br>\n";
	$show_form = "yes";
} elseif (empty($_POST[l_name])) {
	$errorlist++;
	$error .= "ERROR: You must have a last name for your character.<br>\n";
	$show_form = "yes";
}
//check email
$query = "SELECT * FROM e_character WHERE email = '$_POST[email]'";
$result = mysql_query($query) or die(mysql_error());
$check_email = mysql_num_rows($result) or die(mysql_error());
if ($check_email > 0) {
	$errorlist++;
	$error .= "ERROR: That email is already in use.<br>\n";
	$show_form = "yes";
} elseif (empty($_POST[email])) {
	$errorlist++;
	$error .= "ERROR: You must enter a valid email address.<br>\n";
	$show_form = "yes";
}
//check other fields
if (empty($_POST[height])) {
	$errorlist++;
	$error .= "ERROR: You must enter a height for your character.<br>\n";
	$show_form = "yes";
} elseif (empty($_POST[weight])) {
	$errorlist++;
	$error .= "ERROR: You must enter a weight for your character.<br>\n";
	$show_form = "yes";
} elseif (!is_numeric($_POST[weight])) {
	$errorlist++;
	$error .= "ERROR: The weight field must be numeric.<br>\n";
	$show_form = "yes";
} elseif (empty($_POST[place_birth])) {
	$errorlist++;
	$error .= "ERROR: You must enter a birth place for your character.<br>\n";
	$show_form = "yes";
}

if ($errorlist == 0) {
	$f_name = $_POST[f_name];
	$l_name = $_POST[l_name];
	$email = chop($_POST[email]);
	$sex = $_POST[sex];
	$height = chop($_POST[height]);
	$weight = chop(round($_POST[weight]));
	$eye_color = $_POST[eye_color];
	$hair_color = $_POST[hair_color];
	$skin_tone = $_POST[skin_tone];
	$place_birth = chop($_POST[place_birth]);

	//give the new player a password
	$code = rand(100000,999999);
	$password = md5($code);

	//get the current year for birth year
	$query = "SELECT * FROM time WHERE timeID = '1'";
	$result = mysql_query($query) or die(mysql_error());
	$time = mysql_fetch_array($result) or die(mysql_error());
	$birth_year = $time[year] - 16;

	//get the new player's ip address
	$ip = getenv("REMOTE_ADDR");

	//finally insert the new player into the database
	$query = "INSERT INTO e_character (e_characterID, f_name, l_name, email, password, sex, height, weight, eye_color, hair_color, skin_tone, place_birth, birth_year, ip, family, reg_date) VALUES('', '$f_name', '$l_name', '$email', '$password', '$sex', '$height', '$weight', '$eye_color', '$hair_color', '$skin_tone', '$place_birth', '$birth_year', '$ip', '$l_name', NOW())";
	$result = mysql_query($query) or die(mysql_error());

	//send email with password and a message
	$to = $email;
	$subject = "MK Verification.";
	$headers = "From: Medieval Kingdoms <medievalkingdoms@hotmail.com>";
	$message = "SENT FROM MEDIEVAL ADMINISTRATION\n";
	$message .= "Subject: User Verification.\n";
	$message .= "Message: Thank you for joining Medieval Kingdoms, your password is $code. Make sure you join the forums to get masked at z10.invisionfree.com/MKS, again thank you and enjoy playing Medieval Kingdoms.\n\n";

	mail($to, $subject, $message, $headers);

	$display = "You have successfully joined Medieval Kingdoms! Check your email for password. Make sure you go to the forums and get masked.\n";
	$display .= "If you are absolutely new to MK please read the <a href = 'rules.php'>Rules</a> and if needed <a href = 'faqs.php'>FAQs</a> pages.\n";
}
} //end if

//get the form is show form == yes
if ($show_form == "yes") {
//check submitted info
//get aray values from mklib.php for character physical features
global $join_sex_sel, $eye_color_sel, $hair_color_sel, $skin_tone_sel;
//sex
foreach ($join_sex_sel as $sex) {
	$sex_option .= "<option value = \"$sex\">$sex</option>";
} //end foreach
//eye color
foreach ($eye_color_sel as $eye_color) {
	$eye_color_option .= "<option value = \"$eye_color\">$eye_color</option>";
} //end foreach
//hair color
foreach ($hair_color_sel as $hair_color) {
	$hair_color_option .= "<option value = \"$hair_color\">$hair_color</option>";
} //end foreach
//skin tone
foreach ($skin_tone_sel as $skin_tone) {
	$skin_tone_option .= "<option value = \"$skin_tone\">$skin_tone</option>";
} //end foreach
$display = "<center>\n";
$display .= "$error\n";
$display .= "<form action = \"$_SERVER[php_SELF]\" method = \"post\">\n";
$display .= "<table border = 0>\n";
$display .= "<tr>\n";
$display .= "<td align = \"right\">First Name:</td>\n";
$display .= "<td><input type =\"text\" name = \"f_name\" size = 15 maxlength = 50></td>\n";
$display .= "</tr>\n\n";
$display .= "<tr>\n";
$display .= "<td align = \"right\">Last Name:</td>\n";
$display .= "<td><input type = \"text\" name = \"l_name\" size = 15 maxlength = 50></td>\n";
$display .= "</tr>\n\n";
$display .= "<td align = \"right\">Email:</td>\n";
$display .= "<td><input type = \"text\" name = \"email\" size = 15 maxlength = 100></td>\n";
$display .= "</tr>\n\n";
$display .= "<tr>\n";
$display .= "<td align = \"right\">Sex:</td>\n";
$display .= "<td><select name = \"sex\">$sex_option</select>\n";
$display .= "</tr>\n\n";
$display .= "<tr>\n";
$display .= "<td align = \"right\">Height:</td>\n";
$display .= "<td><input type = \"text\" name = \"height\" size = 4 maxlength = 4></td>\n";
$display .= "</tr>\n\n";
$display .= "<tr>\n";
$display .= "<td align = \"right\">Weight:</td>\n";
$display .= "<td><input type = \"text\" name = \"weight\" size = 3 maxlength = 3></td>\n";
$display .= "</tr>\n\n";
$display .= "<tr>\n";
$display .= "<td align = \"right\">Eye Color:</td>\n";
$display .= "<td><select name = \"eye_color\">$eye_color_option</select></td>\n";
$display .= "</tr>\n\n";
$display .= "<tr>\n";
$display .= "<td align = \"right\">Hair Color:</td>\n";
$display .= "<td><select name = \"hair_color\">$hair_color_option</select></td>\n";
$display .= "</tr>\n\n";
$display .= "<tr>\n";
$display .= "<td align = \"right\">Skin Tone:</td>\n";
$display .= "<td><select name = \"skin_tone\">$skin_tone_option</select></td>\n";
$display .= "</tr>\n\n";
$display .= "<tr>\n";
$display .= "<td align = \"right\">Birth Place:</td>\n";
$display .= "<td><input type = \"text\" name = \"place_birth\" size = 15 maxlength = 100 value = \"London, England\"></td>\n";
$display .= "</tr>\n\n";
$display .= "<tr>\n";
$display .= "<td></td>\n";
$display .= "<td><input type = \"submit\" name = \"submit\" value = \"Join MK\"></td>\n";
$display .= "</tr>\n";
$display .= "</table>\n";
$display .= "</form>\n";
$display .= "</center>\n";
}
?>

<html>
<head>
	<title>Join English</title>
</head>
<body bgcolor="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<center>
<table width="901" height="500" border="0" cellpadding="0" cellspacing="0">
<tr>
<td colspan="2" background = "images/MKtemplate_01.gif" width="900" height="168" align = "right" valign = "bottom"><?php print time_display(); print month();?></td>
<td><img src="spacer.gif" width="1" height="168" alt=""></td>
</tr>
<tr>
<td rowspan="3" valign = "top">
<img src="images/MKtemplate_02.gif" width="242" height="299" border="0" usemap="#Map">
<map name="Map">
  <area shape="rect" coords="134,90,175,101" href="index.php">
  <area shape="rect" coords="119,116,195,127" href="join.php">
  <area shape="rect" coords="115,144,199,156" href="rules.php">
  <area shape="rect" coords="117,171,195,183" href="faqs.php">
  <area shape="rect" coords="89,199,222,210" href="z10.invisionfree.com/MKS" target = "_blank">
  <area shape="rect" coords="88,224,225,235" href="credits.php">
  <area shape="rect" coords="81,252,237,264" href="nations.php">
  <area shape="rect" coords="123,279,192,291" href="mkmap.php">
</map>
</td>
<td background = "images/MKtemplate_03.gif" width="658" height="53" align = "center"><h3>Join English</h3></td>
<td>
	<img src="spacer.gif" width="1" height="53" alt=""></td>
</tr>
<tr>
<td background = "images/MKtemplate_04.gif" width="658" height="224" align = "center" valign = "top" style = "background-repeat:repeat-y;"><?php print "$display"; ?></td>
<td><img src="spacer.gif" width="1" height="224" alt=""></td>
</tr>
<tr>
<td rowspan="2" background = "images/MKtemplate_05.gif" width="658" height="55" align = "center" valign = "top">[<a href = "index.php">Home</a>] [<a href = "join.php">Join M.K.</a>] [<a href = "rules.php">M.K. Rules</a>] [<a href = "faqs.php">M.K. FAQs</a>] [<a href = "z10.invisionfree.com/MKS" target = "_blank">M.K. Forums</a>] [<a href = "credits.php">M.K. Credits</a>] [<a href = "nations.php">Nations</a>] [<a href = "mkmap.php">M.K. Map</a>]<br>[[<a href = "rdrvision.com" target = "_blank">RDRvision</a>]] ---- [<a href = "admin_login.php">Admin.</a>]       Version 1.0    </td>
<td><img src="spacer.gif" width="1" height="22" alt=""></td>
</tr>
<tr>
<td background = "images/MKtemplate_06.gif" width="242" height="33" align = "center" valign = "top" style = "background-position:top; background-repeat:repeat-y;">
</td>
<td><img src="spacer.gif" width="1" height="33" alt=""></td>
</tr>
</table>
</center>
</body>
</html>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.