fazlionline Posted June 1, 2009 Share Posted June 1, 2009 I have a database of users, they have filled the form.Now they want to update their information.I want the user should change all of his information, if the user name & pass in the form (is equal to ) user name & pass in the database.This code is not working: <?php// Make a MySQL Connection// Insert a row of information into the table "abcxyz"mysql_query("UPDATE abcxyz SET regname = '$_POST[updname]', regdob = '$_POST[upddob]', regdomi = '$_POST[upddomi]', regmob = '$_POST[updmob]' , regcountry = '$_POST[updcountry]', regcity = '$_POST[updcity]', regposition '$_POST[updposition]', regorg = '$_POST[updorg]', regpro = '$_POST[updpro]', regedu = '$_POST[updedu]', regemail = '$_POST[updemail]', WHERE regid = '$_POST[updemail]' AND regpass = '$_POST[updemail]'");echo "Data Updated!";?>Thanks Link to comment Share on other sites More sharing options...
Synook Posted June 1, 2009 Share Posted June 1, 2009 In what way is it "not working"? Also, you should sanitize your data. Link to comment Share on other sites More sharing options...
fazlionline Posted June 1, 2009 Author Share Posted June 1, 2009 it is not updating the record Link to comment Share on other sites More sharing options...
deved Posted June 1, 2009 Share Posted June 1, 2009 Hard to say without seeing the database, but did you mean for the values in regemail, regid & regpass to be the same? Link to comment Share on other sites More sharing options...
justsomeguy Posted June 1, 2009 Share Posted June 1, 2009 WHEREregid = '$_POST[updemail]' AND regpass = '$_POST[updemail]'Is it correct to have the email address for both the ID and pass? Link to comment Share on other sites More sharing options...
fazlionline Posted June 2, 2009 Author Share Posted June 2, 2009 my HTML code is this: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>fazlionline</title><link href="school.css" rel="stylesheet" type="text/css" /><style type="text/css"><!--.style3 {color: #FF0000; font-weight: bold; }--></style></head><body><table border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td><form id="form1" name="form1" method="post" action="03_update_record.php"> <table border="1" cellpadding="7" cellspacing="3" bordercolor="#990000"> <tr> <td colspan="3" align="center"><p><a href="04_retrieve_data.php">View Other Records</a></p></td> </tr> <tr> <td height="75" colspan="3" align="center" bgcolor="#FF9900"><h1>Update Your Information</h1></td> </tr> <tr> <td width="137" align="right">Full Name:</td> <td><label> <input type="text" name="updname" id="updname" /> </label></td> <td>Write yo full name with nick name</td> </tr> <tr> <td width="137" align="right">ID:</td> <td><label> <input type="text" name="updid" id="updid" /> </label></td> <td><span class="style3">OLD ID</span></td> </tr> <tr> <td align="right">Password:</td> <td><label> <input type="password" name="updpass" id="updpass" /> </label></td> <td><span class="style3">OLD PASSWARD</span></td> </tr> <tr> <td align="right">Bate of Birth:</td> <td><label> <input type="text" name="upddob" id="upddob" /> </label></td> <td> Date - Month - Year</td> </tr> <tr> <td align="right">Domicile</td> <td><label> <input type="text" name="upddomi" id="upddomi" /> </label></td> <td>The place where you parents lived</td> </tr> <tr> <td align="right">Mobile Numbers:</td> <td><label> <input type="text" name="updmob" id="updmob" /> </label></td> <td>You can enter two mobile numbers, separate them with " / " .</td> </tr> <tr> <td align="right">Country:</td> <td><label> <input type="text" name="updcountry" id="updcountry" /> </label></td> <td>The Country you live now</td> </tr> <tr> <td align="right">State/Province/City:</td> <td><label> <input type="text" name="updcity" id="updcity" /> </label></td> <td>The State/province/City you live now</td> </tr> <tr> <td align="right">Position</td> <td><input type="text" name="updposition" id="updposition" /></td> <td>Your Job Position</td> </tr> <tr> <td align="right">Organization Name::</td> <td><label> <input type="text" name="updorg" id="updorg" /> </label></td> <td>Name of the Organization you work in</td> </tr> <tr> <td align="right"><p>Profession:</p> </td> <td><label> <input type="text" name="updpro" id="updpro" /> </label></td> <td>What is your profession, what are you expert in?</td> </tr> <tr> <td align="right">Education Level:</td> <td><label> <input type="text" name="updedu" id="updedu" /> </label></td> <td>Your highest education level</td> </tr> <tr> <td align="right">Email:</td> <td><label> <input type="text" name="updemail" id="updemail" /> </label></td> <td>The email address you use/check most.</td> </tr> <tr> <td height="50" colspan="3" align="center" bgcolor="#FF9900"><label> <input type="submit" name="button" id="button" value="Submit Your Information" /> </label></td> </tr> </table> </form> </td> </tr></table></body></html>and my php page have this code:<?php// Make a MySQL Connection// Insert a row of information into the table "abcxyz"mysql_query("UPDATE abcxyz SET regname = '$_POST['updname']', regdob = '$_POST['upddob']', regdomi = '$_POST['upddomi']', regmob = '$_POST['updmob']' , regcountry = '$_POST['updcountry']', regcity = '$_POST['updcity']', regposition '$_POST['updposition']', regorg = '$_POST['updorg']', regpro = '$_POST['updpro']', regedu = '$_POST['updedu']', regemail = '$_POST['updemail']', WHERE regid = '$_POST['updemail']' AND regpass = '$_POST['updemail']'");echo "Data Updated!";?>Now I want, if a user wants to update his information, he will fill this form.And the code will check if the user ID (regid) given is equal to the user ID in the table abcxyz AND the user password (regpass) in the form is equal to the user password (regpass) in the table abcxyz, then all the information should be updated,AND ifregid in the form AND regpass in the form does not match the regid in the table AND regpass in the table, then no update will happen.That is all.Thank Link to comment Share on other sites More sharing options...
deved Posted June 2, 2009 Share Posted June 2, 2009 I'm pretty sure it's because you have two single parenthesis in the one string ie. '$_POST['updname']' instead of "$_POST['updname']". I'd assign a variable to the posted value such as: $updname = $_POST['updname'] and use the variable instead. Hope that makes sense. Link to comment Share on other sites More sharing options...
justsomeguy Posted June 2, 2009 Share Posted June 2, 2009 How about you just print out the SQL query to see what you're telling the database to do? Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.