Jump to content

Can someone please tell me why my edit code aint working...


Recommended Posts


<?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";
}

?>

 

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.

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());

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.