pixeltrace Posted April 20, 2007 Share Posted April 20, 2007 guys, i need help on my update page. i dont know what happened here because it was working before i gave it to my client, now they came back to me at told me that the update page is not working. i double checked already but i can't find whats wrong. below is the codes for my update form page <? session_start(); if (session_is_registered("username")){ //$username = $_POST['username']; $uid = $_GET[uid]; include '../db_connect.php'; $query = mysql_query("SELECT * FROM admin_user WHERE userid= '$uid'") or die(mysql_error()); $row = mysql_fetch_array( $query ); $uid = $row["userid"]; $uname = $row["username"]; $password = $row["password"]; $fname = $row["first_name"]; $lname = $row["last_name"]; $jobtitle = $row["job_title"]; $email = $row["email"]; $userlevel = $row["user_level"]; ?> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>:: JobHiRings :: Administration Page</title> <link href="../css.css" rel="stylesheet" type="text/css"> </head> <body> <table width="712" border="0" cellspacing="0" cellpadding="0"> <tr> <td colspan="3" align="right"><a href="add.php" class="link2">add new user account </a> | <a href="view.php" class="link2">view user lists </a> </td> </tr> <tr> <td colspan="3"><img src="../images/spacer.gif" width="710" height="6"></td> </tr> <tr> <td width="6"><img src="../images/spacer.gif" width="6" height="10" /></td> <td width="700"><table width="216" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td colspan="3" valign="top" bgcolor="#3261BB"><img src="images/spacer.gif" width="1" height="1"></td> </tr> <tr> <td align="left" bgcolor="#3261BB" width="1"><img src="images/spacer.gif" width="1" height="1"></td> <td width="214" valign="top"><form action="update.php" method="post"> <table width="460" border="0" cellspacing="2" cellpadding="0"> <tr> <td colspan="3" valign="top"><img src="../images/spacer.gif" width="1" height="1"></td> </tr> <tr> <td colspan="3" bgcolor="#999999"> </td> </tr> <tr> <td colspan="3" valign="top"><img src="../images/spacer.gif" width="1" height="1"></td> </tr> <tr> <td width="137" align="right" class="text6">account ID : </td> <td> </td> <td class="text7">USR<? echo "$uid"; ?></td> </tr> <tr> <td align="right" class="text6">username : </td> <td width="7" rowspan="2"> </td> <td width="308"><input type="text" name="uname" value="<? echo "$uname"; ?>" class="textfield"></td> </tr> <tr> <td align="right" class="text6">first name : </td> <td width="308"><input type="text" name="fname" value="<? echo "$fname"; ?>" class="textfield"></td> </tr> <tr> <td align="right" class="text6">last name :</td> <td rowspan="2"> </td> <td><span class="text7"> <input type="text" name="lname" value="<? echo "$lname"; ?>" class="textfield"> </span></td> </tr> <tr> <td align="right" class="text6">job title :</td> <td><span class="text7"> <input type="text" name="jobtitle" value="<? echo "$jobtitle"; ?>" class="textfield"> </span></td> </tr> <tr> <td align="right" class="text6">email address : </td> <td> </td> <td><span class="text7"> <input type="text" name="email" value="<? echo "$email"; ?>" class="textfield"> </span></td> </tr> <tr> <td align="right" class="text6">user level : </td> <td> </td> <td><span class="text7"> <input name="userlevel" type="radio" value="administrator" <? if ($userlevel == 'administrator'){ echo "checked";}?>> </span><span class="text8">Administrator</span><span class="text7"> <input name="userlevel" type="radio" value="staff" <? if ($userlevel == 'staff'){ echo "checked";}?>> </span><span class="text8">Staff</span></td> </tr> <tr> <td> </td> <td> </td> <td> </td> </tr> <tr> <td align="right" class="text6">change password : </td> <td> </td> <td> </td> </tr> <tr> <td align="right" class="text6">new : </td> <td> </td> <td><input name="newpasswd" type="password" class="textfield"></td> </tr> <tr> <td align="right" class="text6">confirm new password : </td> <td> </td> <td><input name="newpasswd2" type="password" class="textfield"></td> </tr> <tr> <td rowspan="2"> </td> <td rowspan="2"> </td> <td><input name="update" type="submit" value="update acount"></td> </tr> <tr> <td><input name="uid" type="hidden" value="<? echo "$uid"; ?>"> <input name="password" type="hidden" value="<? echo "$password"; ?>"></td> </tr> </table> </form></td> <td align="right" bgcolor="#3261BB" width="1"><img src="images/spacer.gif" width="1" height="1"></td> </tr> <tr> <td colspan="3" valign="top" bgcolor="#3261BB"><img src="images/spacer.gif" width="1" height="1"></td> </tr> </table></td> <td width="6"><img src="../images/spacer.gif" width="6" height="10" /></td> </tr> </table> <? }else{ echo "<font face=\"Arial\">You are not authorized to access this page ... Please <a href='index.php'>Login</a></font>"; } ?> </body> </html> and this is the code for my update.php <?php session_start(); if (session_is_registered("username")){ }else{ echo "<font face=\"Arial\">You are not authorized to access this page ... Please <a href='index.php'>Login</a></font>"; } include '../db_connect.php'; $uid = $_POST['uid']; $uname = $_POST['uname']; $password = $_POST['password']; $fname = $_POST['fname']; $lname = $_POST['lname']; $jobtitle = $_POST['jobtitle']; $email = $_POST['email']; $userlevel = $_POST['userlevel']; $newpasswd = $_POST['newpasswd']; $newpasswd2 = $_POST['newpasswd2']; print_r($_POST); if ($newpasswd == ''){ $password = $password; } elseif($newpasswd == $newpasswd2){ $password = md5($newpasswd); $sql="UPDATE admin_user SET username ='$uname', first_name='$fname', last_name='$lname', job_title='$jobtitle', email='$email', user_level='$userlevel', password='$password' WHERE userid='$uid'"; mysql_query($sql) or die("error:".mysql_error()); print_r($sql); echo '<script language=javascript> alert("account has been updated!");window.location = "view.php";</script>'; }else{ echo '<script language=javascript>alert("Password does not match!");window.location = "view.php";</script>'; exit(); } ?> hope you could help me fix this. thanks! Quote Link to comment https://forums.phpfreaks.com/topic/47842-solved-help-on-my-update-page/ Share on other sites More sharing options...
tauchai83 Posted April 20, 2007 Share Posted April 20, 2007 what is the error message that you get? i notice some line with weird character. mysql_query($sql) or die("error:".mysql_error()); print_r($sql);xx what's that actually? Quote Link to comment https://forums.phpfreaks.com/topic/47842-solved-help-on-my-update-page/#findComment-233778 Share on other sites More sharing options...
tauchai83 Posted April 20, 2007 Share Posted April 20, 2007 <?php session_start(); if (session_is_registered("username")){ }else{ echo "<font face=\"Arial\">You are not authorized to access this page ... Please <a href='index.php'>Login</a></font>"; } include '../db_connect.php'; $uid = $_POST['uid']; $uname = $_POST['uname']; $password = $_POST['password']; $fname = $_POST['fname']; $lname = $_POST['lname']; $jobtitle = $_POST['jobtitle']; $email = $_POST['email']; $userlevel = $_POST['userlevel']; $newpasswd = $_POST['newpasswd']; $newpasswd2 = $_POST['newpasswd2']; print_r($_POST); if ($newpasswd == ''){ $password = $password; } elseif($newpasswd == $newpasswd2){ $password = md5($newpasswd); $sql="UPDATE admin_user SET username ='$uname', first_name='$fname', last_name='$lname', job_title='$jobtitle', email='$email', user_level='$userlevel', password='$password' WHERE userid='$uid'"; $result=mysql_query($sql) or die("error:".mysql_error()); if($result){ echo '<script language=javascript> alert("account has been updated!");window.location = "view.php";</script>'; } }else{ echo '<script language=javascript>alert("Password does not match!");window.location = "view.php";</script>'; exit(); } ?> try this and see Quote Link to comment https://forums.phpfreaks.com/topic/47842-solved-help-on-my-update-page/#findComment-233779 Share on other sites More sharing options...
pixeltrace Posted April 20, 2007 Author Share Posted April 20, 2007 its working now thanks! Quote Link to comment https://forums.phpfreaks.com/topic/47842-solved-help-on-my-update-page/#findComment-233787 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.