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

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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