Jump to content

Having some problems with an update query


davelearning

Recommended Posts

Hi all,

 

Firstly here is my code

<?php 
if (isset($_POST['update']))
{
include('../config.php');
$name = $_POST['name'];
$email = $_POST['email'];
$id = $_POST['id'];

$uquery=mysql_query("UPDATE customers SET name='$name' AND email='$email' WHERE id='$id'");
if($uquery)
{
	echo mysql_error();
}

else

{
	echo mysql_error();
}
}
?>


<link href="../styles/clientbox.css" rel="stylesheet" type="text/css">
<link href="cancelform.css" rel="stylesheet" type="text/css" />
<link href="../styles/form_dark.css" rel="stylesheet" type="text/css" />
<body><br>
<h3>My Details</h3>
<div class="text">
Please keep your details updated below, for security reasons you cannot change your password.<br>
<?php 
$id = $_GET['id'];
include('../config.php');
$query=mysql_query("SELECT * FROM customers WHERE id='$id'");
while($row = mysql_fetch_assoc($query))
  				{
					$name = $row['name'];
					$email = $row['email'];

				}
				?>
<form class="dark" action="" method="post">
  <ol>
    <li>
      <fieldset>
        <legend>My Details</legend>
        <ol>
          <li>
            <label for="name">Account Holder</label>
            <input type="text" id="name" name="name" value="<?php echo $name;?>" />
          </li>
          <li>
            <label for="email">Contact/Login Email Address</label>
            <input type="text" id="email" name="email" value="<?php echo $email;?>" />
            <input type="hidden" id="id" name="id" value="<?php echo $id;?>" />
          </li>
        </ol>
      </fieldset>
    </li>
  </ol>
  <p style="text-align:right;">
    <input type="reset" value="CANCEL" />
    <input type="submit" value="UPDATE" name="update" />
  </p>
</form>

 

Basically what is happening is that whatever you enter into the name box returns a 0 if its text or 1 if numbers are entered as opposed to storing the value inputed, if the email address is changed then nothing happens at all.

 

Can someone see if I have made a noob mistake somewhere? The name and email fields are both varchar(256) in my database

 

Thanks

 

Archived

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

×
×
  • 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.