AshleighCo Posted August 31, 2013 Share Posted August 31, 2013 I have searched over 1500 posts over the last 2 weeks and have not found the solution to make my code work. My registration and login forms work correctly but when the user logins to add or edit information the sql database does not update with the users input and the error/updated message does not echo. My users register with name, surname, email and password but once they login they need to add to their personal information and later be able to edit the personal information. But nothing I've tried has worked... my code is as follows: <?phpinclude_once "connect_to_mysql.php";$id = $_SESSION['id']; if ($_POST['username']) {$title = $row["title"];$username = $row["username"];$surname = $row["surname"];$identityno = $row["identityno"];$gender = $row["gender"];$birthdate = strftime("%d %b %Y", strtotime($row["birthdate"]));$ethnicity = $row["ethnicity"];$nationality = $row["nationality"];$homeaddress = $row["homeaddress"];$province = $row["province"];$suburb = $row["suburb"];$hometele = $row["hometele"];$celltele = $row["celltele"];$creditclear = $row["creditclear"];$criminalrecord = $row["criminalrecord"];$driverslicense = $row["driverslicense"];$owntransport = $row["owntransport"];$medicalconditions = $row["medicalconditions"]; $sql = mysql_query("UPDATE cic_candidates SET title='$title', username='$username', surname='$surname', identityno='$identityno', gender='$gender', birthdate='$birthdate', ethnicity='$ethnicity', nationality='$nationality', homeaddress='$homeaddress', province='$province', suburb='$suburb', hometele='$hometele', celltele='$celltele', creditclear='$creditclear', criminalrecord='$criminalrecord', driverslicense='$driverslicense', owntransport='$owntransport', medicalconditions='$medicalconditions' WHERE id='$id'"); echo 'Your account info has been updated, you will now see the new info.<br /><br />To return to your profile edit area, <a href="edit_personal_details.php">click here</a>';exit();}?> Quote Link to comment https://forums.phpfreaks.com/topic/281725-user-input-not-being-addedupdated-to-sql-database/ Share on other sites More sharing options...
requinix Posted August 31, 2013 Share Posted August 31, 2013 (edited) PHPFreaks.com Questions, Comments, & Suggestions This is NOT a help forum! Do not post topics asking for help that are not related to the website. So where is $row defined? Edited August 31, 2013 by requinix Quote Link to comment https://forums.phpfreaks.com/topic/281725-user-input-not-being-addedupdated-to-sql-database/#findComment-1447529 Share on other sites More sharing options...
AshleighCo Posted August 31, 2013 Author Share Posted August 31, 2013 (edited) Will post full code... Edited August 31, 2013 by AshleighCo Quote Link to comment https://forums.phpfreaks.com/topic/281725-user-input-not-being-addedupdated-to-sql-database/#findComment-1447533 Share on other sites More sharing options...
AshleighCo Posted August 31, 2013 Author Share Posted August 31, 2013 <?phpinclude_once "connect_to_mysql.php";$id = $_SESSION['id']; if ($_POST['username']) {$title = $row["title"];$username = $row["username"];$surname = $row["surname"];$identityno = $row["identityno"];$gender = $row["gender"];$birthdate = strftime("%d %b %Y", strtotime($row["birthdate"]));$ethnicity = $row["ethnicity"];$nationality = $row["nationality"];$homeaddress = $row["homeaddress"];$province = $row["province"];$suburb = $row["suburb"];$hometele = $row["hometele"];$celltele = $row["celltele"];$creditclear = $row["creditclear"];$criminalrecord = $row["criminalrecord"];$driverslicense = $row["driverslicense"];$owntransport = $row["owntransport"];$medicalconditions = $row["medicalconditions"]; $sql = mysql_query("UPDATE cic_candidates SET title='$title', username='$username', surname='$surname', identityno='$identityno', gender='$gender', birthdate='$birthdate', ethnicity='$ethnicity', nationality='$nationality', homeaddress='$homeaddress', province='$province', suburb='$suburb', hometele='$hometele', celltele='$celltele', creditclear='$creditclear', criminalrecord='$criminalrecord', driverslicense='$driverslicense', owntransport='$owntransport', medicalconditions='$medicalconditions' WHERE id='$id'"); echo 'Your account info has been updated, you will now see the new info.<br /><br />To return to your profile edit area, <a href="edit_personal_details.php">click here</a>';exit();}?> Quote Link to comment https://forums.phpfreaks.com/topic/281725-user-input-not-being-addedupdated-to-sql-database/#findComment-1447535 Share on other sites More sharing options...
requinix Posted August 31, 2013 Share Posted August 31, 2013 Yep, that's the same code you posted earlier alright. Congratulations on that? What is $row supposed to be? The new values from the form? Then shouldn't it be $_POST instead? I'm going to bed. If someone picks up from where I'm leaving off, remember to mention the SQL injection too. Quote Link to comment https://forums.phpfreaks.com/topic/281725-user-input-not-being-addedupdated-to-sql-database/#findComment-1447537 Share on other sites More sharing options...
AshleighCo Posted August 31, 2013 Author Share Posted August 31, 2013 Okay....I have checked many online options and now have the following code with the following error: Fatal error: Function name must be a string....this refers to this line of my code: $query("UPDATE cic_candidates SET title='$title' Code: <?phpinclude_once "connect_to_mysql.php"; $id = $_SESSION['id']; $title=$_POST['title'];$username=$_POST['username'];$surname=$_POST['surname'];$identityno=$_POST['identityno'];$gender=$_POST['gender']; $birthdate=$_POST['birthdate'];$ethnicity=$_POST['ethnicity'];$nationality=$_POST['nationality'];$homeaddress=$_POST['homeaddress'];$province=$_POST['province'];$suburb=$_POST['suburb'];$hometele=$_POST['hometele'];$celltele=$_POST['celltele'];$creditclear=$_POST['creditclear'];$criminalrecord=$_POST['criminalrecord'];$driverslicense=$_POST['driverslicense'];$owntransport=$_POST['owntransport'];$medicalconditions=$_POST['medicalconditions']; $query("UPDATE cic_candidates SET title='$title', username='$username', surname='$surname', identityno='$identityno', gender='$gender', birthdate='$birthdate', ethnicity='$ethnicity', nationality='$nationality', homeaddress='$homeaddress', province='$province', suburb='$suburb', hometele='$hometele', celltele='$celltele', creditclear='$creditclear', criminalrecord='$criminalrecord', driverslicense='$driverslicense', owntransport='$owntransport', medicalconditions='$medicalconditions' WHERE id='$id'");mysql_query($query); echo 'Your account info has been updated, you will now see the new info.<br /><br />To return to your profile edit area, <a href="edit_personal_details.php">click here</a>';exit();mysql_close(); ?> Quote Link to comment https://forums.phpfreaks.com/topic/281725-user-input-not-being-addedupdated-to-sql-database/#findComment-1447551 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.