I have the login page created that captures the userid & also an edit page that shows all info of a certain table in database. Trying to figure out when a user views the edit page to have it only show the info the user created. Making it only possible to edit info specific to that logged in user.

I have a validate session that checks to make sure the user is logged, any suggestions would help greatly.

- Thanks in advance.

Recommended Answers

Hi

Can you provide the edit code.

Jump to Post

Hi

Can you provide the edit code.

Jump to Post

All 6 Replies

Hi

Can you provide the edit code.

Hi

Can you provide the edit code.

Member Avatar

yeah we would need the PHP code to be able to help you

Just copy it here in the CODE tags

Member Avatar

> yeah we would need the PHP code to be able to help you

Hah! I'm psychic, so I can tell him his error is on line 63, where he's missing a ';' and then again on line 245 - missing variable.

Member Avatar

How did you... I don't even....

Here's the edit code:

<?
if (!isset($_SESSION['valid_user']))
{
    echo "<h2>Sorry, you do not have permission to edit</h2><br>\n";
    echo "<a href=\"index.php?content=login_user\">Please login</a><br>\n";
    
} else

$db="db";
$link = mysql_connect('host', '', 'password');
if (! $link)
die(mysql_error());
mysql_select_db($db , $link)
or die("Not authorized to edit ".mysql_error());
$result = mysql_query( "SELECT * FROM table" )
or die("SELECT Error: ".mysql_error());
$num_rows = mysql_num_rows($result);
print "<h2>Enter player ID below and add player stats</h2><br><br>";
print "<table width=600 border=1 align=center>";
print "<tr><th>ID</th><th>POSTER</th><th>NA</th><th>PLAYER</th><th>AB</th><th>H</th><th>BB</th><th>HR</th><th>SB</th><th>RBI</th><th>R</th><th>Batting Average</th></tr>";
while ($get_info = mysql_fetch_row($result)){ 
print "<tr>";
foreach ($get_info as $field) 
print "<td>$field</td>";
print "</tr>";
}
print "</table>";
mysql_close($link);
?>
<br>
<form method="POST" action="index.php?content=edit_record">
  <div align="center">
    <h5>
Enter player ID Number & add player stats:<br>
<br>
ID:<input type="text" name="id" size="3" maxlength="3">AB:<input type="text" name="" size="3" maxlength="3">H:<input type="text" name="" size="3" maxlength="3">BB:<input type="text" name="" size="3" maxlength="3">HR:<input type="text" name="" size="3" maxlength="3">SB:<input type="text" name="" size="3" maxlength="3">RBI:<input type="text" name="" size="3" maxlength="3">R:<input type="text" name="" size="3" maxlength="3"><br>
<input type="submit" value="Submit"><input type="reset">
  </pre>
  </div>
</form>
<div align="center">
  <h6 align="left"> <a href="index.php?content=delete">Delete Player</a> | 
</body>
</html>

I tried to use a query to only find the user posts but that didn't work or I'm doing it wrong.

Here's a query I tried to use that didn't work:

$result = mysql_query( "SELECT * FROM table where useid = $useid" )

Any suggestions would greatly help. - Thanks in advance

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.