adamjones Posted October 22, 2008 Share Posted October 22, 2008 Ok. I have a page which calls information from the database. When you update a user, it redirects to this form, depending on the ID: <?php $host="localhost"; $username="wowdream_domaine"; $password="pass"; $db_name="wowdream_domaine"; $tbl_name="members"; mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $id=$_GET['id']; $sql="SELECT * FROM $tbl_name WHERE id='$id'"; $result=mysql_query($sql); $rows=mysql_fetch_array($result); ?> <form name="form1" method="post" action="update_ac.php"> <fieldset> <label>Username:</label> <input class="small" name="uname" type="text" id="uname" value="<? echo $rows['username']; ?>"> <br class="hid" /> <br class="hid" /> <label>Password:</label> <input class="small" name="pass" type="password" id="pass" value="<? echo $rows['password']; ?>"> <br class="hid" /> <br class="hid" /> <label>Rank:</label> <input class="small" name="access" type="text" id="access" value="<? echo $rows['access']; ?>" size="15"> <br class="hid" /> <br class="hid" /> <label>Real Name:</label> <input class="small" name="name" type="text" id="name" value="<? echo $rows['name']; ?>"> <br class="hid" /> <br class="hid" /> <label>E-Mail:</label> <input class="small" name="email" type="text" id="email" value="<? echo $rows['email']; ?>"> <br class="hid" /> <br class="hid" /> <label>Contact Number:</label> <input class="small" name="number" type="text" id="number" value="<? echo $rows['number']; ?>"> <br class="hid" /> <br class="hid" /> <br class="hid" /> <br class="hid" /> <br class="hid" /> <br class="hid" /> <br class="hid" /> <br class="hid" /> <br /><br /><br /><br /> <a href="#" class="button submit" title="Submit"><span>Update</span></a> <span class="clear"></span> </fieldset> </form><?php mysql_close(); ?> Which posts information to; <?php $host="localhost"; $username="wowdream_domaine"; $password="pass"; $db_name="wowdream_domaine"; $tbl_name="members"; mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $id=$_GET['id']; $uname=$_POST['uname']; $pass=$_POST['pass']; $access=$_POST['access']; $name=$_POST['name']; $email=$_POST['email']; $number=$_POST['number']; $sql="UPDATE $tbl_name SET username='$uname', password='$pass', access='$access', name='$name', email='$email', number='$number' WHERE id='$id'"; $result=mysql_query($sql); if($result){ header("location:editadmindone.php"); } else { header("location:editadminerror.php"); } ?> I'm calling the information from the form, my database info is correct. Im just puzzled as to why it's redirecting to 'editadmindone.php', and not actually updating the database! Quote Link to comment https://forums.phpfreaks.com/topic/129614-solved-form-isnt-posting-information-to-my-database/ Share on other sites More sharing options...
rhodesa Posted October 22, 2008 Share Posted October 22, 2008 $_GET['id'] won't get passed like that....try this: <form name="form1" method="post" action="update_ac.php?id=<?php echo $id?>"> Quote Link to comment https://forums.phpfreaks.com/topic/129614-solved-form-isnt-posting-information-to-my-database/#findComment-671966 Share on other sites More sharing options...
adamjones Posted October 22, 2008 Author Share Posted October 22, 2008 Cheers. All working now. Quote Link to comment https://forums.phpfreaks.com/topic/129614-solved-form-isnt-posting-information-to-my-database/#findComment-671970 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.