adamjones Posted December 4, 2008 Share Posted December 4, 2008 Hi. I'm making a settings page where users can update their info, however, when submitting the form, it's just overwriting the old details with nothing... This is my code; <?php $host="localhost"; $username="designby_x"; $password="password"; $db_name="designby_x"; $tbl_name="members"; mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $name=$_GET['myusername']; $sql="SELECT * FROM $tbl_name WHERE username='$myusername'"; $result=mysql_query($sql); $rows=mysql_fetch_array($result); ?> <form name='form1' method='send' action='update_ac.php' id='formular' class='formular' rel='facebox'> <fieldset> <legend>Account Info</legend> <label> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="52%"><div align="left"><b>Your Password</b>:</div></td> <td width="48%"><div align="left"> <label> <input name="pass" type="password" id="pass" value="<? echo $rows['password']; ?>" /> </label> </div></td> </tr> </table> </fieldset></label> <fieldset> <legend>Personal Info</legend> <label> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="52%"><div align="left"><b>Name</b>:</div></td> <td width="48%"><div align="left"> <label> <input name="name" type="text" id="name" value="<? echo $rows['name']; ?>" /> </label> </div></td> </tr> <tr> <td><div align="left"><b>E-Mail address:</b></div></td> <td><div align="left"> <label> <input name="email" type="text" id="email" value="<? echo $rows['email']; ?>" /> </label> </div></td> </tr> </table> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="22%"><label> <input type="submit" name="submit" id="submit" value="Update" /> </label></td> <td width="78%"><label> <input type="reset" name="Reset" id="Reset" value="Reset" /> </label></td> </tr> </table> <p> <label></label> (If you are having troubles clicking in the boxes, please use the 'tab' button, on your keyboard)</p> </fieldset> </form> This is update_Ac.php; <? session_start(); if(!session_is_registered(myusername)){ header("location:index.php"); } ?> <?php $host="localhost"; $username="designby_x"; $password="password"; $db_name="designby_x"; $tbl_name="members"; $name=$_POST['name']; $pass=$_POST['pass']; $email=$_POST['email']; mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $sql="UPDATE $tbl_name SET name='$name', password='$pass', email='$email' WHERE username='$myusername'"; $result=mysql_query($sql); if($result){ header("location:updated.php"); } else { header("location:editadminerror.php"); } ?> Can anyone see the problem? Cheers, Adam. Link to comment https://forums.phpfreaks.com/topic/135527-solved-my-code-isnt-updating-the-database/ Share on other sites More sharing options...
revraz Posted December 4, 2008 Share Posted December 4, 2008 echo $sql and check the result put mysql_error() after your query to check for errors Link to comment https://forums.phpfreaks.com/topic/135527-solved-my-code-isnt-updating-the-database/#findComment-706011 Share on other sites More sharing options...
Mchl Posted December 4, 2008 Share Posted December 4, 2008 Change method to "post" in your form Link to comment https://forums.phpfreaks.com/topic/135527-solved-my-code-isnt-updating-the-database/#findComment-706013 Share on other sites More sharing options...
adamjones Posted December 4, 2008 Author Share Posted December 4, 2008 Ah. Didn't see I had it set to send. Cheers. Link to comment https://forums.phpfreaks.com/topic/135527-solved-my-code-isnt-updating-the-database/#findComment-706023 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.