Jump to content

Archived

This topic is now archived and is closed to further replies.

adamjones

[SOLVED] Form isn't posting information to my database.

Recommended Posts

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!

 

Share this post


Link to post
Share on other sites

$_GET['id'] won't get passed like that....try this:

 

<form name="form1" method="post" action="update_ac.php?id=<?php echo $id?>">

Share this post


Link to post
Share on other sites

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.