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
Share on other sites

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.