This code runs like when i submit the form it takes the image and displayed and top of the image a map will displayed. But actually i want that when i give the image it checks the location in the map and after displayed it.plz tell that how to start the logic.
[php]
<?php
// Connect to database
$errmsg = "";if (! @mysql_connect( "localhost","ro ot","sreeni") ) {
$errmsg = "Cannot connect to database";
}
@mysql_select_d b("my_db1");
// First run ONLY - need to create table by uncommenting this
// Or with silent @ we can let it fail every sunsequent time ;-)
$q = <<<CREATE
create table pix (
pid int primary key not null auto_increment,
name varchar(20),ema il varchar(30),cit y varchar(20),sta te varchar(20),zip int(7),country varchar(20),mon th varchar(20),dat e int(3),upload longblob)
CREATE;
@mysql_query($q );
// Insert any new image into database
if ($_REQUEST[completed] == 1) {
// Need to add - check for large upload. Otherwise the code
// will just duplicate old file ;-)
// ALSO - note that latest.img must be public write and in a
// live appliaction should be in another (safe!) directory.
move_uploaded_f ile($_FILES['upload']['tmp_name'],"latest.img ");
$instr = fopen("latest.i mg","rb");
$image = addslashes(frea d($instr,filesi ze("latest.img" )));
if (strlen($instr) < 149000) {
mysql_query ("INSERT INTO pix(name, email, city, state, zip, country, month, date, upload) VALUES('".$_POS T['name']."', '".$_POST['email']."', '".$_POST['city']."', '".$_POST['state']."', '".$_POST['zip']."', '".$_POST['country']."', '".$_POST['month']."', '".$_POST['date']."', '".$image."')") ;
mysql_query ("insert into pix (name,email,cit y,state,zip,cou ntry,month,date ) values ( $_POST[name],$_POST[email],$_POST[city],$_POST[state],$_POST[zip]. ,$_POST[country],$_POST[month],$_POST[date])");
} else {
$errmsg = "Too large!";
}
}
// Find out about latest image
$gotten = @mysql_query("s elect * from pix order by pid desc");
if ($row = @mysql_fetch_as soc($gotten)) {
$name = htmlspecialchar s($row[name]);
$email = htmlspecialchar s($row[email]);
$city = htmlspecialchar s($row[city]);
$state = htmlspecialchar s($row[state]);
$zip = htmlspecialchar s($row[zip]);
$country = htmlspecialchar s($row[country]);
$month = htmlspecialchar s($row[month]);
$date = htmlspecialchar s($row[date]);
$bytes = $row[upload];
} else {
$errmsg = "There is no image in the database yet";
$title = "no database image available";
// Put up a picture of our training centre
$instr = fopen("latest.i mg","rb");
$bytes = fread($instr,fi lesize("latest. img"));
}
// If this is the image request, send out the image
if ($_REQUEST[gim] == 1) {
header("Content-type: image/jpeg");
print $bytes;
exit ();
}
?>
<html>
<body>
<script type='text/javascript'>
function formValidator() {
var name = document.getEle mentById('name' );
var email = document.getEle mentById('email ');
var city = document.getEle mentById('city' );
var state = document.getEle mentById('state ');
var country = document.getEle mentById('count ry');
var gender = document.getEle mentById('gende r');
var zip = document.getEle mentById('zip') ;
var upload = document.getEle mentById('uploa d');
var message=documen t.getElementByI d('message');
if(isAlphabet(n ame, "Please enter only letters for name"))
{
if(emailValidat or(email, "Please enter a valid email address"))
{
if(isAlphabet(c ity,"please enter only letters for city"))
{
if(isAlphabet(s tate,"please enter only letters for state"))
{
if(isAlphabet(s tate,"please enter only letters for country"))
{
if(modeSelectio n(gender, "Please Choose gender"))
{
if(len(zip,"Ple ase enter 6 characters only for zip code"))
{
if(isEmpty(uplo ad, "Please upload your photo"))
{
return true;
}}
}
} }}}
}
return false;
}
function isAlphabet(elem , helperMsg)
{
var alphaExp = /^[a-zA-Z]+$/;
if(elem.value.m atch(alphaExp))
{
return true;
}
else
{
alert(helperMsg );
elem.focus();
return false;
}
}
function isEmpty(elem, helperMsg)
{
if(elem.value.l ength == 0)
{
alert(helperMsg );
elem.focus();
// set the focus to this input
return false;
}
return true;
}
function isAlphanumeric( elem, helperMsg)
{
var alphaExp = /^[0-9a-zA-Z]+$/;
if(elem.value.m atch(alphaExp))
{
return true;
}
else
{
alert(helperMsg );
elem.focus();
return false;
}
}
function len (elem,helperMsg )
{
var uInput = elem.value;
if(uInput.lengt h == 6)
{
if(isNumeric(el em,helperMsg))
{
return true;
}
else
{
// alert("Please enter numeric characters only for zip code");
elem.focus();
return false;
}
}
else{
alert("Please enter 6digits only for zip code");
elem.focus();
return false; }
}
function isNumeric(elem, helperMsg)
{
var numericExpressi on = /^[0-9]+$/;
if(elem.value.m atch(numericExp ression))
{
return true;
}
else
{
alert(helperMsg );
elem.focus();
return false;
}
}
function modeSelection(e lem, helperMsg)
{
if(elem.value == "select")
{
alert(helperMsg );
elem.focus();
return false;
}
else
{
return true;
}
}
function emailValidator( elem, helperMsg)
{
var emailExp = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/;
if(elem.value.m atch(emailExp))
{
return true;
}
else
{
alert(helperMsg );
elem.focus();
return false;
}
}
</script>
<body bgcolor=white>< h2>Here's the latest picture</h2>
<font color=red><?= $errmsg ?></font>
<tr align="left">
<td>
<iframe width="425" height="350" frameborder="0" scrolling="no" marginheight="0 " marginwidth="0" src="http://maps.google.com/?ie=UTF8&z= 4&ll=37.062 5,-95.677068&o utput=embed& ;s=AARTsJqzARj-Z8VnW5pkPMLMmZb qrJcYpw"></iframe><br /><small><a href="http://maps.google.com/?ie=UTF8&z= 4&ll=37.062 5,-95.677068&s ource=embed" style="color:#0 000FF;text-align:left">Vie w Larger Map</a></small>
</td>
</tr>
<tr>
<td>
<center><img src=?gim=1 width=350 height=200><br>
<b><?= $title ?></center>
</td>
</tr>
<hr>
<h1><i><center> <font color=blue>Add Your Greeting</font></i></h1>
<center>
<form onSubmit='retur n formValidator() ' method=post enctype=multipa rt/form-data>
<input type=hidden name=MAX_FILE_S IZE value=150000>
<input type=hidden name=completed value=1>
<center><tabl e border=1 bordercolorligh t ="black" bordercolordark ="#D4D4D4" bgcolor= "#BBBBBB
">
<tr>
<td>
<table cellpadding="0" cellspacing="0" border="0" width="600" summary="Create user account">
<tr> <td> <p>Fields marked <font color=red>* </font>are required</p></td><td> </td></tr>
<tr >
<td align="right" width="150">Nam e <font color=red>*</font></td>
<td align="right" width="150">
<input type="text" name="name" id="name" onChange="retur n isAlphabet(this ,'please enter charactersonly' )"> </td>
</tr>
<tr> <td colspan="3" nowrap height="20"><sp acer type="vertical" height="10"></td></tr>
<tr >
<td align="right" width="150">Ema il<font color=red>*</font></td>
<td align="right" width="150"><in put type="text" id="email" name="email" width="150" maxLength="20" onChange=" return emailValidator( this,'not a valid email id')">
</td>
</tr>
<tr> <td colspan="3" nowrap height="20"><sp acer type="vertical" height="10"></td></tr>
<tr>
<td align="right" width="150">Cit y <font color=red>*</font></td>
<td align="right" width="150">
<input type="text" name="city" id="city" onChange="retur n isAlphabet(this ,'please enter charactersonly' )"> </td>
</tr>
<tr> <td colspan="3" nowrap height="20"><sp acer type="vertical" height="10"></td></tr>
<tr>
<td align="right" width="150">Sta te <font color=red>*</font></td>
<td align="right" width="150">
<input type="text" name="state" id="state" onChange="retur n isAlphabet(this ,'please enter charactersonly' )"> </td>
</tr>
<tr> <td colspan="3" nowrap height="20"><sp acer type="vertical" height="10"></td></tr>
<tr>
<td align="right" width="150">Cou ntry<font color=red>*</font></td>
<td align="right" width="150">
<SELECT id='country' name='country' onchange='retur n isAlphabet(this ,'please enter charactersonly' )'><OPTION>choo se a country</OPTION> <OPTION>Unite d States</OPTION> <OPTION>Unite d Kingdom</OPTION> <OPTION>Canad a</OPTION> <OPTION>Afghani stan</OPTION> <OPTION>Albania </OPTION> <OPTION>Algeria </OPTION> <OPTION>Andorra </OPTION> <OPTION>Angol a</OPTION> <OPTION>Anguill a</OPTION> <OPTION>Antarct ica</OPTION> <OPTION>Antig ua and Barbuda</OPTION> <OPTION>Argenti na</OPTION> <OPTION>Armenia </OPTION> <OPTION>Aruba </OPTION> <OPTION>Austral ia</OPTION> <OPTION>Austria </OPTION> <OPTION>Azerbai jan</OPTION> <OPTION>Bahamas </OPTION> <OPTION>Bahrain </OPTION> <OPTION>Bangald esh</OPTION> <OPTION>Barbado s</OPTION> <OPTION>Belgium </OPTION> <OPTION>Beliz e</OPTION> <OPTION>Belarus </OPTION> <OPTION>Benin </OPTION> <OPTION>Bermuda </OPTION> <OPTION>Bhuta n</OPTION> <OPTION>Bolivia </OPTION> <OPTION>Bosni a andHerzegovina</OPTION> <OPTION>Botswan a</OPTION> <OPTION>Brazi l</OPTION> <OPTION>Brune i</OPTION> <OPTION>Bulgari a</OPTION> <OPTION>Burki na Faso</OPTION> <OPTION>Burundi </OPTION> <OPTION>Cambodi a</OPTION> <OPTION>Cameroo n</OPTION> <OPTION>Cape Verde</OPTION> <OPTION>Cayma n Islands</OPTION> <OPTION>Centr al African Republic</OPTION> <OPTION>Chile </OPTION> <OPTION>China </OPTION> <OPTION>Christm as Island</OPTION> <OPTION>Colombi a</OPTION> <OPTION>Comoros </OPTION> <OPTION>Congo </OPTION> <OPTION>Democra tic Republic of the Congo</OPTION> <OPTION>Cook Islands</OPTION> <OPTION>Costa Rica</OPTION> <OPTION>Cote DIvoire</OPTION> <OPTION>Croatia </OPTION> <OPTION>Cuba</OPTION><OPTION >Cyprus</OPTION><OPTION >Czech Republic</OPTION><OPTION >Denmark</OPTION><OPTION >Djibouti</OPTION><OPTION >Dominica</OPTION><OPTION >Dominican Republic</OPTION><OPTION >Ecuador</OPTION><OPTION >Egypt</OPTION><OPTION >El Salvador</OPTION><OPTION >Equitorial Guinea</OPTION><OPTION >Eritrea</OPTION><OPTION >Estonia</OPTION><OPTION >Ethiopia</OPTION><OPTION >Falkland Islands</OPTION><OPTION >Fiji</OPTION><OPTION >Finland</OPTION><OPTION >France</OPTION> <OPTION>Frenc h Guiana</OPTION><OPTION >French Polynesia</OPTION><OPTION >Gabon</OPTION><OPTION >Gambia</OPTION> <OPTION>Germany </OPTION><OPTION >Georgia</OPTION> <OPTION>S Georgia and the S Sandwich Is</OPTION> <OPTION>Ghana </OPTION> <OPTION>Greec e</OPTION> <OPTION>Greenla nd</OPTION><OPTION >Grenada</OPTION> <OPTION>Guadelo upe</OPTION> <OPTION>Guam</OPTION> <OPTION>Guatema la</OPTION> <OPTION>Guine a</OPTION> <OPTION>Guine a Bissau</OPTION> <OPTION>Guyan a</OPTION> <OPTION>Haiti </OPTION> <OPTION>Hondura s</OPTION> <OPTION>Hong Kong</OPTION> <OPTION>Hungary </OPTION> <OPTION>Iceland </OPTION><OPTION >India</OPTION> <OPTION>Indones ia</OPTION> <OPTION>Iran</OPTION><OPTION >Iraq</OPTION> <OPTION>Ireland </OPTION> <OPTION>Israe l</OPTION><OPTION >Italy</OPTION> <OPTION>Jamaica </OPTION> <OPTION>Japan </OPTION><OPTION >Jordan</OPTION> <OPTION>Kazakhs tan</OPTION> <OPTION>Kenya </OPTION><OPTION >Kiribati</OPTION> <OPTION>St. Kitts and Nevis</OPTION> <OPTION>North Korea</OPTION> <OPTION>South Korea</OPTION> <OPTION>Kyrgyzs tan</OPTION><OPTION >Kuwait</OPTION> <OPTION>Laos</OPTION> <OPTION>Latvi a</OPTION> <OPTION>Lebanon </OPTION> <OPTION>Lesotho </OPTION> <OPTION>Liberia </OPTION><OPTION >Libya</OPTION><OPTION >Liechtenstei n</OPTION> <OPTION>Lithuan ia</OPTION> <OPTION>Luxembo urg</OPTION><OPTION >Macau</OPTION> <OPTION>Macedon ia</OPTION> <OPTION>Madagas car</OPTION> <OPTION>Malaysi a</OPTION> <OPTION>Maldive s</OPTION> <OPTION>Mali</OPTION> <OPTION>Marshal l Islands</OPTION> <OPTION>Malta </OPTION> <OPTION>Norther n Mariana Islands</OPTION><OPTION >Malawi</OPTION> <OPTION>Martini que</OPTION> <OPTION>Maurita nia</OPTION><OPTION >Mauritius</OPTION> <OPTION>Mayotte </OPTION> <OPTION>Mexic o</OPTION> <OPTION> Micronesia</OPTION> <OPTION>Moldova </OPTION> <OPTION>Mongoli a</OPTION> <OPTION>Montser rat</OPTION> <OPTION>Morocco </OPTION> <OPTION>Mozambi que</OPTION> <OPTION>Myanmar </OPTION> <OPTION>Namibia </OPTION> <OPTION>Nauru </OPTION> <OPTION>Nepal </OPTION> <OPTION>Netherl ands</OPTION><OPTION >Netherlands Antilles</OPTION><OPTION >New Caledonia</OPTION> <OPTION>New Zealand</OPTION> <OPTION>Nicarag ua</OPTION> <OPTION>Niger </OPTION> <OPTION>Nigeria </OPTION> <OPTION>Niue</OPTION> <OPTION>Norwa y</OPTION> <OPTION>Oman</OPTION> <OPTION>Pakista n</OPTION> <OPTION>Palau </OPTION> <OPTION>Panam a</OPTION> <OPTION>Papua New Guinea</OPTION><OPTION >Paraguay</OPTION> <OPTION>Peru</OPTION> <OPTION>Philipp ines</OPTION> <OPTION>Pitcair n Islands</OPTION><OPTION >Poland</OPTION> <OPTION>Portuga l</OPTION> <OPTION>Puert o Rico</OPTION> <OPTION>Qatar </OPTION> <OPTION>Reunion </OPTION> <OPTION>Romania </OPTION><OPTION >Russia</OPTION> <OPTION>Rwand a</OPTION> <OPTION>St. Lucia</OPTION><OPTION >Saint Vincent and the Grenadines</OPTION> <OPTION>Samoa American</OPTION> <OPTION>Samoa </OPTION><OPTION >San Marino</OPTION> <OPTION>Sao Tome and Principe</OPTION> <OPTION>Saudi Arabia</OPTION> <OPTION>Senegal </OPTION> <OPTION>Seychel les</OPTION> <OPTION>Sierr a Leone</OPTION> <OPTION>Singapo re</OPTION> <OPTION>Slovaki a</OPTION> <OPTION>Sloveni a</OPTION><OPTION >Solomon Islands</OPTION><OPTION >Somalia</OPTION><OPTION >South Africa</OPTION> <OPTION>Spain </OPTION> <OPTION>Sri Lanka</OPTION><OPTION >Sudan</OPTION> <OPTION>Surinam e</OPTION> <OPTION>Swazila nd</OPTION><OPTION >Sweden</OPTION> <OPTION>Switzer land</OPTION> <OPTION>Syria </OPTION><OPTION >Taiwan</OPTION> <OPTION>Tajikis tan</OPTION> <OPTION>Tanzani a</OPTION><OPTION >Thailand</OPTION> <OPTION>Togo</OPTION> <OPTION>Tonga </OPTION> <OPTION>Trinida d and Tobago</OPTION> <OPTION>Tunisia </OPTION> <OPTION>Turke y</OPTION><OPTION >Turkmenistan </OPTION> <OPTION>Tuval u</OPTION><OPTION >Uganda</OPTION><OPTION >Ukraine</OPTION> <OPTION>Unite d Arab Emirates</OPTION><OPTION >Uruguay</OPTION> <OPTION>Uzbekis tan</OPTION><OPTION >Vanuatu</OPTION><OPTION >Vatican City</OPTION> <OPTION>Venezue la</OPTION> <OPTION>Virgi n Islands</OPTION><OPTION >Vietnam</OPTION> <OPTION>Weste rn Sahara</OPTION> <OPTION>Yemen </OPTION><OPTION >Yugoslavia</OPTION> <OPTION>Zambi a</OPTION> <OPTION>Zimbabw e</OPTION><OPTION >APO</OPTION> <OPTION>FPO</OPTION> <OPTION>Other </OPTION><OPTION >Bouvet Island</OPTION> <OPTION>Briti sh Indian Ocean Territory</OPTION><OPTION >Chad</OPTION> <OPTION>Cocos Keeling Islands</OPTION><OPTION >East Timor</OPTION><OPTION >Faroe Islands</OPTION><OPTION >French Southern Territories</OPTION> <OPTION>Gibralt ar</OPTION><OPTION >Heard and McDonald Islands</OPTION><OPTION >Monaco</OPTION><OPTION >Norfolk Island</OPTION> <OPTION>St. Helena</OPTION><OPTION >St. Pierre and Miquelon</OPTION><OPTION >Svalbard and Jan Mayen Islands</OPTION> <OPTION>Tokelau </OPTION> <OPTION>Turks and Caicos Islands</OPTION> <OPTION>Unite d States Minor Outlying Islands</OPTION><OPTION >Wallis and Futuna Islands</OPTION> <OPTION>Briti sh Virgin Islands</OPTION></SELECT>
</div><br/>
<tr> <td colspan="3" nowrap height="20"><sp acer type="vertical" height="10"></td></tr>
<tr>
<td align="right" width="150">Dat eofbirth<font color=red>*</font></td>
<td align="right" width="150">
<SELECT id='m_BIRTHMONT H' name='month'><O PTION>choose month</OPTION> <OPTION>January </OPTION> <OPTION>Februar y</OPTION> <OPTION>March </OPTION> <OPTION>April </OPTION> <OPTION>May</OPTION> <OPTION>June</OPTION> <OPTION>July</OPTION> <OPTION>Augus t</OPTION> <OPTION>Septemb er</OPTION> <OPTION>October </OPTION> <OPTION>Novembe r</OPTION> <OPTION>Decembe r</OPTION></SELECT>
<SELECT id='m_BIRTHDAY' name='date' ><OPTION>day</OPTION> <OPTION>1</OPTION> <OPTION>2</OPTION><OPTION >3</OPTION> <OPTION>4</OPTION> <OPTION>5</OPTION><OPTION >6</OPTION> <OPTION>7</OPTION> <OPTION>8</OPTION><OPTION >9</OPTION> <OPTION>10</OPTION> <OPTION>11</OPTION><OPTION >12</OPTION> <OPTION>13</OPTION> <OPTION>14</OPTION><OPTION >15</OPTION> <OPTION>16</OPTION> <OPTION>17</OPTION><OPTION >18</OPTION> <OPTION>19</OPTION> <OPTION>20</OPTION><OPTION >21</OPTION> <OPTION>22</OPTION> <OPTION>23</OPTION><OPTION >24</OPTION> <OPTION>25</OPTION> <OPTION>26</OPTION><OPTION >27</OPTION> <OPTION>28</OPTION> <OPTION>29</OPTION><OPTION >30</OPTION> <OPTION>31</OPTION></SELECT>
</div><br/>
</tr>
<tr> <td colspan="3" nowrap height="20"><sp acer type="vertical" height="10"></td></tr>
<tr>
<td align="right" width="150">Gen der<font color=red>*</font></td>
<td align="center" width="150"><se lect id="gender" name="gender" width="150" maxLength="20" onSelect="retur n modeSelection(t his,'Please Choose gender')"> <option value="select"> select</option><option value="M">M</option><option value="F">F</option> </select> </td>
</tr>
<tr> <td colspan="3" nowrap height="20"><sp acer type="vertical" height="10"></td></tr>
<tr>
<td align="right" width="150">Zip </LABEL><font color=red>*</font></td>
<td align="right" width="150"><in put type="text" id="zip" name="zip" width="150" maxLength="6" onChange=" return len(this,'pleas e enter only 6 characters for zip code')"></td>
</tr>
<tr> <td colspan="3" nowrap height="20"><sp acer type="vertical" height="10"></td></tr>
<tr >
<td align="right" width="150">You r Greeting</LABEL></td>
<td align="right" width="150"> <textarea name="message" id="message" cols="30" rows="6"></textarea></td>
</tr>
<tr> <td colspan="3" nowrap height="20"><sp acer type="vertical" height="10"></td></tr>
<tr>
<td align="right" width="150">You r Photo</LABEL><font color=red>*</font></td>
<td align="right" width="150"><in put type="file" id="upload" name="upload" width="150" maxLength="20" onChange=" return isEmpty(this,'p lease upload photo')"> </td>
</tr>
<tr> <td colspan="3" nowrap height="20"><sp acer type="vertical" height="10"></td></tr>
<tr>
<td align="right" width="150"> <input type="submit" value="Save" width="150" maxLength="20"> </td>
<td align="left" width="150"> <input type="reset" value="clear" width="150" maxLength="20"> </td>
</tr>
</table>
</td></tr></table>
</form>
</body>
</html>[/php]
Please enclose any code within the proper code tags!!. See the Posting Guidelines on how to do that. - moderator
[php]
<?php
// Connect to database
$errmsg = "";if (! @mysql_connect( "localhost","ro ot","sreeni") ) {
$errmsg = "Cannot connect to database";
}
@mysql_select_d b("my_db1");
// First run ONLY - need to create table by uncommenting this
// Or with silent @ we can let it fail every sunsequent time ;-)
$q = <<<CREATE
create table pix (
pid int primary key not null auto_increment,
name varchar(20),ema il varchar(30),cit y varchar(20),sta te varchar(20),zip int(7),country varchar(20),mon th varchar(20),dat e int(3),upload longblob)
CREATE;
@mysql_query($q );
// Insert any new image into database
if ($_REQUEST[completed] == 1) {
// Need to add - check for large upload. Otherwise the code
// will just duplicate old file ;-)
// ALSO - note that latest.img must be public write and in a
// live appliaction should be in another (safe!) directory.
move_uploaded_f ile($_FILES['upload']['tmp_name'],"latest.img ");
$instr = fopen("latest.i mg","rb");
$image = addslashes(frea d($instr,filesi ze("latest.img" )));
if (strlen($instr) < 149000) {
mysql_query ("INSERT INTO pix(name, email, city, state, zip, country, month, date, upload) VALUES('".$_POS T['name']."', '".$_POST['email']."', '".$_POST['city']."', '".$_POST['state']."', '".$_POST['zip']."', '".$_POST['country']."', '".$_POST['month']."', '".$_POST['date']."', '".$image."')") ;
mysql_query ("insert into pix (name,email,cit y,state,zip,cou ntry,month,date ) values ( $_POST[name],$_POST[email],$_POST[city],$_POST[state],$_POST[zip]. ,$_POST[country],$_POST[month],$_POST[date])");
} else {
$errmsg = "Too large!";
}
}
// Find out about latest image
$gotten = @mysql_query("s elect * from pix order by pid desc");
if ($row = @mysql_fetch_as soc($gotten)) {
$name = htmlspecialchar s($row[name]);
$email = htmlspecialchar s($row[email]);
$city = htmlspecialchar s($row[city]);
$state = htmlspecialchar s($row[state]);
$zip = htmlspecialchar s($row[zip]);
$country = htmlspecialchar s($row[country]);
$month = htmlspecialchar s($row[month]);
$date = htmlspecialchar s($row[date]);
$bytes = $row[upload];
} else {
$errmsg = "There is no image in the database yet";
$title = "no database image available";
// Put up a picture of our training centre
$instr = fopen("latest.i mg","rb");
$bytes = fread($instr,fi lesize("latest. img"));
}
// If this is the image request, send out the image
if ($_REQUEST[gim] == 1) {
header("Content-type: image/jpeg");
print $bytes;
exit ();
}
?>
<html>
<body>
<script type='text/javascript'>
function formValidator() {
var name = document.getEle mentById('name' );
var email = document.getEle mentById('email ');
var city = document.getEle mentById('city' );
var state = document.getEle mentById('state ');
var country = document.getEle mentById('count ry');
var gender = document.getEle mentById('gende r');
var zip = document.getEle mentById('zip') ;
var upload = document.getEle mentById('uploa d');
var message=documen t.getElementByI d('message');
if(isAlphabet(n ame, "Please enter only letters for name"))
{
if(emailValidat or(email, "Please enter a valid email address"))
{
if(isAlphabet(c ity,"please enter only letters for city"))
{
if(isAlphabet(s tate,"please enter only letters for state"))
{
if(isAlphabet(s tate,"please enter only letters for country"))
{
if(modeSelectio n(gender, "Please Choose gender"))
{
if(len(zip,"Ple ase enter 6 characters only for zip code"))
{
if(isEmpty(uplo ad, "Please upload your photo"))
{
return true;
}}
}
} }}}
}
return false;
}
function isAlphabet(elem , helperMsg)
{
var alphaExp = /^[a-zA-Z]+$/;
if(elem.value.m atch(alphaExp))
{
return true;
}
else
{
alert(helperMsg );
elem.focus();
return false;
}
}
function isEmpty(elem, helperMsg)
{
if(elem.value.l ength == 0)
{
alert(helperMsg );
elem.focus();
// set the focus to this input
return false;
}
return true;
}
function isAlphanumeric( elem, helperMsg)
{
var alphaExp = /^[0-9a-zA-Z]+$/;
if(elem.value.m atch(alphaExp))
{
return true;
}
else
{
alert(helperMsg );
elem.focus();
return false;
}
}
function len (elem,helperMsg )
{
var uInput = elem.value;
if(uInput.lengt h == 6)
{
if(isNumeric(el em,helperMsg))
{
return true;
}
else
{
// alert("Please enter numeric characters only for zip code");
elem.focus();
return false;
}
}
else{
alert("Please enter 6digits only for zip code");
elem.focus();
return false; }
}
function isNumeric(elem, helperMsg)
{
var numericExpressi on = /^[0-9]+$/;
if(elem.value.m atch(numericExp ression))
{
return true;
}
else
{
alert(helperMsg );
elem.focus();
return false;
}
}
function modeSelection(e lem, helperMsg)
{
if(elem.value == "select")
{
alert(helperMsg );
elem.focus();
return false;
}
else
{
return true;
}
}
function emailValidator( elem, helperMsg)
{
var emailExp = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/;
if(elem.value.m atch(emailExp))
{
return true;
}
else
{
alert(helperMsg );
elem.focus();
return false;
}
}
</script>
<body bgcolor=white>< h2>Here's the latest picture</h2>
<font color=red><?= $errmsg ?></font>
<tr align="left">
<td>
<iframe width="425" height="350" frameborder="0" scrolling="no" marginheight="0 " marginwidth="0" src="http://maps.google.com/?ie=UTF8&z= 4&ll=37.062 5,-95.677068&o utput=embed& ;s=AARTsJqzARj-Z8VnW5pkPMLMmZb qrJcYpw"></iframe><br /><small><a href="http://maps.google.com/?ie=UTF8&z= 4&ll=37.062 5,-95.677068&s ource=embed" style="color:#0 000FF;text-align:left">Vie w Larger Map</a></small>
</td>
</tr>
<tr>
<td>
<center><img src=?gim=1 width=350 height=200><br>
<b><?= $title ?></center>
</td>
</tr>
<hr>
<h1><i><center> <font color=blue>Add Your Greeting</font></i></h1>
<center>
<form onSubmit='retur n formValidator() ' method=post enctype=multipa rt/form-data>
<input type=hidden name=MAX_FILE_S IZE value=150000>
<input type=hidden name=completed value=1>
<center><tabl e border=1 bordercolorligh t ="black" bordercolordark ="#D4D4D4" bgcolor= "#BBBBBB
">
<tr>
<td>
<table cellpadding="0" cellspacing="0" border="0" width="600" summary="Create user account">
<tr> <td> <p>Fields marked <font color=red>* </font>are required</p></td><td> </td></tr>
<tr >
<td align="right" width="150">Nam e <font color=red>*</font></td>
<td align="right" width="150">
<input type="text" name="name" id="name" onChange="retur n isAlphabet(this ,'please enter charactersonly' )"> </td>
</tr>
<tr> <td colspan="3" nowrap height="20"><sp acer type="vertical" height="10"></td></tr>
<tr >
<td align="right" width="150">Ema il<font color=red>*</font></td>
<td align="right" width="150"><in put type="text" id="email" name="email" width="150" maxLength="20" onChange=" return emailValidator( this,'not a valid email id')">
</td>
</tr>
<tr> <td colspan="3" nowrap height="20"><sp acer type="vertical" height="10"></td></tr>
<tr>
<td align="right" width="150">Cit y <font color=red>*</font></td>
<td align="right" width="150">
<input type="text" name="city" id="city" onChange="retur n isAlphabet(this ,'please enter charactersonly' )"> </td>
</tr>
<tr> <td colspan="3" nowrap height="20"><sp acer type="vertical" height="10"></td></tr>
<tr>
<td align="right" width="150">Sta te <font color=red>*</font></td>
<td align="right" width="150">
<input type="text" name="state" id="state" onChange="retur n isAlphabet(this ,'please enter charactersonly' )"> </td>
</tr>
<tr> <td colspan="3" nowrap height="20"><sp acer type="vertical" height="10"></td></tr>
<tr>
<td align="right" width="150">Cou ntry<font color=red>*</font></td>
<td align="right" width="150">
<SELECT id='country' name='country' onchange='retur n isAlphabet(this ,'please enter charactersonly' )'><OPTION>choo se a country</OPTION> <OPTION>Unite d States</OPTION> <OPTION>Unite d Kingdom</OPTION> <OPTION>Canad a</OPTION> <OPTION>Afghani stan</OPTION> <OPTION>Albania </OPTION> <OPTION>Algeria </OPTION> <OPTION>Andorra </OPTION> <OPTION>Angol a</OPTION> <OPTION>Anguill a</OPTION> <OPTION>Antarct ica</OPTION> <OPTION>Antig ua and Barbuda</OPTION> <OPTION>Argenti na</OPTION> <OPTION>Armenia </OPTION> <OPTION>Aruba </OPTION> <OPTION>Austral ia</OPTION> <OPTION>Austria </OPTION> <OPTION>Azerbai jan</OPTION> <OPTION>Bahamas </OPTION> <OPTION>Bahrain </OPTION> <OPTION>Bangald esh</OPTION> <OPTION>Barbado s</OPTION> <OPTION>Belgium </OPTION> <OPTION>Beliz e</OPTION> <OPTION>Belarus </OPTION> <OPTION>Benin </OPTION> <OPTION>Bermuda </OPTION> <OPTION>Bhuta n</OPTION> <OPTION>Bolivia </OPTION> <OPTION>Bosni a andHerzegovina</OPTION> <OPTION>Botswan a</OPTION> <OPTION>Brazi l</OPTION> <OPTION>Brune i</OPTION> <OPTION>Bulgari a</OPTION> <OPTION>Burki na Faso</OPTION> <OPTION>Burundi </OPTION> <OPTION>Cambodi a</OPTION> <OPTION>Cameroo n</OPTION> <OPTION>Cape Verde</OPTION> <OPTION>Cayma n Islands</OPTION> <OPTION>Centr al African Republic</OPTION> <OPTION>Chile </OPTION> <OPTION>China </OPTION> <OPTION>Christm as Island</OPTION> <OPTION>Colombi a</OPTION> <OPTION>Comoros </OPTION> <OPTION>Congo </OPTION> <OPTION>Democra tic Republic of the Congo</OPTION> <OPTION>Cook Islands</OPTION> <OPTION>Costa Rica</OPTION> <OPTION>Cote DIvoire</OPTION> <OPTION>Croatia </OPTION> <OPTION>Cuba</OPTION><OPTION >Cyprus</OPTION><OPTION >Czech Republic</OPTION><OPTION >Denmark</OPTION><OPTION >Djibouti</OPTION><OPTION >Dominica</OPTION><OPTION >Dominican Republic</OPTION><OPTION >Ecuador</OPTION><OPTION >Egypt</OPTION><OPTION >El Salvador</OPTION><OPTION >Equitorial Guinea</OPTION><OPTION >Eritrea</OPTION><OPTION >Estonia</OPTION><OPTION >Ethiopia</OPTION><OPTION >Falkland Islands</OPTION><OPTION >Fiji</OPTION><OPTION >Finland</OPTION><OPTION >France</OPTION> <OPTION>Frenc h Guiana</OPTION><OPTION >French Polynesia</OPTION><OPTION >Gabon</OPTION><OPTION >Gambia</OPTION> <OPTION>Germany </OPTION><OPTION >Georgia</OPTION> <OPTION>S Georgia and the S Sandwich Is</OPTION> <OPTION>Ghana </OPTION> <OPTION>Greec e</OPTION> <OPTION>Greenla nd</OPTION><OPTION >Grenada</OPTION> <OPTION>Guadelo upe</OPTION> <OPTION>Guam</OPTION> <OPTION>Guatema la</OPTION> <OPTION>Guine a</OPTION> <OPTION>Guine a Bissau</OPTION> <OPTION>Guyan a</OPTION> <OPTION>Haiti </OPTION> <OPTION>Hondura s</OPTION> <OPTION>Hong Kong</OPTION> <OPTION>Hungary </OPTION> <OPTION>Iceland </OPTION><OPTION >India</OPTION> <OPTION>Indones ia</OPTION> <OPTION>Iran</OPTION><OPTION >Iraq</OPTION> <OPTION>Ireland </OPTION> <OPTION>Israe l</OPTION><OPTION >Italy</OPTION> <OPTION>Jamaica </OPTION> <OPTION>Japan </OPTION><OPTION >Jordan</OPTION> <OPTION>Kazakhs tan</OPTION> <OPTION>Kenya </OPTION><OPTION >Kiribati</OPTION> <OPTION>St. Kitts and Nevis</OPTION> <OPTION>North Korea</OPTION> <OPTION>South Korea</OPTION> <OPTION>Kyrgyzs tan</OPTION><OPTION >Kuwait</OPTION> <OPTION>Laos</OPTION> <OPTION>Latvi a</OPTION> <OPTION>Lebanon </OPTION> <OPTION>Lesotho </OPTION> <OPTION>Liberia </OPTION><OPTION >Libya</OPTION><OPTION >Liechtenstei n</OPTION> <OPTION>Lithuan ia</OPTION> <OPTION>Luxembo urg</OPTION><OPTION >Macau</OPTION> <OPTION>Macedon ia</OPTION> <OPTION>Madagas car</OPTION> <OPTION>Malaysi a</OPTION> <OPTION>Maldive s</OPTION> <OPTION>Mali</OPTION> <OPTION>Marshal l Islands</OPTION> <OPTION>Malta </OPTION> <OPTION>Norther n Mariana Islands</OPTION><OPTION >Malawi</OPTION> <OPTION>Martini que</OPTION> <OPTION>Maurita nia</OPTION><OPTION >Mauritius</OPTION> <OPTION>Mayotte </OPTION> <OPTION>Mexic o</OPTION> <OPTION> Micronesia</OPTION> <OPTION>Moldova </OPTION> <OPTION>Mongoli a</OPTION> <OPTION>Montser rat</OPTION> <OPTION>Morocco </OPTION> <OPTION>Mozambi que</OPTION> <OPTION>Myanmar </OPTION> <OPTION>Namibia </OPTION> <OPTION>Nauru </OPTION> <OPTION>Nepal </OPTION> <OPTION>Netherl ands</OPTION><OPTION >Netherlands Antilles</OPTION><OPTION >New Caledonia</OPTION> <OPTION>New Zealand</OPTION> <OPTION>Nicarag ua</OPTION> <OPTION>Niger </OPTION> <OPTION>Nigeria </OPTION> <OPTION>Niue</OPTION> <OPTION>Norwa y</OPTION> <OPTION>Oman</OPTION> <OPTION>Pakista n</OPTION> <OPTION>Palau </OPTION> <OPTION>Panam a</OPTION> <OPTION>Papua New Guinea</OPTION><OPTION >Paraguay</OPTION> <OPTION>Peru</OPTION> <OPTION>Philipp ines</OPTION> <OPTION>Pitcair n Islands</OPTION><OPTION >Poland</OPTION> <OPTION>Portuga l</OPTION> <OPTION>Puert o Rico</OPTION> <OPTION>Qatar </OPTION> <OPTION>Reunion </OPTION> <OPTION>Romania </OPTION><OPTION >Russia</OPTION> <OPTION>Rwand a</OPTION> <OPTION>St. Lucia</OPTION><OPTION >Saint Vincent and the Grenadines</OPTION> <OPTION>Samoa American</OPTION> <OPTION>Samoa </OPTION><OPTION >San Marino</OPTION> <OPTION>Sao Tome and Principe</OPTION> <OPTION>Saudi Arabia</OPTION> <OPTION>Senegal </OPTION> <OPTION>Seychel les</OPTION> <OPTION>Sierr a Leone</OPTION> <OPTION>Singapo re</OPTION> <OPTION>Slovaki a</OPTION> <OPTION>Sloveni a</OPTION><OPTION >Solomon Islands</OPTION><OPTION >Somalia</OPTION><OPTION >South Africa</OPTION> <OPTION>Spain </OPTION> <OPTION>Sri Lanka</OPTION><OPTION >Sudan</OPTION> <OPTION>Surinam e</OPTION> <OPTION>Swazila nd</OPTION><OPTION >Sweden</OPTION> <OPTION>Switzer land</OPTION> <OPTION>Syria </OPTION><OPTION >Taiwan</OPTION> <OPTION>Tajikis tan</OPTION> <OPTION>Tanzani a</OPTION><OPTION >Thailand</OPTION> <OPTION>Togo</OPTION> <OPTION>Tonga </OPTION> <OPTION>Trinida d and Tobago</OPTION> <OPTION>Tunisia </OPTION> <OPTION>Turke y</OPTION><OPTION >Turkmenistan </OPTION> <OPTION>Tuval u</OPTION><OPTION >Uganda</OPTION><OPTION >Ukraine</OPTION> <OPTION>Unite d Arab Emirates</OPTION><OPTION >Uruguay</OPTION> <OPTION>Uzbekis tan</OPTION><OPTION >Vanuatu</OPTION><OPTION >Vatican City</OPTION> <OPTION>Venezue la</OPTION> <OPTION>Virgi n Islands</OPTION><OPTION >Vietnam</OPTION> <OPTION>Weste rn Sahara</OPTION> <OPTION>Yemen </OPTION><OPTION >Yugoslavia</OPTION> <OPTION>Zambi a</OPTION> <OPTION>Zimbabw e</OPTION><OPTION >APO</OPTION> <OPTION>FPO</OPTION> <OPTION>Other </OPTION><OPTION >Bouvet Island</OPTION> <OPTION>Briti sh Indian Ocean Territory</OPTION><OPTION >Chad</OPTION> <OPTION>Cocos Keeling Islands</OPTION><OPTION >East Timor</OPTION><OPTION >Faroe Islands</OPTION><OPTION >French Southern Territories</OPTION> <OPTION>Gibralt ar</OPTION><OPTION >Heard and McDonald Islands</OPTION><OPTION >Monaco</OPTION><OPTION >Norfolk Island</OPTION> <OPTION>St. Helena</OPTION><OPTION >St. Pierre and Miquelon</OPTION><OPTION >Svalbard and Jan Mayen Islands</OPTION> <OPTION>Tokelau </OPTION> <OPTION>Turks and Caicos Islands</OPTION> <OPTION>Unite d States Minor Outlying Islands</OPTION><OPTION >Wallis and Futuna Islands</OPTION> <OPTION>Briti sh Virgin Islands</OPTION></SELECT>
</div><br/>
<tr> <td colspan="3" nowrap height="20"><sp acer type="vertical" height="10"></td></tr>
<tr>
<td align="right" width="150">Dat eofbirth<font color=red>*</font></td>
<td align="right" width="150">
<SELECT id='m_BIRTHMONT H' name='month'><O PTION>choose month</OPTION> <OPTION>January </OPTION> <OPTION>Februar y</OPTION> <OPTION>March </OPTION> <OPTION>April </OPTION> <OPTION>May</OPTION> <OPTION>June</OPTION> <OPTION>July</OPTION> <OPTION>Augus t</OPTION> <OPTION>Septemb er</OPTION> <OPTION>October </OPTION> <OPTION>Novembe r</OPTION> <OPTION>Decembe r</OPTION></SELECT>
<SELECT id='m_BIRTHDAY' name='date' ><OPTION>day</OPTION> <OPTION>1</OPTION> <OPTION>2</OPTION><OPTION >3</OPTION> <OPTION>4</OPTION> <OPTION>5</OPTION><OPTION >6</OPTION> <OPTION>7</OPTION> <OPTION>8</OPTION><OPTION >9</OPTION> <OPTION>10</OPTION> <OPTION>11</OPTION><OPTION >12</OPTION> <OPTION>13</OPTION> <OPTION>14</OPTION><OPTION >15</OPTION> <OPTION>16</OPTION> <OPTION>17</OPTION><OPTION >18</OPTION> <OPTION>19</OPTION> <OPTION>20</OPTION><OPTION >21</OPTION> <OPTION>22</OPTION> <OPTION>23</OPTION><OPTION >24</OPTION> <OPTION>25</OPTION> <OPTION>26</OPTION><OPTION >27</OPTION> <OPTION>28</OPTION> <OPTION>29</OPTION><OPTION >30</OPTION> <OPTION>31</OPTION></SELECT>
</div><br/>
</tr>
<tr> <td colspan="3" nowrap height="20"><sp acer type="vertical" height="10"></td></tr>
<tr>
<td align="right" width="150">Gen der<font color=red>*</font></td>
<td align="center" width="150"><se lect id="gender" name="gender" width="150" maxLength="20" onSelect="retur n modeSelection(t his,'Please Choose gender')"> <option value="select"> select</option><option value="M">M</option><option value="F">F</option> </select> </td>
</tr>
<tr> <td colspan="3" nowrap height="20"><sp acer type="vertical" height="10"></td></tr>
<tr>
<td align="right" width="150">Zip </LABEL><font color=red>*</font></td>
<td align="right" width="150"><in put type="text" id="zip" name="zip" width="150" maxLength="6" onChange=" return len(this,'pleas e enter only 6 characters for zip code')"></td>
</tr>
<tr> <td colspan="3" nowrap height="20"><sp acer type="vertical" height="10"></td></tr>
<tr >
<td align="right" width="150">You r Greeting</LABEL></td>
<td align="right" width="150"> <textarea name="message" id="message" cols="30" rows="6"></textarea></td>
</tr>
<tr> <td colspan="3" nowrap height="20"><sp acer type="vertical" height="10"></td></tr>
<tr>
<td align="right" width="150">You r Photo</LABEL><font color=red>*</font></td>
<td align="right" width="150"><in put type="file" id="upload" name="upload" width="150" maxLength="20" onChange=" return isEmpty(this,'p lease upload photo')"> </td>
</tr>
<tr> <td colspan="3" nowrap height="20"><sp acer type="vertical" height="10"></td></tr>
<tr>
<td align="right" width="150"> <input type="submit" value="Save" width="150" maxLength="20"> </td>
<td align="left" width="150"> <input type="reset" value="clear" width="150" maxLength="20"> </td>
</tr>
</table>
</td></tr></table>
</form>
</body>
</html>[/php]
Please enclose any code within the proper code tags!!. See the Posting Guidelines on how to do that. - moderator
Comment