Jump to content

Recommended Posts

 

I want to create a Jackpot game where the positive & negative numbers are randomly generated. I have written my code in Dreamweaver but I don't see the output of my PHP code. Instead of code I see the PHP symbol. I also want to know how to combine multiple functionalities in PHP. I want to create a table, store game credit, generate a random number etc. This is my current code.

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Jackpot</title>
</head>

<body>
<?php include "header.php"; ?>
<table width="100%" cellpadding="0" cellspacing="0" align="center">
<tr valign="top">
  <td width="100%" height="59" align="left" valign="top"><table width="100%" cellpadding="0" cellspacing="0" align="center">
    <tr valign="top">
      <td align="left" valign="top" bgcolor="#FFFFFF"><?php include "menu.php"; ?></td>
      <td width="100%" align="left" valign="top"><p align="center">Jackpot</p></td>
      </tr>
  </table>    <p align="center"> </p></td>
</tr>
</table>
<?php include "footer.php";?>
<?php
$random_number = rand(-1000,1000);
echo "<p> You struck a Jackpot of </p>";
echo $random_number;
?>
<form action="Jackpot.php" method="post">
fingerValue: <input type="text" name="fingerValue" />
<input type="submit" />
</form>

</body>
</html>

Link to comment
https://forums.phpfreaks.com/topic/243212-how-to-build-a-php-based-game-website/
Share on other sites

@Eiolon: I am using the Dreamweaver software to execute my PHP code, no output comes. All I see is the PHP symbol.

 

@Maq: My file does have a PHP extension.

 

Can someone tell me how to put multiple things in one PHP program eg. generating a random number, capturing form info etc.

I don't know how Dreamweaver works, but it sounds like you didn't install a webserver to host your code. You can use WAMP or easyPHP if running windows.

Try to run your code from the browser then, through your newly installed host.

 

I don't get your second question.

Dreamweaver does not show the php code in the design (or split) window... You need to some program like xampp

 

And then Proceed with the following steps..

 

1. Download xampp (free) and extraxt the contents to root C:/

 

2. Open xampp folder and open xampp-control.exe

 

3. Start apachae and myaql serveics and they shuld turn green.

 

4. Now go to your browser and type http://localhost and see wether its opening xampp window.

 

5. If its working then save your .php file in the following directory :

 

                            C:\xampp\htdocs

 

6. Now again go to your browse and type in your address bar : http://localhost/abc.php  (here abc.php is the name of your file)

 

And it will work if your php code is fine...

 

And your second problem :  You can put as many php tag as you can..

 

For ex.

 

<html>
<body>

....

<?php

// Any Code

?>

Your HTML Code

<?php

//Your Second code

?>

</body>
</html>

 

 

HOPE IT HELPS ...

Happy CODING

I am using the Dreamweaver software to execute my PHP code, no output comes. All I see is the PHP symbol.

 

That's because Dreamweaver doesn't parse your PHP code. You need to have a webserver installed like XAMPP and have your files hosted in it's htdocs directory (unless you know, which I doubt, how to re-configure Apache to point to the current location of your directory).

 

You can then see the output, if you are lucky formatted like you did in Dreamweaver since DW is a WYSIWYAG: What You See Is What You Almost Get, if you navigate your browser to either: http://localhost:80/ or http://localhost:8080/

 

localhost (the reserved 127.0.0.1 ip address) is not a website like www.google.com it's a loopback address or in other words it points back to your computer with a certain protcol (http) and a port (80) this will trigger your local XAMPP installation as it's listening on one of these ports with a http protocol handler (Apache).

Thanx frenz for all your help.

 

@pranshu82202:I have used PHP tags before but what the problem is, now I have only used a table to display the header Jackpot. Remaining things are outside the table. I don't think I need the table but how do I place the remaining things in the table?

 

Everyone: Basically I am developing a mini game. In this game, the gamer has some credit value. The gamer provides some credit for this game. The game generates random positive and negative values. These generated values are added to the gamer's credit. Now my qn is how do I update the gamer's credit? This is a real-time game.

Thanx frenz for all your help.

 

@pranshu82202:I have used PHP tags before but what the problem is, now I have only used a table to display the header Jackpot. Remaining things are outside the table. I don't think I need the table but how do I place the remaining things in the table?

 

Everyone: Basically I am developing a mini game. In this game, the gamer has some credit value. The gamer provides some credit for this game. The game generates random positive and negative values. These generated values are added to the gamer's credit. Now my qn is how do I update the gamer's credit? This is a real-time game.

 

You should either take a look at sessions, cookies or databases.

I created a mySQL database using XAMP but I don't know what all to put in a database associated with a game that generates random numbers. I have to update user credit though so do I require 3 fields? Username, Credit, Random Value Generated.

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.