0

Basically I want the user to select the current month and day that they left a review, click submit, then given a random coupon code. I want the coupon code, the month they selected, and the day they selected to get inserted into the database.

HTML Page

<form action="redeem.php" method="post">
<select name="month">
    <option>Select Month</option>
    <option value="1">January</option>
    <option value="2">February</option>
    (Just took this part out to save room for DaniWeb)
    <option value="11">November</option>
    <option value="12">December</option>
</select>

<select name="day">
    <option value="1">1</option>
    <option value="2">2</option>
    (Just took this part out to save room for DaniWeb)
    <option value="30">30</option>
    <option value="31">31</option>
</select>
<input type="submit" name="Submit" value="Submit">
</form>

PHP Page

<?php
$con = mysql_connect("localhost","dbname","dbpassword");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

$RandomNum = rand(10000000,19999999);
echo 'Thank you for taking time out to leave us a review.';
echo '<br><br>';
echo 'Please save this code for 5% off your next service.';
echo '<br><br><br><b><font color="ff6600">';
echo $RandomNum;
echo '</font></b><br><br>';
echo 'This code does not expire.';
echo '<br><br>';
echo 'Simply tell us the code when you call us for your next service.';


mysql_select_db("dbname", $con);

mysql_query("INSERT INTO Coupon (Coupon, Month, Day)
VALUES ($RandomNum, '$_POST[month]', '$_POST[day]')");

mysql_close($con);
?> 
</div>

    <?php
    } else {
    ?>

Just now replaced the database name and password for privacy purposes. I get a white blank screen when I choose dates and click submit, and nothing happens. Please help.

2
Contributors
8
Replies
9
Views
5 Years
Discussion Span
Last Post by diafol
0

The path in the form action right?

Have you left anything out from the top of the redeem.php page? Because I don't understand this:

<?php
} else {
?>

To which control structure does it belong? You've already closed the '$con' one.

Look at Page SOurce View (or whatever it's called in your browser).

0

there's just some more HTML underneath that last part and then at the bottom there's this:

<?php
    };
    ?>

I don't really understand everything, I pretty much copied and pasted from websites

0

Perhaps it's better that you post the whole code as you're feeding us bits that don't make sense.

I don't really understand everything, I pretty much copied and pasted from websites

Yep, it'll hit the fan when you do that. :)

0
<html>
<head>
<link rel="stylesheet" type="text/css" href="design.css"/>
</head>
<body>
<div id="header"><img src="images/header.bmp" width="774"></a></div>
<div id="minibg"><img src="images/bg.png"></div>
<div id="line"><img src="images/line.bmp"/></div>
<div id="line2"><img src="images/line.bmp"/></div>
<div id="review2"><br><br>Please select the date you left a review.</div>
<div id="date">
<form action="redeem.php" method="post">
<select name="month">
    <option>Select Month</option>
    <option value="1">January</option>
    <option value="2">February</option>
    <option value="3">March</option>
    <option value="4">April</option>
    <option value="5">May</option>
    <option value="6">June</option>
    <option value="7">July</option>
    <option value="8">August</option>
    <option value="9">September</option>
    <option value="10">October</option>
    <option value="11">November</option>
    <option value="12">December</option>
</select>

<select name="day">
    <option value="1">1</option>
    <option value="2">2</option>
    <option value="3">3</option>
    <option value="4">4</option>
    <option value="5">5</option>
    <option value="6">6</option>
    <option value="7">7</option>
    <option value="8">8</option>
    <option value="9">9</option>
    <option value="10">10</option>
    <option value="11">11</option>
    <option value="12">12</option>
    <option value="13">13</option>
    <option value="14">14</option>
    <option value="15">15</option>
    <option value="16">16</option>
    <option value="17">17</option>
    <option value="18">18</option>
    <option value="19">19</option>
    <option value="20">20</option>
    <option value="21">21</option>
    <option value="22">22</option>
    <option value="23">23</option>
    <option value="24">24</option>
    <option value="25">25</option>
    <option value="26">26</option>
    <option value="27">27</option>
    <option value="28">28</option>
    <option value="29">29</option>
    <option value="30">30</option>
    <option value="31">31</option>
</select>
<input type="submit" name="Submit" value="Submit">
</form>
</div>

<div id="review3"><br><br>Please select the review site you used.</div>

<div id="site">
<select>
    <option>Google Places</option>
    <option>Yahoo Local</option>
    <option>City Search</option>
    <option>Yelp</option>
</select>
</div>

<div id="thankyou">Thank You !</div>
</body>
</html>

PHP

<html>
    <head>
    <link rel="stylesheet" type="text/css" href="design.css"/>
    </head>

<div id="thankyou2"> 
<?php
$con = mysql_connect("localhost","be","Ez1.");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }


$RandomNum = rand(10000000,19999999);
echo 'Thank you for taking time out to leave us a review.';
echo '<br><br>';
echo 'Please save this code for 5% off your next service.';
echo '<br><br><br><b><font color="ff6600">';
echo $RandomNum;
echo '</font></b><br><br>';
echo 'This code does not expire.';
echo '<br><br>';
echo 'Simply tell us the code when you call us for your next service.';


mysql_select_db("be_coupon", $con);

mysql_query("INSERT INTO Coupon (Coupon, Month, Day)
VALUES ($RandomNum, '$_POST[month]', '$_POST[day]')");

mysql_close($con);
?> 
</div>

    <?php
    } else {
    ?>

    <body>

<div id="header"><img src="images/header.bmp" width="774"></a></div>
<div id="minibg"><img src="images/bg.png"></div>
<div id="line"><img src="images/line.bmp"/></div>
<div id="line2"><img src="images/line.bmp"/></div>

    </body>
    </html>

    <?php
    };
    ?>
0

I took it out and it still doesn't work. That's not the problem

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.