Forum Moderators: coopster
See anything wrong here?
echo()statements at top).
Some long-term advice, with particular value to future maintenance:
You may know what each section is for at the moment, but will have difficulty remembering in the future. Write the comments as if for some other programmer coming to your code for the first time. This has proved a life-saver for me recently.
You should never use any
$_REQUEST[]variables (
$_POST[], $_GET[], $_COOKIE[]) directly in your code. This is a real pain to do, but will save much future grief. Try to understand that there are people out there that do nothing else other than trying to "own" your server through your code. It is particularly important with user-submitted info which is then stored in a database.
$_REQUEST[]variables.
Error-checking is an integral part of the code, and the best place for it is at the top. Have a global error boolean (== TRUE means that there has been an error) and per-section error booleans.
Use CSS. Declare 2 styles which are nearly identical:
- normal_stylethe sole difference being that the second has a different background colour and/or border. Then switch between the 2 styles according to the value of the per-section error boolean (the ternary operator is useful here!):
- error_style
<?php
echo "<input type='text' class='". ( $per_section_error_boolean )? "error_style" : "normal_style" ) ."' />";
?>
It seems to work ok but what ever month, day and year it is, it puts it in the drop down menu double and out of order.
<td valign="top" colspan="2" style="white-space:nowrap;"><strong>Trip Start:</strong><br />
<select name="TSpickMonth" size="1">
<option value="<? echo date('M');
?>"><? echo date('M');?></option>
<option value="January">Jan</option>
<option value="Feburary">Feb</option>
<option value="March">Mar</option>
<option value="April">Apr</option>
<option value="May">May</option>
<option value="June">Jun</option>
<option value="July">Jul</option>
<option value="August">Aug</option>
<option value="September">Sep</option>
<option value="October">Oct</option>
<option value="November">Nov</option>
<option value="December">Dec</option>
</select>
<select name="TSpickDay" size="1">
<option value="<? echo date('d');
?>"><? echo date('d');?></option>
<option value="1">1</option>
<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>
<select name="TSpickYear" size="1">
<option value="<? echo date('Y');
?>"><? echo date('Y');?></option>
<option value="2002">2002</option>
<option value="2003">2003</option>
<option value="2004">2004</option>
<option selected="selected" value="2005">2005</option>
<option value="2006">2006</option>
</select>
</td>
SORRY: There is a problem with information you have submitted:
Please complete your report and "Submit" again...
<?
$errmsg = '';
$errmsg .= '<font color=#FF0000>SORRY: There is a problem with information you have submitted:</font>';
$errmsg .= '<ul>';
if (empty($_POST['triplocation'])) {
$errmsg .= '<font color=#FF0000><li>Your report has no [trip location]</li></font><br>';
}
if (empty($_POST['author'])) {
$errmsg .= '<font color=#FF0000><li>Please identify the [trip report author]</li></font><br>';
}
if (empty($_POST['report'])) {
$errmsg .= '<font color=#FF0000><li>Please fill in your [trip report]</li></font><br>';
}
$errmsg .= '</ul>';
$errmsg .= '<font color=#FF0000>Please complete your report and "Submit" again...<br></font>';
if (!empty($errmsg)) {
include 'form.php';
} else {
{
$errmsg .= '<font color=#FF0000>SORRY: There is a problem with information you have submitted:</font>';
$errmsg .= '<ul>';
}
if (empty($_POST['triplocation'])) {
$errmsg .= '<font color=#FF0000><li>Your report has no [trip location]</li></font><br>';
}
if (empty($_POST['author'])) {
$errmsg .= '<font color=#FF0000><li>Please identify the [trip report author]</li></font><br>';
}
if (empty($_POST['report'])) {
$errmsg .= '<font color=#FF0000><li>Please fill in your [trip report]</li></font><br>';
}
$errmsg .= '</ul>';
$errmsg .= '<font color=#FF0000>Please complete your report and "Submit" again...<br></font>';
if (!empty($errmsg)) {
include 'form.php';
} else {
if (isset($errmsg) &&!empty($errmsg)) {
echo '<p>',$errmsg;
echo '</ul>';
echo '<font color=#FF0000>Please complete your report and "Submit" again...<br></font>';
}
that should do it
I have no clue it was in what you pasted
>> get month name
I see it is just the number at the moment.
as far as dates go I always store the numeric representation and then worry about how I want displayed when I output it. That makes it a lot easier if I need to do any math with the dates at any point.
there is an example on the page I linked that shows how to use mktime inside the date function
for mktime you need these arguments
int mktime ( [int hour [, int minute [, int second [, int month [, int day [, int year [, int is_dst]]]]]]] )
so you need 0,0,0 before month,day, year
for date it takes 2 arguments, the second will be your mktime part
the first will be your pattern for your date, look at the date function page for all the patterns
if (!empty($row['photolink'])) echo '<strong>Photo Slideshow Link: </strong>
<a href="javascript:void(0);" onclick="fullScreen(',$row['photolink'],');">',$row['photolink'],'</a><br>';
I need it output like this:
<a href="javascript:void(0);" onclick="fullScreen('http://www.myphotoalbum.com');">http://www.myphotoalbum.com</a>
Here is what it is currently:
<a href="javascript:void(0);" onclick="fullScreen(http://www.myphotoalbum.com);">http://www.myphotoalbum.com</a>
How do I get the ' ' for the address?