Tunavis Posted April 29, 2013 Share Posted April 29, 2013 <?php include 'connect.php'; if(!isset($_POST['submit'])) { $q = "SELECT * FROM player_registration WHERE player_id = $_GET[player_id]"; $result = mysql_query($q); $person = mysql_fetch_array($result); } ?> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <table border="0" cellpadding="5" cellspacing="0"> <tbody> <tr> <td>Name</td><td><input type="text" name="inputname" value="<?php echo $person['name']; ?>" /></td></tr><br /> <tr> <td>Surname</td><td><input type="text" name="inputsurname" value="<?php echo $person['surname']; ?>" /></td></tr><br /> <tr> <td>Contact Number</td><td><input type="text" name="inputcontact_num" value="<?php echo $person['contact_number']; ?>" /></td></tr><br /> <tr> <td>Email</td><td><input type="text" name="inputemail" value="<?php echo $person['email']; ?>" /></td></tr><br /> <tr> <td>Position</td><td><input type="text" name="inputpos" value="<?php echo $person['position']; ?>" /></td></tr><br /> <tr> <td>Username</td><td><input type="text" name="inputusername" value="<?php echo $person['username']; ?>" /></td></tr><br /> <tr> <td>Password</td><td><input type="text" name="inputpassw" value="<?php echo $person['password']; ?>" /></td></tr><br /> <tr> <td><input type="hidden" name="player_id" value="<?php echo $_GET['player_id']; ?>" /></td></tr> <tr> <td><input type="submit" name="submit" value="Submit" /></td></tr> </tbody> </table> </form> <?php if(isset($_POST['submit'])) { $u = "UPDATE player_registration SET `name`='$_POST[inputname], `surname`='$_POST[inputsurname], `contact_number`='$_POST[inputcontact]', `email`='$_POST[inputemail]', `position`='$_POST[inputpos]', `username`='$_POST[inputusername]', `password`='$_POST[inputpassw]' WHERE ID = $_POST[player_id]"; mysql_query($u) or die (mysql_error()); echo "User has been modified!"; } else { echo "Please fill out the form"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/277403-can-someone-please-tell-me-why-my-edit-code-aint-working/ Share on other sites More sharing options...
requinix Posted April 29, 2013 Share Posted April 29, 2013 Because there's something wrong with it. Considering how you didn't give any kind of explanation behind what your code is supposed to do and what it actually does, I think that's a damn good answer. Quote Link to comment https://forums.phpfreaks.com/topic/277403-can-someone-please-tell-me-why-my-edit-code-aint-working/#findComment-1427074 Share on other sites More sharing options...
Tunavis Posted April 29, 2013 Author Share Posted April 29, 2013 It is supposed to edit and update info from a table. The problem is when I submit the changes nothing is changed... Quote Link to comment https://forums.phpfreaks.com/topic/277403-can-someone-please-tell-me-why-my-edit-code-aint-working/#findComment-1427095 Share on other sites More sharing options...
jugesh Posted April 29, 2013 Share Posted April 29, 2013 echo query and run query in phpmyadmin u wl come to know if there is any error Quote Link to comment https://forums.phpfreaks.com/topic/277403-can-someone-please-tell-me-why-my-edit-code-aint-working/#findComment-1427101 Share on other sites More sharing options...
jugesh Posted April 29, 2013 Share Posted April 29, 2013 You Query: $u = "UPDATE player_registration SET `name`='$_POST[inputname], `surname`='$_POST[inputsurname], `contact_number`='$_POST[inputcontact]', `email`='$_POST[inputemail]', `position`='$_POST[inputpos]', `username`='$_POST[inputusername]', `password`='$_POST[inputpassw]' WHERE ID = $_POST[player_id]"; mysql_query($u) or die (mysql_error()); check colored part one quote is missing. rectify it to: $u = "UPDATE `player_registration` SET `name`='$_POST[inputname], `surname`='$_POST[inputsurname]', `contact_number`='$_POST[inputcontact]', `email`='$_POST[inputemail]', `position`='$_POST[inputpos]', `username`='$_POST[inputusername]', `password`='$_POST[inputpassw]' WHERE ID = $_POST[player_id]"; mysql_query($u) or die (mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/277403-can-someone-please-tell-me-why-my-edit-code-aint-working/#findComment-1427102 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.