Jump to content

Need some help designing an admin add-on


AGuyFawkesMask

Recommended Posts

Hi everyone,

I'm interested in creating a mod for my admin panel that allows my flight scheduling department to automatically generate random flight numbers via a script I set up. The only function the script serves is to generate a random flight number and store it in a MySQL database such that it can't be used again. However, right now that script is exposed and isn't apart of the phpVMS admin panel. Anyone can access it if they have the URL.

To fix this, I'm interested in bringing it into the admin panel. The problem I'm afraid I'm going to have is figuring out which files I'll need to create/edit to bring this simple script in there.

In advance, I appreciate your help. This is by far one of the most active, most helpful VA forums I know of and I feel that that should be heard. Here are the two scripts:

generate.php

<html>
<head>
<style type="text/css">
#title { color: white; background-color: #2d90c9; font-size: x-large; font-weight: bold; font-family: "Century Gothic",Georgia,Serif; }
#body { color: black; font-size: small; font-family: "Arial",Georgia,Serif; }
</style>
<title>Generate Flight Numbers</title>
<?php
$rand_num = (rand(100, 999));
?>
</head>
<body>
<center>
<div id="title">Generate Flight Numbers</div><br>
<form method="post" action="update.php">
<div id="body">Random flight number: <input type="text" name="flight_number" size="10" value="<?php echo $rand_num ?>" /></div><br>
<input onClick="javascript:location.reload(true)" type="button" value="Get New Number" />
<input type="submit" value="Update Database" /></form>
<?php
$connect = mysql_connect("CENSORED","CENSORED","CENSORED");
if (!$connect)
  { die('Connection failed. Cannot login.' . mysql_error()); }
mysql_select_db("CENSORED",$connect);
$query = mysql_query("SELECT * FROM flight_numbers");
$total_flights = mysql_num_rows($query); ?>
<div id="body">Total number of flights in database: <?php echo $total_flights; ?></div>
</center>
</body>
</html>

update.php

<?php
$connect = mysql_connect("CENSORED","CENSORED","CENSORED");
if (!$connect)
  { die('Connection failed. Cannot login.' . mysql_error()); }
mysql_select_db("CENSORED",$connect);
$flight_number = $_POST['flight_number'];
$insert = "INSERT INTO flight_numbers (flight_number) VALUES ('$flight_number')";
if (mysql_query($insert))
  { echo "$flight_number successfully added to database.<br><br>This page will now automatically redirect.";
 echo '<meta http-equiv="refresh" content="2; url=generate.php">';
 exit; }
else
  { echo "This page will now automatically redirect.<br><br>";
 echo '<meta http-equiv="refresh" content="2; url=generate.php">';
 die('Cannot write to database. Reason: ' . mysql_error()); }
 mysql_close();
?>

All I want to do is add this into my admin panel, I just don't know how to get started.

Again, I appreciate all of your help in advance.

  • Like 1
Link to comment
Share on other sites

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.

Loading...
×
×
  • Create New...