need help with update.php
Posted: Wed Oct 13, 2010 5:20 pm
I haven't a clue where to start. basically i need a script where people who use my site can click on an image beside an entry and update it into the table where it needs to go.
here is the form for people to enter the scroll name
scroll.php
This finds the user's scroll info
ScrollRead.php
And this stores the info in the DB
ScrollReadGet.php
now when an egg from the nest hatches i want people to be able to click an image beside it and update it by deleting it from the egg table and moving it to the hatch table and so on... hope this is enough info
here is the form for people to enter the scroll name
scroll.php
Code: Select all
<style>
body {
font: normal small Verdana, Helvetica, sans-serif;
}
</style>
<center><form name="input" action="ScrollRead.php" method="post">
Scroll Name:
<input type="text" name="user" maxlength="40" size="15"/>
<input type="submit" value="Read Scroll" />
</form></center>ScrollRead.php
Code: Select all
<?php
ini_set("display_errors",false);
$fdd = $_POST['user'];
$user = str_replace(" ","%20","$fdd");
echo ''.$fdd.'';
echo '<input type=hidden value="'.$user.'" name=user><br>';
$young = unserialize(file_get_contents('http://dragcave.net/api/thehatch2010/serialize/user_young/'.$user.''));
foreach($young['errors'] as $error) {
if($error[0] == 3) {echo '<center>Sorry, we were unable to locate that scroll.</center>'; return;}
}
foreach($young['errors'] as $error) {
if($error[0] == 4) {echo '<center>Sorry, this user has no dragons.</center>'; return;}
}
foreach ($young['dragons'] as $key => $value) {
$data = unserialize(file_get_contents('http://dragcave.net/api/YOURKEY/serialize/view/'.$key));
echo '<input type="checkbox" name="checkboxes[]" value="'.$key.'" border="0"></a>';
echo '<a href="http://www.dragcave.net/view/'.$key.'"><img src="http://www.dragcave.net/image/'.$key.gif.'" border="0"></a>';
foreach ($data['clicks'] as $help => $me) {
echo '$help';
}
}
?>ScrollReadGet.php
Code: Select all
<?php
ini_set("display_errors",false);
$link = mysql_connect('localhost', '---', '---',true); if (!$link) { die('Could not connect: ' . mysql_error()); }
mysql_select_db("thehatch_dragon") or die(mysql_error());
$ids=$_GET['checkboxes'];
$user = $_GET['user'];
$young = unserialize(file_get_contents('http://dragcave.net/api/YOURKEY/serialize/user/'.$user.''));
foreach ($young['dragons'] as $key => $value) {
$querya = "DELETE FROM hatch WHERE code='$key'";
$queryb = "DELETE FROM er WHERE code='$key'";
$queryc = "DELETE FROM egg WHERE code='$key'";
mysql_query($querya);
mysql_query($queryb);
mysql_query($queryc);
}
echo '<center>Dragons updated. -- ';
echo 'Dragons now entered:<br>';
foreach ($ids as $hey) {
echo '<a href="http://www.dragcave.net/view/'.$hey.'" target="frame1"><img src="http://www.dragcave.net/image/'.$hey.'.gif" border="0"></a></ >';
$data = unserialize(file_get_contents('http://dragcave.net/api/YOURKEY/serialize/view/'.$hey.''));
$hrsleft = $data['dragons'][$hey]['hoursleft'];
$hatch = $data['dragons'][$hey]['hatch'];
if ($hrsleft < 96) {
$query3 = "INSERT INTO er(code, user) VALUES('$hey', '$user')";
mysql_query($query3);
echo 'Dragon has been entered into the ER.<br>';
}
else
{
if (! $hatch) {
$query4 = "INSERT INTO egg(code, user) VALUES('$hey', '$user')";
mysql_query($query4);
echo 'Egg has been entered into the Nest.<br>';
}
else
{
$query2 = "INSERT INTO hatch(code, user) VALUES('$hey', '$user')";
mysql_query($query2);
echo 'Hatchling has been entered into the Nursery.<br>';
}
}
}
?>