By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,127 Members | 1,115 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,127 IT Pros & Developers. It's quick & easy.

problem in connecting to map with image

P: 10
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","root","sreeni")) {
$errmsg = "Cannot connect to database";
}
@mysql_select_db("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),email varchar(30),city varchar(20),state varchar(20),zip int(7),country varchar(20),month varchar(20),date 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_file($_FILES['upload']['tmp_name'],"latest.img");
$instr = fopen("latest.img","rb");
$image = addslashes(fread($instr,filesize("latest.img")));
if (strlen($instr) < 149000) {
mysql_query ("INSERT INTO pix(name, email, city, state, zip, country, month, date, upload) VALUES('".$_POST['name']."', '".$_POST['email']."', '".$_POST['city']."', '".$_POST['state']."', '".$_POST['zip']."', '".$_POST['country']."', '".$_POST['month']."', '".$_POST['date']."', '".$image."')");
mysql_query ("insert into pix (name,email,city,state,zip,country,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("select * from pix order by pid desc");
if ($row = @mysql_fetch_assoc($gotten)) {
$name = htmlspecialchars($row[name]);
$email = htmlspecialchars($row[email]);
$city = htmlspecialchars($row[city]);
$state = htmlspecialchars($row[state]);
$zip = htmlspecialchars($row[zip]);
$country = htmlspecialchars($row[country]);
$month = htmlspecialchars($row[month]);
$date = htmlspecialchars($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.img","rb");
$bytes = fread($instr,filesize("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.getElementById('name');
var email = document.getElementById('email');
var city = document.getElementById('city');
var state = document.getElementById('state');
var country = document.getElementById('country');
var gender = document.getElementById('gender');
var zip = document.getElementById('zip');
var upload = document.getElementById('upload');
var message=document.getElementById('message');
if(isAlphabet(name, "Please enter only letters for name"))
{
if(emailValidator(email, "Please enter a valid email address"))
{
if(isAlphabet(city,"please enter only letters for city"))
{
if(isAlphabet(state,"please enter only letters for state"))
{
if(isAlphabet(state,"please enter only letters for country"))
{
if(modeSelection(gender, "Please Choose gender"))
{
if(len(zip,"Please enter 6 characters only for zip code"))
{
if(isEmpty(upload, "Please upload your photo"))
{
return true;
}}
}
} }}}
}
return false;
}
function isAlphabet(elem, helperMsg)
{
var alphaExp = /^[a-zA-Z]+$/;
if(elem.value.match(alphaExp))
{
return true;
}
else
{
alert(helperMsg);
elem.focus();
return false;
}
}
function isEmpty(elem, helperMsg)
{
if(elem.value.length == 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.match(alphaExp))
{
return true;
}
else
{
alert(helperMsg);
elem.focus();
return false;
}
}
function len (elem,helperMsg)
{
var uInput = elem.value;
if(uInput.length == 6)
{
if(isNumeric(elem,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 numericExpression = /^[0-9]+$/;
if(elem.value.match(numericExpression))
{
return true;
}
else
{
alert(helperMsg);
elem.focus();
return false;
}
}
function modeSelection(elem, 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.match(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&amp;z=4&amp;ll=37.0625,-95.677068&amp;output=embed&amp;s=AARTsJqzARj-Z8VnW5pkPMLMmZbqrJcYpw"></iframe><br /><small><a href="http://maps.google.com/?ie=UTF8&amp;z=4&amp;ll=37.0625,-95.677068&amp;source=embed" style="color:#0000FF;text-align:left">View 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='return formValidator()' method=post enctype=multipart/form-data>
<input type=hidden name=MAX_FILE_SIZE value=150000>
<input type=hidden name=completed value=1>
<center><table border=1 bordercolorlight ="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">Name <font color=red>*</font></td>
<td align="right" width="150">
<input type="text" name="name" id="name" onChange="return isAlphabet(this,'please enter charactersonly')"> </td>
</tr>
<tr> <td colspan="3" nowrap height="20"><spacer type="vertical" height="10"></td></tr>
<tr >
<td align="right" width="150">Email<font color=red>*</font></td>
<td align="right" width="150"><input 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"><spacer type="vertical" height="10"></td></tr>
<tr>
<td align="right" width="150">City <font color=red>*</font></td>
<td align="right" width="150">
<input type="text" name="city" id="city" onChange="return isAlphabet(this,'please enter charactersonly')"> </td>
</tr>
<tr> <td colspan="3" nowrap height="20"><spacer type="vertical" height="10"></td></tr>
<tr>
<td align="right" width="150">State <font color=red>*</font></td>
<td align="right" width="150">
<input type="text" name="state" id="state" onChange="return isAlphabet(this,'please enter charactersonly')"> </td>
</tr>
<tr> <td colspan="3" nowrap height="20"><spacer type="vertical" height="10"></td></tr>
<tr>
<td align="right" width="150">Country<font color=red>*</font></td>
<td align="right" width="150">
<SELECT id='country' name='country' onchange='return isAlphabet(this,'please enter charactersonly')'><OPTION>choose a country</OPTION> <OPTION>United States</OPTION> <OPTION>United Kingdom</OPTION> <OPTION>Canada</OPTION> <OPTION>Afghanistan</OPTION> <OPTION>Albania</OPTION> <OPTION>Algeria</OPTION> <OPTION>Andorra</OPTION> <OPTION>Angola</OPTION> <OPTION>Anguilla</OPTION> <OPTION>Antarctica</OPTION> <OPTION>Antigua and Barbuda</OPTION> <OPTION>Argentina</OPTION> <OPTION>Armenia</OPTION> <OPTION>Aruba</OPTION> <OPTION>Australia</OPTION> <OPTION>Austria</OPTION> <OPTION>Azerbaijan</OPTION> <OPTION>Bahamas</OPTION> <OPTION>Bahrain</OPTION> <OPTION>Bangaldesh</OPTION> <OPTION>Barbados</OPTION> <OPTION>Belgium</OPTION> <OPTION>Belize</OPTION> <OPTION>Belarus</OPTION> <OPTION>Benin</OPTION> <OPTION>Bermuda</OPTION> <OPTION>Bhutan</OPTION> <OPTION>Bolivia</OPTION> <OPTION>Bosnia andHerzegovina</OPTION> <OPTION>Botswana</OPTION> <OPTION>Brazil</OPTION> <OPTION>Brunei</OPTION> <OPTION>Bulgaria</OPTION> <OPTION>Burkina Faso</OPTION> <OPTION>Burundi</OPTION> <OPTION>Cambodia</OPTION> <OPTION>Cameroon</OPTION> <OPTION>Cape Verde</OPTION> <OPTION>Cayman Islands</OPTION> <OPTION>Central African Republic</OPTION> <OPTION>Chile</OPTION> <OPTION>China</OPTION> <OPTION>Christmas Island</OPTION> <OPTION>Colombia</OPTION> <OPTION>Comoros</OPTION> <OPTION>Congo</OPTION> <OPTION>Democratic 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>French 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>Greece</OPTION> <OPTION>Greenland</OPTION><OPTION >Grenada</OPTION> <OPTION>Guadeloupe</OPTION> <OPTION>Guam</OPTION> <OPTION>Guatemala</OPTION> <OPTION>Guinea</OPTION> <OPTION>Guinea Bissau</OPTION> <OPTION>Guyana</OPTION> <OPTION>Haiti</OPTION> <OPTION>Honduras</OPTION> <OPTION>Hong Kong</OPTION> <OPTION>Hungary</OPTION> <OPTION>Iceland</OPTION><OPTION >India</OPTION> <OPTION>Indonesia</OPTION> <OPTION>Iran</OPTION><OPTION >Iraq</OPTION> <OPTION>Ireland</OPTION> <OPTION>Israel</OPTION><OPTION >Italy</OPTION> <OPTION>Jamaica</OPTION> <OPTION>Japan</OPTION><OPTION >Jordan</OPTION> <OPTION>Kazakhstan</OPTION> <OPTION>Kenya</OPTION><OPTION >Kiribati</OPTION> <OPTION>St. Kitts and Nevis</OPTION> <OPTION>North Korea</OPTION> <OPTION>South Korea</OPTION> <OPTION>Kyrgyzstan</OPTION><OPTION >Kuwait</OPTION> <OPTION>Laos</OPTION> <OPTION>Latvia</OPTION> <OPTION>Lebanon</OPTION> <OPTION>Lesotho</OPTION> <OPTION>Liberia</OPTION><OPTION >Libya</OPTION><OPTION >Liechtenstein</OPTION> <OPTION>Lithuania</OPTION> <OPTION>Luxembourg</OPTION><OPTION >Macau</OPTION> <OPTION>Macedonia</OPTION> <OPTION>Madagascar</OPTION> <OPTION>Malaysia</OPTION> <OPTION>Maldives</OPTION> <OPTION>Mali</OPTION> <OPTION>Marshall Islands</OPTION> <OPTION>Malta</OPTION> <OPTION>Northern Mariana Islands</OPTION><OPTION >Malawi</OPTION> <OPTION>Martinique</OPTION> <OPTION>Mauritania</OPTION><OPTION >Mauritius</OPTION> <OPTION>Mayotte</OPTION> <OPTION>Mexico</OPTION> <OPTION> Micronesia</OPTION> <OPTION>Moldova</OPTION> <OPTION>Mongolia</OPTION> <OPTION>Montserrat</OPTION> <OPTION>Morocco</OPTION> <OPTION>Mozambique</OPTION> <OPTION>Myanmar</OPTION> <OPTION>Namibia</OPTION> <OPTION>Nauru</OPTION> <OPTION>Nepal</OPTION> <OPTION>Netherlands</OPTION><OPTION >Netherlands Antilles</OPTION><OPTION >New Caledonia</OPTION> <OPTION>New Zealand</OPTION> <OPTION>Nicaragua</OPTION> <OPTION>Niger</OPTION> <OPTION>Nigeria</OPTION> <OPTION>Niue</OPTION> <OPTION>Norway</OPTION> <OPTION>Oman</OPTION> <OPTION>Pakistan</OPTION> <OPTION>Palau</OPTION> <OPTION>Panama</OPTION> <OPTION>Papua New Guinea</OPTION><OPTION >Paraguay</OPTION> <OPTION>Peru</OPTION> <OPTION>Philippines</OPTION> <OPTION>Pitcairn Islands</OPTION><OPTION >Poland</OPTION> <OPTION>Portugal</OPTION> <OPTION>Puerto Rico</OPTION> <OPTION>Qatar</OPTION> <OPTION>Reunion</OPTION> <OPTION>Romania</OPTION><OPTION >Russia</OPTION> <OPTION>Rwanda</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>Seychelles</OPTION> <OPTION>Sierra Leone</OPTION> <OPTION>Singapore</OPTION> <OPTION>Slovakia</OPTION> <OPTION>Slovenia</OPTION><OPTION >Solomon Islands</OPTION><OPTION >Somalia</OPTION><OPTION >South Africa</OPTION> <OPTION>Spain</OPTION> <OPTION>Sri Lanka</OPTION><OPTION >Sudan</OPTION> <OPTION>Suriname</OPTION> <OPTION>Swaziland</OPTION><OPTION >Sweden</OPTION> <OPTION>Switzerland</OPTION> <OPTION>Syria</OPTION><OPTION >Taiwan</OPTION> <OPTION>Tajikistan</OPTION> <OPTION>Tanzania</OPTION><OPTION >Thailand</OPTION> <OPTION>Togo</OPTION> <OPTION>Tonga</OPTION> <OPTION>Trinidad and Tobago</OPTION> <OPTION>Tunisia</OPTION> <OPTION>Turkey</OPTION><OPTION >Turkmenistan</OPTION> <OPTION>Tuvalu</OPTION><OPTION >Uganda</OPTION><OPTION >Ukraine</OPTION> <OPTION>United Arab Emirates</OPTION><OPTION >Uruguay</OPTION> <OPTION>Uzbekistan</OPTION><OPTION >Vanuatu</OPTION><OPTION >Vatican City</OPTION> <OPTION>Venezuela</OPTION> <OPTION>Virgin Islands</OPTION><OPTION >Vietnam</OPTION> <OPTION>Western Sahara</OPTION> <OPTION>Yemen</OPTION><OPTION >Yugoslavia</OPTION> <OPTION>Zambia</OPTION> <OPTION>Zimbabwe</OPTION><OPTION >APO</OPTION> <OPTION>FPO</OPTION> <OPTION>Other</OPTION><OPTION >Bouvet Island</OPTION> <OPTION>British 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>Gibraltar</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>United States Minor Outlying Islands</OPTION><OPTION >Wallis and Futuna Islands</OPTION> <OPTION>British Virgin Islands</OPTION></SELECT>
</div><br/>
<tr> <td colspan="3" nowrap height="20"><spacer type="vertical" height="10"></td></tr>
<tr>
<td align="right" width="150">Dateofbirth<font color=red>*</font></td>
<td align="right" width="150">
<SELECT id='m_BIRTHMONTH' name='month'><OPTION>choose month</OPTION> <OPTION>January</OPTION> <OPTION>February</OPTION> <OPTION>March</OPTION> <OPTION>April</OPTION> <OPTION>May</OPTION> <OPTION>June</OPTION> <OPTION>July</OPTION> <OPTION>August</OPTION> <OPTION>September</OPTION> <OPTION>October</OPTION> <OPTION>November</OPTION> <OPTION>December</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"><spacer type="vertical" height="10"></td></tr>
<tr>
<td align="right" width="150">Gender<font color=red>*</font></td>
<td align="center" width="150"><select id="gender" name="gender" width="150" maxLength="20" onSelect="return modeSelection(this,'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"><spacer type="vertical" height="10"></td></tr>
<tr>
<td align="right" width="150">Zip</LABEL><font color=red>*</font></td>
<td align="right" width="150"><input type="text" id="zip" name="zip" width="150" maxLength="6" onChange=" return len(this,'please enter only 6 characters for zip code')"></td>
</tr>
<tr> <td colspan="3" nowrap height="20"><spacer type="vertical" height="10"></td></tr>
<tr >
<td align="right" width="150">Your 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"><spacer type="vertical" height="10"></td></tr>
<tr>
<td align="right" width="150">Your Photo</LABEL><font color=red>*</font></td>
<td align="right" width="150"><input type="file" id="upload" name="upload" width="150" maxLength="20" onChange=" return isEmpty(this,'please upload photo')"> </td>
</tr>
<tr> <td colspan="3" nowrap height="20"><spacer 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
Mar 5 '08 #1
Share this Question
Share on Google+
1 Reply


ronverdonk
Expert 2.5K+
P: 4,258
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.
followed by a bunch (approx 300 lines) of unreadable code, since it is not enclosed within code tags! Read the Posting Guidelines before you post any code in this forum.

You'd have to explain your problem a bit more descriptive, because I do not understand what it is that you want or have a problem with.

Ronald
Mar 7 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.