Instructables

PHP: The Gift Giver

Picture of PHP: The Gift Giver
gg_2.png
gg_3.png
As Christmas approaches, people scatter stores to get last-minute gifts. So I decided to decrease your risk of being trampled by people richer than you by creating a "gift giver" you can use online. It also has an "exchange" feature so you can get rid of your coffee maker (that you already have two of) without leaving the warmth of home. Be careful, though. You never know what it's going to give.

This system uses three files and sessions. The first file is just a cover page. It only has text and a button to send you to the second page. The second page give you an initial gift and an "exchange" option. The third page gives you a second gift if you chose to on page two. I will not include any stylesheets.
 
Remove these adsRemove these ads by Signing Up

Step 1: Index.php

Picture of Index.php
Index.php is the file apache sends to a client when they visit a site. You can actually rename this file to "index.html", "home.html", "home.php", etc. Just remember to make the necessary changes later.

In the root directory of your web server (named "www"), create two folders called "gift1" and "gift2". These folders will have one file in them called "index.php". Unlike the "index.php" file we are about to create, these index files HAS to have the "php" extension.

In your root directory, create "index.php" and put in the following text, then save the file:

<!DOCTYPE HTML><html><title>gift giver</title><meta charset="UTF-8"></head>
<body>
<h1>The Gift Giver</h1>
<p>Hahaha. This page will give you a gift. It is simple. Just click "give me
a gift." It will. It is a small gift. But you have a chance to "exchange" it
for another gift. The exchange gifts will be bigger. However, it may not be
a good gift.</p>
<br /><br />
<form action="./gift1" method="post">
<!-- Gift? <input type="checkbox" name="gift" value="yes" /><br /> -->
<input type="submit" name="ubmit" value="Click here for your gift" />
</form>
</body></html>
interesting, so do other people give you gifts or are the gifts randomly generated and given to you?
qazxsw21000 (author)  amandaghassaei1 year ago
The gift is randomly generated and given to you.
Pro

Get More Out of Instructables

Already have an Account?

close

PDF Downloads
As a Pro member, you will gain access to download any Instructable in the PDF format. You also have the ability to customize your PDF download.

Upgrade to Pro today!