Jump to content

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


Tunavis

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

Archived

This topic is now archived and is closed to further replies.

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