Jump to content

[SOLVED] Adding admin panel to script


freelancer

Recommended Posts

I worked out simple match results form where is included all data from mysql database. I can add info to database table from my file add.html witch includes

<form action="insert.php" method="post">
Opponent: <input type="text" name="opponent"><br>
Map: <input type="text" name="map"><br>
Score: <input type="text" name="score"><br>
<input type="Submit">
</form>

insert.php stores info what was in fields into my database table called 'results'.

Furthermore I made script that allows edit specific table via id number. File name called update.php:

<?php

$id=$_GET['id'];
include('config.php');
mysql_connect("server",$username,$password);
@mysql_select_db($database) or die( "No database selceted!");

$query=" SELECT * FROM results WHERE id='$id'";
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();

$i=0;
while ($i < $num) {

$opponent=mysql_result($result,$i,"opponent");
$map=mysql_result($result,$i,"map");
$score=mysql_result($result,$i,"score");

?>
<form action="updated.php" method="post">
<input type="hidden" name="ud_id" value="<? echo $id; ?>">
Opponent: <input type="text" name="ud_opponent" value="<? echo $opponent; ?>"><br>
Map: <input type="text" name="ud_map" value="<? echo $map; ?>"><br>
Score: <input type="text" name="ud_score" value="<? echo $score; ?>"><br>
<input type="Submit" value="Update">
</form>
<?
++$i;
}
?>

This can be done by changing url as update.php?id=<id from table>.

Now, all works fine but I want to secure it that random people can't edit table by just going to this url.

After that I would like that in this admin panel witch is protected with user&pass all my table information is included and there would be 1 additional column where is 'Edit' button for each one that I don't have to type id number to change something if I need.

 

I hope you understand what you mean and are able to help me out :P Thanks

 

Link to comment
https://forums.phpfreaks.com/topic/37999-solved-adding-admin-panel-to-script/
Share on other sites

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.