Jump to content

Need concept help or help with this coding please


Attila

Recommended Posts

OK all I am trying to create a very simple blog for members of my online video game guild.  I know that sessions would be the best way to go but it is not anything that is extreamly critical for passwords sensativity.

 

So what I am doing is in the database I will hard code there user name and password.  I have the members go to one page to login.  You can see that page here: http://thaczero.com/memberslog.php Useer name is Test and Password is Test

 

Since I am being lazy after you enter I am using $_POST['Uname'] and $_POST['Password'] inside a link to get to the page the member can use to adjust their data such as Main character name and their blog information.

 

This is where my problem is.  The first php code below here is the form and method to get it to display.  It also displays what they have in the database and provides them text blocks to adjust what is in the database if they with plus add more blog information.

 

So this part quiries the database with the information from the previus page for user and password

 

<? 
<? 

include ('includes/thacoheader.php');
include ('includes/allfunctions.php');

if ($count != "1") 
{

$sql = "SELECT * FROM `Character` WHERE `user` = \"$_GET[uname]\" AND `password` =  \"$_GET[Password]\"";
database_connected();
$result = mysql_query($sql) or die(mysql_error());
$num_rows = mysql_num_rows($result);
while($row = mysql_fetch_array($result)) 
{  
$count = 1;
$uname = $_GET['Uname'];
$pass = $_GET['Password'];
$img = $row['picture'];
$rname = $row['realname'];
$toon = $row['maintoonsname'];
$loc = $row['location'];
$tim = $row['timezone'];
$ptim = $row['playtime'];
$origblog = $row['blog'];
} //end to the while loop
}
?>
<p align="center"><img src="<? echo $img; ?>"></p>
<?
$top_form = "<form method=\"post\" action=\"$_SERVER[php_SELF]\">

<table align=\"center\">
<tr class=\"cindex\">
    	<td>Field Name</td>
	<td>Whats in the Database</td>
	<td>This is the colum you edit</td>
	<td>Notes</td>
  </tr>
<tr class=\"cindex\">
    	<td>Real Name:</td>
	<td>$rname</td>
	<td><input name=\"textfield\" type=\"text\" name=\"realname\" size=\"30\" maxlength=\"30\" value=\"$_POST[realname]\"/></td>
	<td>This can only be up to 30 Characters long with no spaces just your first name.</td>
  </tr>
<tr class=\"cindex\">
    	<td>Main Toons Name:</td>
	<td>$toon </td>
	<td><input name=\"textfield\" type=\"text\" name=\"maintoonsname\" size=\"30\" maxlength=\"30\" value=\"$_POST[maintoonsname]\"/></td>
	<td>This can only be up to 30 Characters long with no spaces just your characters first name.</td>
  </tr>
<tr class=\"cindex\">
    	<td>Location:</td>
	<td>$loc</td>
	<td><input name=\"textfield\" type=\"text\" name=\"location\" size=\"30\" maxlength=\"30\" value=\"$_POST[location]\"/></td>
	<td>This can only be up to 30 Characters long and it is where you live.</td>
  </tr>
<tr class=\"cindex\">
    	<td>Time Zone:</td>
	<td>$tim</td>
	<td><input name=\"textfield\" type=\"text\" name=\"timezone\" size=\"30\" maxlength=\"30\" value=\"$_POST[timezone]\"/></td>
	<td>What time zone do you live in?</td>
  </tr>
<tr class=\"cindex\">
   	<td>Play time:</td>
	<td>$ptim</td>
	<td><input name=\"textfield\" type=\"text\" name=\"playtime\" size=\"30\" maxlength=\"30\" value=\"$_POST[playtime]\"/></td>		
	<td>What time of day do you usually play?</td>
  </tr>
<tr class=\"cindex\">
   	<td colspan=\"4\">Blog:</td>
  </tr>
    </tr>
<tr class=\"cindex\">
   	<td colspan=\"4\"><p>Just add more of your blog information at the top here.  
If you delete any data here and submit it will be lost.  
This data is going to be parsed with BBC code.  So some things that you can do to spruce up your coding look like this:  	
  </p>
  <p>This is for Bold					[b][/b]
  <br>	    
    This is for italix					[i][/i]
    <br>
    This is for underline				[u][/u]
    <br>
    This is for a hyperlink				[url][/url]
    <br>
    This is to align left				[align=left][/align]
    <br>
    This is to align center				[align=center][/align]
    <br>
    This is to align right				[align=right[/align]
        <br>
        This is for an image			    [img][/img] </p>
  <br>
  You will need to put your text between those tags so they will work.  
If you accidantly screwed up on what you are adding and want to start over please 
go to another web address like www.thaczero.com then relog back in so you will not loose what you already have in the database.
  </td>
  </tr>

<tr class=\"cindex\">
<td colspan=\"2\" valign=\"top\">$origblog
<td colspan=\"2\"><div align=\"center\"><textarea name=\"blog\" cols=\"75\" rows=\"30\">$_POST[blog]</textarea></div>
</tr>
</tr>
  </tr>
<tr class=\"cindex\">
   	<td colspan=\"4\"><div align=\"center\">
   	  <input type=\"submit\" name=\"Submit\" value=\"Submit\" />
      <input type=\"hidden\" name=\"op\" value=\"ds\">
	  </div></td>
  </tr>
</table>
</form>";

 

Next after they have made an update I use the following code to update the database.  This is the part that is not working:

 

if ($_POST[op] != "ds") 
{ 
	// they need to see the form 
	echo $top_form; 
} 
else if ($_POST[op] == "ds") 
	{ 
	$blogging = $origblog.$_POST['blog'];

$query = ("UPDATE `charactedatabase` SET `maintoonsname` = '$_POST[maintoonsname]' 
, `location` = '$_POST[location]' 
, `timezone` = '$_POST[timezone]' 
, `playtime` = '$_POST[playtime]' 
, `blog` = '$blogging'
WHERE `user` = '$uname'");

mysql_query($query);

	echo "this is the realname:  ".$_POST["realname"]."<br>";
	echo "this is the toons name:  ".$_POST["maintoonsname"]."<br>";
	echo "this is the location:  ".$_POST["location"]."<br>";
	echo "this is the timezone:  ".$_POST["timezone"]."<br>";
	echo "this is the playtime:  ".$_POST["playtime"]."<br>";
	echo "this is the blogging:  ".$blogging."<br>";
	echo "this is the username:  ".$uname."<br>";
	echo "this is the Password:  ".$Pass."<br>";
	echo "these are the variables<br>";
	echo $uname;
	echo "<br>";
	echo $pass;
	echo "<br>";
	echo $img;
	echo "<br>";
	echo $rname;
	echo "<br>";
	echo $toon;
	echo "<br>";
	echo $loc;
	echo "<br>";
	echo $tim;
	echo "<br>";
	echo $ptim;
	echo "<br>";
	echo $origblog;
	echo "<br>";
	exit;


	}
include ('includes/thacofooter.php');

 

I have all the echo statements in there to show me what the values of each item is and almost all of them ar NULL.  Am I echoing them wrong?  I know it is not updating the database because I look in the database and there are no changes.  Please any help would be greatly appreciated.  If you have coding that can make this happen easier I am willing to learn. 

 

Thanks for all you people do and all your help.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.