Jump to content

[SOLVED] php Confirmation...


mastercjb

Recommended Posts

I have a code for selling a house in my game. I'm trying to figure out how to make it to where, if someone clicks Sell Your House then it will ask you "Are You Sure You Wish To Sell Your House?". The only way I can think to do it would be with javascript, but I cant seem to get java into this code... Can someone please help. Heres my page script.

 

<?php
include 'header.php';

if($_GET['buy'] != ''){
    $result = mysql_query("SELECT * FROM `houses` WHERE `id`='".$_GET['buy']."'");
    $worked = mysql_fetch_array($result);
    $cost = $worked['cost'];

	   if($user_class->house != 0){
		  $result2 = mysql_query("SELECT * FROM `houses` WHERE `id`='".$user_class->house."'");
		  $worked2 = mysql_fetch_array($result2);
		  $cost = $cost - ($worked2['cost'] * .75);

		  echo Message('You have sold your house for 75% of what it was worth ($'.$cost."). That amount will go towards the purchase of the new house.");
	   }


      if($cost > $user_class->money) {
          echo Message("You don't have enough money to buy that house.");
      }
      if($cost <= $user_class->money && $worked['name'] != "") {
  
          $newmoney = $user_class->money - $cost;
          $result = mysql_query("UPDATE `grpgusers` SET `house` = '".$_GET['buy']."', `money` = '".$newmoney."' WHERE `id`='".$_SESSION['id']."'");
          echo Message("You have purchased and moved into ".$worked['name'].".");
          $user_class = new User($_SESSION['id']);
      }
      if ($worked['name'] == ""){
          echo Message("That's not a real house.");
      }
}
?>
<tr><td class="contenthead">Move House</td></tr>
<?
if($user_class->house > 0){
echo "<tr><td class='contentcontent' align='center'><a href='house.php?action=sell'>Sell Your House</a></td></tr>";
}
?>
<tr><td class="contentcontent">
<table width='100%'>
<tr>
	<td width='45%'><b>Type</b></td>
	<td width='15%'><b>Awake</b></td>
	<td width='20%'><b>Cost</b></td>
	<td width='20%'><b>Move</b></td>
</tr>

<?php
$result = mysql_query("SELECT * FROM `houses` ORDER BY `id` ASC");
while($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
		echo "<tr><td width='45%'>".$line['name']."</td><td>".$line['awake']."</td><td>\$".$line['cost']."</td><td>";
			if($line['id'] > $user_class->house){
				echo "<a href='house.php?buy=".$line['id']."'>Move In</a>";
			}
		echo "</td></tr>";

}
?>
</table>
</td></tr>
<?php
include 'footer.php';
?>

Link to comment
Share on other sites

try...

<?
if($user_class->house > 0){
   echo "<tr><td class='contentcontent' align='center'><a href='house.php?action=sell' onclick=\"return confirm('Do you want to sell your home?');\" >Sell Your House</a></td></tr>";
}
?>

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.