OK, I literally jumped into PHP tonight. Ive been going for about 6 hours now. All i did before this was include scripts. Im making a admin page for my site to quickly update my members. I have everything working fine. Adding people, viewing them, etc. The edit and update page are killing me though. Heres the script for my edit page:
PHP Code:
<?
$id = $_GET['id'];
$username="afh_um";
$password="*****";
$db = mysql_connect("localhost", $username,$password );
mysql_select_db("afh_umblah",$db);
$result = mysql_query("SELECT * FROM members WHERE id='$id'",$db);
$num=mysql_numrows($result);
mysql_close();
$name=mysql_result($result,$i,"name");
$rank=mysql_result($result,$i,"rank");
$char=mysql_result($result,$i,"char");
$aka=mysql_result($result,$i,"aka");
$recby=mysql_result($result,$i,"recby");
echo "<b><center>Editing $name</b><br><br>";
echo "<form action=update.php method=post><input type=hidden name=ud_id value=$id><br>Name: <br><textarea name=ud_name>$name</textarea><br>Rank: <br> <input type=text maxlength=50 value=$rank name=ud_rank><br>Char: <br><input type=text maxlength=50 value=$char name=ud_char><br>AKA's: <br><input type=text maxlength=200 value=$aka name=ud_aka><br>Recruited By: <br><input type=text maxlength=50 value=$recby name=ud_recby><br><br><input type=submit value=Update></center>";
?>
works fine. the website adress is something like edit.php?id=### and then it retrieves and uses that to pull the other info. Another problem I had here was that I wanted to display the info in text inputs and it would only display the first word. Thats why you see the textarea. Any help with that also would be generous. So I'm guessing thats working fine, so then when your done editing, it submits to this, my update.php page:
PHP Code:
<?
$ud_id=$_POST['ud_id'];
$ud_name=$_POST['ud_name'];
$ud_rank=$_POST['ud_rank'];
$ud_char=$_POST['ud_char'];
$ud_aka=$_POST['ud_aka'];
$ud_recby=$_POST['ud_recby'];
$username="afh_um";
$password="*****";
$db = mysql_connect("localhost", $username,$password );
mysql_select_db("afh_umblah",$db);
$query="UPDATE members SET name='$ud_name', rank='$ud_rank', char='$ud_char', aka='$ud_aka', recby='$ud_recby' WHERE id='$ud_id'";
mysql_query($query);
echo "Record Updated";
mysql_close();
?>
It says Record Updated, I go back to view the changed info, still the same. Refresh about 50 times out of anger, still the same. Any help will be appreciated. Thanks.
-Shiv