I dont know how. But finnaly I actually got SOME of this code working, (with a lot of help ofcourse).
Now it works. No errors. The password is checked just as it should and you are redirected just as it should. However it does not save the info to the database when updating. The query IS correct as i tried it in the phpMyAdmin, and there is nothing wrong with tha vars as I already checked them a cpl of hundred times.
Everything goes just as it should, and you even get redirected to the save sucessfull page. But it just doesnt save the damn info!
You can go to http://lorenscorn.net/guilds/editguild.php?id=31 and use the password 'viktor' to edit the info, and then go back again and see that the changes actually never took place.
<?
$conn = mysql_connect("localhost","****","*
****") or die("DIE");
mysql_select_db("lorens_sfs") or die('Failed to select db: ' .mysql_error());
$query = "SELECT name,abbrev,location,website,uosite,email,password,align,waring,rp,pk,pvp,faction,charter,id FROM guilds WHERE id = $id";
$result = mysql_query($query) or die('SELECT query failed.<BR>Error: ' . mysql_error() . '<BR>Query: ' . $query);
$info = mysql_fetch_array($result);
$name =$info['name'];
$abbrev =$info['abbrev'];
$charter = $info['charter'];
$location = $info['location'];
$website = $info['website'];
$uosite = $info['uosite'];
$rp = $info['rp'];
$pk = $info['pk'];
$pvp = $info['pvp'];
$faction = $info['faction'];
$alignment = $info['align'];
$waring = $info['waring'];
$email = $info['email'];
$password = $info['password'];
$id = $info['id'];
if (isset($save)) {
$passquery = "SELECT password FROM guilds WHERE id = $id";
$passresult = mysql_query($passquery) or die('SELECT query failed.<BR>Error: ' . mysql_error() . '<BR>Query: ' . $query);
$passw = mysql_fetch_array($passresult);
if ($pass == $passw['password']) {
$write = "UPDATE guilds SET name='$name', charter='$charter', abbrev='$abbrev', location='$location', website='$site', uosite='$uosite', rp='$rp', pk='$pk', pvp='$pvp', faction='$faction', align='$alignment', waring='$waring' WHERE id = $id";
$insert = mysql_query($write)or die('UPDATE query failed.<BR>Error: ' . mysql_error() . '<BR>Query: ' . $write);
header("Location: savedornot.php?page=saved&name=$name");
}
else {
header("Location: savedornot.php?page=passerror&id=$id&name=$name&charter=$charter&abbrev=$abbrev&location=$location&site=$site&uosite=$uosite");
}
}
?>
<form method="post" action="editguild.php?id=<? echo $id; ?>">
<p align="center">
<? echo $error; ?>
<br>
<br>
</p>
<table width="100%" border="0" class="contenttype" cellpadding="0" cellspacing="0">
<tr>
<td>
<p><b>*Name of the guild: </b> <br>
<input type="text" name="name" size="35" maxlength="40" value="<? echo $name; ?>">
<br>
<br>
<b>*Abbreviation: <br>
<input type="text" name="abbrev" size="35" maxlength="3" value="<? echo $abbrev; ?>">
<br>
</b><b><br>
Guild charter/description: </b><br>
<textarea name="charter" cols="35" rows="3"><? echo $charter ?>
</textarea>
<br>
<b><br>
** Location/operative area: <br>
<input type="text" name="location" size="35" maxlength="35" value="<? echo $location; ?>">
<br>
<br>
Website: <br>
<input type="text" name="site" size="35" maxlength="55" value="<? echo $website; ?>">
<br>
</b></p>
<p><b> UO website:<br>
<input type="text" name="uosite" size="35" maxlength="55" value="<? echo $uosite; ?>">
<br>
<br>
</b> <b><br>
*E-mail: <br>
<input type="text" name="email" size="35" maxlength="38" value="<? echo $email; ?>">
<br>
<br>
<input type="checkbox" name="rp" value="1">
Roleplaying<br>
<input type="checkbox" name="pk" value="1">
Player Killing<br>
<input type="checkbox" name="pvp" value="1">
PvP<br>
<input type="checkbox" name="faction" value="1">
Faction<br>
<br>
Alignment: <br>
<input type="radio" name="alignment" value="Good" checked>
Good
<input type="radio" name="alignment" value="Evil">
Evil
<input type="radio" name="alignment" value="Neutral">
" Neutral" <br>
<br>
Waring:<br>
<input type="radio" name="waring" value="Waring">
Waring
<input type="radio" value="Non-waring" checked name="waring">
Non-waring<br>
</b><span class="type"><br>
* Required fields<br>
<br>
</span><b><span class="contenttype">***
Password: </span></b><span class="type"><b><br>
<input type="text" name="pass" size="35" maxlength="7">
</b> <br>
<br>
** Dont be very specific when you enter
your guild area, as it will only mess
up the search results. Instead of writing
"northeast of Yew" or "turn
left after Jerry's", just enter
your closest town or area name.<br>
<br>
*** The password is required to edit
your guild info. </span><br>
<b><br>
<input type="submit" name="save" value="Submit">
Ahh well thankyou.. Changed it now however those nasty people need to know my host right?