Jump to content

Recommended Posts

Hello Everyone, I have just joined today & this forum looks amazing, a place where everyone gets help in creating PHP scripts... First of all, thankyou in advance to everyone who is going through my post. Its tricky & I will appreciate only PHP gurus to comment upon my question...

 

I am building a website which is 50% completed in Dreamweaver CS3

 

My Question : I need to create a Button, users of my website when (press/click) this button will go through a script which will increase the category's ending time by 10mins & will increase the value of category by $50. The category will be donated to the last person pressing this button (------- > That means no one has pressed this button in last 10mins after him & the automatic ending time is achieved).

 

This is a part of my final year PHP project to be presented at my uni & really havn't got much time, please tell me everything from A-Z that will be needed & what scripts & codes will I need. How will I create SQL database & connect it with my

 

index.html page script // As the button will be present on index.html page

 

I have already created the website with gud looking buttons shouting click me, but really don't know what scripts will I be using.. thanx everyone for going thru.. regards, diNO

Link to comment
https://forums.phpfreaks.com/topic/112091-urgent-help-with-php-coding-please/
Share on other sites

This is a part of my final year PHP project to be presented at my uni & really havn't got much time, please tell me everything from A-Z that will be needed & what scripts & codes will I need. How will I create SQL database & connect it with my

 

index.html page script // As the button will be present on index.html page

 

PHP Tutorials

Some general hints:

 

1. Figure out the current time and value of the category, and the experation time

2. If time has expired, the last person who clicked the button wins

3. If button is clicked, increase experation time/value of the category

 

You should be able to figure it out from there.

Assuming you havnt got any code already done

 

In a list you will need:

 

1. The users selected username and something to validate them by ( some log in script )

 

2. Post OR GET for your form

 

3. Patience

 

4. And possibly a pair of reading glasses if you've read a PHP book and not learnt how to do it xD

 

Ok so for number one you'll need a form so any form will do be it get or post ( just change method )

 

<!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>test</title>
</head>

<body>

<form id="login" action="setstuff.php" method="post" enctype="multipart/form-data">
<label>Username:</label><input name="username" type="text" />
<label>Password:</label><input name="password" type="password" />
</form>
</body>
</html>

 

So you have your form posting to setstuff.php

 

<?php
if(isset($_POST['change_owner'])){
mysql_query("UPDATE bonusowner SET owner='$username' WHERE date=" . $DATE)or die(mysql_error())
or die(mysql_error());

echo "woo YOUR the bonus owner now ;]";
}
else{
/* set stuff.php setting variables and registering a session and containing another form to make this super quick and simple etc*/

$username = $_POST['username'];
$password = $_POST['password'];

//Perform an SQL query to check that users credentials

$DATE = date("Y-m-d");

$query = mysql_query("SELECT username FROM table WHERE username=" . $username . " AND password=" . $password)or die(mysql_error());

$num_rows = mysql_num_rows($query); //easy way to tell if there in the database

$bonus_owner_sql = mysql_query("SELECT * FROM bonusowner WHERE date=" . $DATE)or die(mysql_error());

if($num_rows > 0){

$bonus_owner = mysql_fetch_array($bonus_owner_sql);

session_start();
session_name('token');
session_register($username);

echo '<div style="width:300px; height:300px; border:1px solid #000000">';
echo "welcome back " . $username . "<br /><br />";

echo "current bonus owner is" . $bonus_owner . "!";
echo "whatever you plan to do...\n";

echo '<form id="change_owner" action=" ' . $PHP_SELF . '" method="post" enctype="multipart/form-data"> //Form for the button with hidden value for username
<input type="hidden" value="$bonus_owner" />
<input type="button" value="GET YOUR STUFF" />
</form>';
}
else{
echo "please go back to try again";
}
}

?>

 

Hopefully that works I'm half asleep so yeah have a play with that if it doesnt work at least its a start and structure for you.

I actually forgot the time expiration part :o

 

sorry and its 10 to 1  :o :o :o

 

I'm sure you can work out the ten minute addition by adding somethign along the lines of time()+10 in an if statement I'm too tired to work it out as of now ( its bad enough I managed to code what I did )

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.