I'm passing form data as JSON via AJAX to a PHP file which then saves the JSON in a text file on the server.
The problem is that when I use FILE_APPEND the data is not written on the file when the JSON data already exists in the text file.
My HTML code is:
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="eloqua.css">
<script src="http://code.jquery.com/jquery-1.9.0.js"></script>
<script type="text/javascript">
$(document).ready(function(){
localStorage.clear();
$("form").on("submit", function() {
if(window.localStorage!==undefined) {
var fields = $(this).serialize();
localStorage.setItem("eloqua-fields", JSON.stringify( fields ));
alert("Stored Succesfully");
$(this).find("input[type=text]").val("");
alert("Now Passing stored data to Server through AJAX jQuery");
$.ajax({
type: "POST",
url: "backend.php",
data: fields
});
} else {
alert("Storage Failed. Try refreshing");
}
});
});
</script>
<script type="text/javascript">
function validateForm()
{
var a=document.forms["EloquaForm"]["C_FirstName"].value;
if (a==null || a=="")
{
alert("First name must be filled out");
return false;
}
var b=document.forms["EloquaForm"]["C_LastName"].value;
if (b==null || b=="")
{
alert("Last name must be filled out");
return false;
}
var y=document.forms["EloquaForm"]["C_EmailAddress"].value;
var atpos=y.indexOf("#");
var dotpos=y.lastIndexOf(".");
if (atpos<1 || dotpos<atpos+2 || dotpos+2>=y.length)
{
alert("Not a valid e-mail address");
return false;
}
}
</script>
</head>
<body>
<p><img src="red-asterix.jpeg"> indicates a required field</p>
<div class="form-container" style="width: 625px">
<form class="form-eloqua" name="EloquaForm" action="http://s33.t.eloqua.com/e/f2" onsubmit="return validateForm();" method="post">
<span class="form-eloqua-label"><span>First Name</span></span><input id="firstname" type="text" name="C_FirstName" />
<span class="form-eloqua-label"><span>Last Name</span></span><input id="lastname" type="text" name="C_LastName" />
<span class="form-eloqua-label"><span>Email Address</span></span><input id="email" type="text" name="C_EmailAddress" />
<span class="form-eloqua-label">Title</span><input id="title" type="text" name="C_Title" />
<span class="form-eloqua-label">Company</span><input id="company" type="text" name="C_Company" />
<span class="form-eloqua-label">ZIP or Postal Code</span><input id="postcode" type="text" name="zipOrPostalCode" />
<span class="form-eloqua-label">Country</span><select id="country" name="country">
<option value="">Please select ...</option>
<option value="AF">Afghanistan</option>
<option value="AL">Albania</option>
<option value="DZ">Algeria</option>
<option value="AS">American Samoa</option>
<option value="AD">Andorra</option>
<option value="AG">Angola</option>
<option value="AI">Anguilla</option>
<option value="AG">Antigua & Barbuda</option>
<option value="AR">Argentina</option>
<option value="AA">Armenia</option>
<option value="AW">Aruba</option>
<option value="AU">Australia</option>
<option value="AT">Austria</option>
<option value="AZ">Azerbaijan</option>
<option value="BS">Bahamas</option>
<option value="BH">Bahrain</option>
<option value="BD">Bangladesh</option>
<option value="BB">Barbados</option>
<option value="BY">Belarus</option>
<option value="BE">Belgium</option>
<option value="BZ">Belize</option>
<option value="BJ">Benin</option>
<option value="BM">Bermuda</option>
<option value="BT">Bhutan</option>
<option value="BO">Bolivia</option>
<option value="BL">Bonaire</option>
<option value="BA">Bosnia & Herzegovina</option>
<option value="BW">Botswana</option>
<option value="BR">Brazil</option>
<option value="BC">British Indian Ocean Ter</option>
<option value="BN">Brunei</option>
<option value="BG">Bulgaria</option>
<option value="BF">Burkina Faso</option>
<option value="BI">Burundi</option>
<option value="KH">Cambodia</option>
<option value="CM">Cameroon</option>
<option value="CA">Canada</option>
<option value="IC">Canary Islands</option>
<option value="CV">Cape Verde</option>
<option value="KY">Cayman Islands</option>
<option value="CF">Central African Republic</option>
<option value="TD">Chad</option>
<option value="CD">Channel Islands</option>
<option value="CL">Chile</option>
<option value="CN">China</option>
<option value="CI">Christmas Island</option>
<option value="CS">Cocos Island</option>
<option value="CO">Colombia</option>
<option value="CC">Comoros</option>
<option value="CG">Congo</option>
<option value="CK">Cook Islands</option>
<option value="CR">Costa Rica</option>
<option value="CT">Cote D'Ivoire</option>
<option value="HR">Croatia</option>
<option value="CU">Cuba</option>
<option value="CB">Curacao</option>
<option value="CY">Cyprus</option>
<option value="CZ">Czech Republic</option>
<option value="DK">Denmark</option>
<option value="DJ">Djibouti</option>
<option value="DM">Dominica</option>
<option value="DO">Dominican Republic</option>
<option value="TM">East Timor</option>
<option value="EC">Ecuador</option>
<option value="EG">Egypt</option>
<option value="SV">El Salvador</option>
<option value="GQ">Equatorial Guinea</option>
<option value="ER">Eritrea</option>
<option value="EE">Estonia</option>
<option value="ET">Ethiopia</option>
<option value="FA">Falkland Islands</option>
<option value="FO">Faroe Islands</option>
<option value="FJ">Fiji</option>
<option value="FI">Finland</option>
<option value="FR">France</option>
<option value="GF">French Guiana</option>
<option value="PF">French Polynesia</option>
<option value="FS">French Southern Ter</option>
<option value="GA">Gabon</option>
<option value="GM">Gambia</option>
<option value="GE">Georgia</option>
<option value="DE">Germany</option>
<option value="GH">Ghana</option>
<option value="GI">Gibraltar</option>
<option value="GB">Great Britain</option>
<option value="GR">Greece</option>
<option value="GL">Greenland</option>
<option value="GD">Grenada</option>
<option value="GP">Guadeloupe</option>
<option value="GU">Guam</option>
<option value="GT">Guatemala</option>
<option value="GN">Guinea</option>
<option value="GY">Guyana</option>
<option value="HT">Haiti</option>
<option value="HW">Hawaii</option>
<option value="HN">Honduras</option>
<option value="HK">Hong Kong</option>
<option value="HU">Hungary</option>
<option value="IS">Iceland</option>
<option value="IN">India</option>
<option value="ID">Indonesia</option>
<option value="IA">Iran</option>
<option value="IQ">Iraq</option>
<option value="IR">Ireland</option>
<option value="IM">Isle of Man</option>
<option value="IL">Israel</option>
<option value="IT">Italy</option>
<option value="JM">Jamaica</option>
<option value="JP">Japan</option>
<option value="JO">Jordan</option>
<option value="KZ">Kazakhstan</option>
<option value="KE">Kenya</option>
<option value="KI">Kiribati</option>
<option value="NK">Korea North</option>
<option value="KS">Korea South</option>
<option value="KW">Kuwait</option>
<option value="KG">Kyrgyzstan</option>
<option value="LA">Laos</option>
<option value="LV">Latvia</option>
<option value="LB">Lebanon</option>
<option value="LS">Lesotho</option>
<option value="LR">Liberia</option>
<option value="LY">Libya</option>
<option value="LI">Liechtenstein</option>
<option value="LT">Lithuania</option>
<option value="LU">Luxembourg</option>
<option value="MO">Macau</option>
<option value="MK">Macedonia</option>
<option value="MG">Madagascar</option>
<option value="MY">Malaysia</option>
<option value="MW">Malawi</option>
<option value="MV">Maldives</option>
<option value="ML">Mali</option>
<option value="MT">Malta</option>
<option value="MH">Marshall Islands</option>
<option value="MQ">Martinique</option>
<option value="MR">Mauritania</option>
<option value="MU">Mauritius</option>
<option value="ME">Mayotte</option>
<option value="MX">Mexico</option>
<option value="MI">Midway Islands</option>
<option value="MD">Moldova</option>
<option value="MC">Monaco</option>
<option value="MN">Mongolia</option>
<option value="MS">Montserrat</option>
<option value="MA">Morocco</option>
<option value="MZ">Mozambique</option>
<option value="MM">Myanmar</option>
<option value="NA">Nambia</option>
<option value="NU">Nauru</option>
<option value="NP">Nepal</option>
<option value="AN">Netherland Antilles</option>
<option value="NL">Netherlands (Holland, Europe)</option>
<option value="NV">Nevis</option>
<option value="NC">New Caledonia</option>
<option value="NZ">New Zealand</option>
<option value="NI">Nicaragua</option>
<option value="NE">Niger</option>
<option value="NG">Nigeria</option>
<option value="NW">Niue</option>
<option value="NF">Norfolk Island</option>
<option value="NO">Norway</option>
<option value="OM">Oman</option>
<option value="PK">Pakistan</option>
<option value="PW">Palau Island</option>
<option value="PS">Palestine</option>
<option value="PA">Panama</option>
<option value="PG">Papua New Guinea</option>
<option value="PY">Paraguay</option>
<option value="PE">Peru</option>
<option value="PH">Philippines</option>
<option value="PO">Pitcairn Island</option>
<option value="PL">Poland</option>
<option value="PT">Portugal</option>
<option value="PR">Puerto Rico</option>
<option value="QA">Qatar</option>
<option value="ME">Republic of Montenegro</option>
<option value="RS">Republic of Serbia</option>
<option value="RE">Reunion</option>
<option value="RO">Romania</option>
<option value="RU">Russia</option>
<option value="RW">Rwanda</option>
<option value="NT">St Barthelemy</option>
<option value="EU">St Eustatius</option>
<option value="HE">St Helena</option>
<option value="KN">St Kitts-Nevis</option>
<option value="LC">St Lucia</option>
<option value="MB">St Maarten</option>
<option value="PM">St Pierre & Miquelon</option>
<option value="VC">St Vincent & Grenadines</option>
<option value="SP">Saipan</option>
<option value="SO">Samoa</option>
<option value="AS">Samoa American</option>
<option value="SM">San Marino</option>
<option value="ST">Sao Tome & Principe</option>
<option value="SA">Saudi Arabia</option>
<option value="SN">Senegal</option>
<option value="RS">Serbia</option>
<option value="SC">Seychelles</option>
<option value="SL">Sierra Leone</option>
<option value="SG">Singapore</option>
<option value="SK">Slovakia</option>
<option value="SI">Slovenia</option>
<option value="SB">Solomon Islands</option>
<option value="OI">Somalia</option>
<option value="ZA">South Africa</option>
<option value="ES">Spain</option>
<option value="LK">Sri Lanka</option>
<option value="SD">Sudan</option>
<option value="SR">Suriname</option>
<option value="SZ">Swaziland</option>
<option value="SE">Sweden</option>
<option value="CH">Switzerland</option>
<option value="SY">Syria</option>
<option value="TA">Tahiti</option>
<option value="TW">Taiwan</option>
<option value="TJ">Tajikistan</option>
<option value="TZ">Tanzania</option>
<option value="TH">Thailand</option>
<option value="TG">Togo</option>
<option value="TK">Tokelau</option>
<option value="TO">Tonga</option>
<option value="TT">Trinidad & Tobago</option>
<option value="TN">Tunisia</option>
<option value="TR">Turkey</option>
<option value="TU">Turkmenistan</option>
<option value="TC">Turks & Caicos Is</option>
<option value="TV">Tuvalu</option>
<option value="UG">Uganda</option>
<option value="UA">Ukraine</option>
<option value="AE">United Arab Emirates</option>
<option value="GB">United Kingdom</option>
<option value="US">United States of America</option>
<option value="UY">Uruguay</option>
<option value="UZ">Uzbekistan</option>
<option value="VU">Vanuatu</option>
<option value="VS">Vatican City State</option>
<option value="VE">Venezuela</option>
<option value="VN">Vietnam</option>
<option value="VB">Virgin Islands (Brit)</option>
<option value="VA">Virgin Islands (USA)</option>
<option value="WK">Wake Island</option>
<option value="WF">Wallis & Futana Is</option>
<option value="YE">Yemen</option>
<option value="ZR">Zaire</option>
<option value="ZM">Zambia</option>
<option value="ZW">Zimbabwe</option>
</select>
<div class="form-eloqua-separator"></div>
<span class="form-eloqua-label">Annual Revenue Range</span><select name="C_Annual_Revenue1"> <option value="">Please select ...</option> <option value="0-100,000,000">0-100,000,000</option><option value="100,000,001-300,000,000">100,000,001-300,000,000</option><option value="300,000,001-500,000,000">300,000,001-500,000,000</option><option value="500,000,001-2,000,000,000">500,000,001-2,000,000,000</option><option value="2 Billion +">2 Billion +</option></select>
<div class="submit-button"><input type="submit" id="submit" value="Submit" /></div>
<div id="output"></div>
<input type="hidden" name="elqoffer" value="GGB2BContentMktg" />
<input type="hidden" name="elqchannel" value="TheMarketer" />
<input type="hidden" name="elqbq" value="14Q2" />
<input type="hidden" name="elqbc" value="UK" />
<input type="hidden" name="elqFormName" value="2013-Syndication-1372365875136" />
<input type="hidden" name="elqSiteId" value="33" />
</form>
</div>
</body>
</html>
and my PHP code is:
<?php
date_default_timezone_set('America/Chicago'); // CDT
echo '<h2>Server Timezone : ' . date_default_timezone_get() . '</h2>';
$current_date = date('d/m/Y == H:i:s ');
print "<h2>Server Time : " . $current_date . "</h2>";
$dataObject = $_POST; //Fetching all posts
echo "<pre>"; //making the dump look nice in html.
var_dump($dataObject);
echo "</pre>";
//Writes it as json to the file, you can transform it any way you want
$json = json_encode($dataObject);
file_put_contents('your_data.txt', $json . PHP_EOL, FILE_APPEND);
?>
If I understood ( after seeing hackingarticles.com/marketer/your_data.txt).Your code look as working. Try change to:
$file_content = array();
if ( file_exists('your_data.txt')){
$file_content = (array)json_decode(file_get_contents('your_data.txt'));
unlink('your_data.txt');
}
$file_content['users'][] = array('user'=>$_POST);
file_put_contents('your_data.txt',json_encode($file_content));
Related
I have to create new page on website on WP. Also I created custom php code, which taking date from user and return description from MySQL.
Currently I have this in this way. I created file calendar.php. I put this to my wordpress catalog C:\xampp\htdocs\mayancalendar4\calendar.php. I have access to this by http://localhost/mayancalendar4/calendar.php. Problem is I want put the form and result in middle of page (where the 404 info occur), not on the end.
My calendar.php:
<?php
define( 'WP_USE_THEMES', true );
/** Loads the WordPress Environment and Template */
require __DIR__ . '/wp-blog-header.php';
?>
<!DOCTYPE html>
<html>
<section class="container grey-text">
<h4 class="center">Wybierz dzień</h4>
<form class="white" action="calendar.php" method="POST">
<!-- <form class="white" method="POST"> -->
<label for="day">Day</label>
<select id="day" 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>
<label for="month">Month</label>
<select id="month" name="month">
<option value="1">Styczeń</option>
<option value="2">Luty</option>
<option value="3">Marzec</option>
<option value="4">Kwiecień</option>
<option value="5">Maj</option>
<option value="6">Czerwiec</option>
<option value="7">Lipiec</option>
<option value="8">Sierpień</option>
<option value="9">Wrzesień</option>
<option value="10">Październik</option>
<option value="11">Listopad</option>
<option value="12">Grudzień</option>
</select>
<label for="year">Year</label>
<select id="year" name="year">
<option value="1900">1900</option>
<option value="1901">1901</option>
<option value="1902">1902</option>
<option value="1903">1903</option>
<option value="1904">1904</option>
<option value="1905">1905</option>
<option value="1906">1906</option>
<option value="1907">1907</option>
<option value="1908">1908</option>
<option value="1909">1909</option>
<option value="1910">1910</option>
<option value="1911">1911</option>
<option value="1912">1912</option>
<option value="1913">1913</option>
<option value="1914">1914</option>
<option value="1915">1915</option>
<option value="1916">1916</option>
<option value="1917">1917</option>
<option value="1918">1918</option>
<option value="1919">1919</option>
<option value="1920">1920</option>
<option value="1921">1921</option>
<option value="1922">1922</option>
<option value="1923">1923</option>
<option value="1924">1924</option>
<option value="1925">1925</option>
<option value="1926">1926</option>
<option value="1927">1927</option>
<option value="1928">1928</option>
<option value="1929">1929</option>
<option value="1930">1930</option>
<option value="1931">1931</option>
<option value="1932">1932</option>
<option value="1933">1933</option>
<option value="1934">1934</option>
<option value="1935">1935</option>
<option value="1936">1936</option>
<option value="1937">1937</option>
<option value="1938">1938</option>
<option value="1939">1939</option>
<option value="1940">1940</option>
<option value="1941">1941</option>
<option value="1942">1942</option>
<option value="1943">1943</option>
<option value="1944">1944</option>
<option value="1945">1945</option>
<option value="1946">1946</option>
<option value="1947">1947</option>
<option value="1948">1948</option>
<option value="1949">1949</option>
<option value="1950">1950</option>
<option value="1951">1951</option>
<option value="1952">1952</option>
<option value="1953">1953</option>
<option value="1954">1954</option>
<option value="1955">1955</option>
<option value="1956">1956</option>
<option value="1957">1957</option>
<option value="1958">1958</option>
<option value="1959">1959</option>
<option value="1960">1960</option>
<option value="1961">1961</option>
<option value="1962">1962</option>
<option value="1963">1963</option>
<option value="1964">1964</option>
<option value="1965">1965</option>
<option value="1966">1966</option>
<option value="1967">1967</option>
<option value="1968">1968</option>
<option value="1969">1969</option>
<option value="1970">1970</option>
<option value="1971">1971</option>
<option value="1972">1972</option>
<option value="1973">1973</option>
<option value="1974">1974</option>
<option value="1975">1975</option>
<option value="1976">1976</option>
<option value="1977">1977</option>
<option value="1978">1978</option>
<option value="1979">1979</option>
<option value="1980">1980</option>
<option value="1981">1981</option>
<option value="1982">1982</option>
<option value="1983">1983</option>
<option value="1984">1984</option>
<option value="1985">1985</option>
<option value="1986">1986</option>
<option value="1987">1987</option>
<option value="1988">1988</option>
<option value="1989">1989</option>
<option value="1990">1990</option>
<option value="1991">1991</option>
<option value="1992">1992</option>
<option value="1993">1993</option>
<option value="1994">1994</option>
<option value="1995">1995</option>
<option value="1996">1996</option>
<option value="1997">1997</option>
<option value="1998">1998</option>
<option value="1999">1999</option>
<option value="2000">2000</option>
<option value="2001">2001</option>
<option value="2002">2002</option>
<option value="2003">2003</option>
<option value="2004">2004</option>
<option value="2005">2005</option>
<option value="2006">2006</option>
<option value="2007">2007</option>
<option value="2008">2008</option>
<option value="2009">2009</option>
<option value="2010">2010</option>
<option value="2011">2011</option>
<option value="2012">2012</option>
<option value="2013">2013</option>
<option value="2014">2014</option>
<option value="2015">2015</option>
<option value="2016">2016</option>
<option value="2017">2017</option>
<option value="2018">2018</option>
<option value="2019">2019</option>
<option value="2020">2020</option>
<option value="2021">2021</option>
<option value="2022">2022</option>
<option value="2023">2023</option>
<option value="2024">2024</option>
<option value="2025">2025</option>
<option value="2026">2026</option>
<option value="2027">2027</option>
<option value="2028">2028</option>
<option value="2029">2029</option>
<option value="2030">2030</option>
<option value="2031">2031</option>
<option value="2032">2032</option>
<option value="2033">2033</option>
<option value="2034">2034</option>
<option value="2035">2035</option>
<option value="2036">2036</option>
<option value="2037">2037</option>
<option value="2038">2038</option>
<option value="2039">2039</option>
<option value="2040">2040</option>
<option value="2041">2041</option>
<option value="2042">2042</option>
<option value="2043">2043</option>
<option value="2044">2044</option>
<option value="2045">2045</option>
<option value="2046">2046</option>
<option value="2047">2047</option>
<option value="2048">2048</option>
<option value="2049">2049</option>
<option value="2050">2050</option>
<option value="2051">2051</option>
<option value="2052">2052</option>
<option value="2053">2053</option>
<option value="2054">2054</option>
<option value="2055">2055</option>
<option value="2056">2056</option>
<option value="2057">2057</option>
<option value="2058">2058</option>
<option value="2059">2059</option>
<option value="2060">2060</option>
<option value="2061">2061</option>
<option value="2062">2062</option>
<option value="2063">2063</option>
<option value="2064">2064</option>
<option value="2065">2065</option>
<option value="2066">2066</option>
<option value="2067">2067</option>
<option value="2068">2068</option>
<option value="2069">2069</option>
<option value="2070">2070</option>
<option value="2071">2071</option>
<option value="2072">2072</option>
<option value="2073">2073</option>
<option value="2074">2074</option>
<option value="2075">2075</option>
<option value="2076">2076</option>
<option value="2077">2077</option>
<option value="2078">2078</option>
<option value="2079">2079</option>
<option value="2080">2080</option>
<option value="2081">2081</option>
<option value="2082">2082</option>
<option value="2083">2083</option>
<option value="2084">2084</option>
<option value="2085">2085</option>
<option value="2086">2086</option>
<option value="2087">2087</option>
<option value="2088">2088</option>
<option value="2089">2089</option>
<option value="2090">2090</option>
<option value="2091">2091</option>
<option value="2092">2092</option>
<option value="2093">2093</option>
<option value="2094">2094</option>
<option value="2095">2095</option>
<option value="2096">2096</option>
<option value="2097">2097</option>
<option value="2098">2098</option>
<option value="2099">2099</option>
</select>
<div class="center">
<input type="submit" name="submit" value="Submit" class="btn brand z-depth-0">
</div>
</form>
</section>
<div>
<?php
function count_days_past($days){
// echo "Licze dla $days";
// echo "</br>";
$result = 250 - abs($days);
if ($result < 0){
return count_days_past($result);
}
else{
return $result;
}
};
if(isset($_POST['submit'])){
$year = $_POST['year'];
$month = $_POST['month'];
$day = $_POST['day'];
$start_date = "2021-07-01";
$selected_date = "$year-$month-$day";
$start_date_time = strtotime("2021-07-01");
$selected_date_time = strtotime("$year-$month-$day");
$datediff = $selected_date_time - $start_date_time;
$amount_days = round($datediff / (60 * 60 * 24));
// dodaje 1, bo nie uzywam wartosci 0
if ($amount_days < 0){
// echo "Licze dni z przeszlosci";
// echo "</br>";
$number_of_day = count_days_past($amount_days) + 1;
echo "Nr dnia (wstecz)- $number_of_day";
echo "</br>";
}
else if ($amount_days == 0){
$number_of_day = 1;
echo "Nr dnia (zero)- $number_of_day";
echo "</br>";
}
else{
$number_of_day = ($amount_days % 250) + 1;
echo "Nr dnia (przod)- $number_of_day";
echo "</br>";
}
echo "start date - $start_date </br>";
echo "selected date - $selected_date </br>";
echo "amount days - $amount_days </br>";
echo "nr dnia - $number_of_day </br>";
//db connection
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "mayancalendar4";
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT id, opis, img FROM kalendarz_opisy WHERE id = $number_of_day";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
echo "<h3>Opis dla dnia nr $number_of_day</h3>";
// output data of each row
while($row = $result->fetch_assoc()) {
echo "<p>". $row["opis"]. "</p>";
}
} else {
echo "0 results";
}
$conn->close();
};
?>
</div>
</html>
Its look like and I marked what I want achieve:
Result of submit:
Before I tried put my php and html code by wp-admin and edit text on page. Then I have a form on middle of page, but the submit button not working and I don't getting result.
This looks:
After submit:
I working with WP first time. I doing this in correct way?
It is not the good way actually. You should follow the WP standards to do these modifications. Although, check your WordPress files, inside path:
wp-content/themes/your_themes/404.php
This is the file responsible for 404 not found page. You could create a child-theme (if you do not have yet), create a file 404.php inside your child theme and edit/modity it according to your needs.
Useful links on how to create a child-theme, could be found here:
https://www.wpbeginner.com/wp-themes/how-to-create-a-wordpress-child-theme-video/
Another link to create custom 404 page on your website:
Method 2. Create a Custom 404 Page in WordPress By Adding Code
https://www.wpbeginner.com/wp-themes/how-to-improve-your-404-page-template-in-wordpress/
Need to create a new page template and assign it to the page so you can easily handle the page.
For the create template create a new file filename.php in parent or child theme.
Here is code for the create template on the active theme directory check this screenshot: http://prntscr.com/1ibx1iz
<?php
/*
Template Name: New page temp // your template name write here
*/
get_header();
// your code
get_footer();
?>
Now create a new page and assign that template. check this screenshot:http://prntscr.com/1ibxgj9 and publish the page after viewing the page so you can see your custom design.
I'm having trouble getting my form's post data to come through. As this code stands, the file uploads, but I don't have any post data for the other form fields. I noticed that if I get rid of multipart/form-data enctype, it will not upload (obviously) but I DO get the post data to come through for the other fields. Any ideas on why this is?
The page where this code occurs is index.php?page=page1&upload=1
<form enctype="multipart/form-data" action="?page=page1&upload=2" method="post">
Select Location: <select name="location">
<option>Select Location</option>
<option value="N">North</option>
<option value="S">South</option>
<option value="E">East</option>
<option value="W">West</option>
</select><br />
Upload File: <input name="ufile" type="file" id="ufile" size="50" /><br />
<b><u>Sunday</u></b> Date: <select name="month">
<option> - Month - </option>
<option value="01">January</option>
<option value="02">Febuary</option>
<option value="03">March</option>
<option value="04">April</option>
<option value="05">May</option>
<option value="06">June</option>
<option value="07">July</option>
<option value="08">August</option>
<option value="09">September</option>
<option value="10">October</option>
<option value="11">November</option>
<option value="12">December</option>
</select>
<select name="day">
<option> - Day - </option>
<option value="01">1</option>
<option value="02">2</option>
<option value="03">3</option>
<option value="04">4</option>
<option value="05">5</option>
<option value="06">6</option>
<option value="07">7</option>
<option value="08">8</option>
<option value="09">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="year">
<?php
$optionyear = date("Y",time());
$currentyear = $optionyear;
while($optionyear != 1990) {
echo "<option value=\"".$optionyear."\"";
if($optionyear == $currentyear) {
echo " selected";
}
echo ">".$optionyear."</option>";
$optionyear--;
}
?>
</select><br />
<input type="submit" name="Submit" value="Upload" /><br />
</form>
Thanks!
U can get your upload data with $_FILES[] and other data with $_POST[]
Try
echo "<pre>";
print_r($_POST);
print_r($_FILES['ufile']);
echo "</pre>";
By the way where is close tag for <form> element?
I have the following date picker with 3 different select ids
<form id="testform" method="get" action="../Untitled-1.html">
<select id="date-sel-dd" name="date-sel-dd">
<option value="-1">Day</option>
<option value="1">1st</option>
<option value="2">2nd</option>
<option value="3">3rd</option>
<option value="4">4th</option>
<option value="5">5th</option>
<option value="6">6th</option>
<option value="7">7th</option>
<option value="8">8th</option>
<option value="9">9th</option>
<option value="10">10th</option>
<option value="11">11th</option>
<option value="12">12th</option>
<option value="13">13th</option>
<option value="14">14th</option>
<option value="15">15th</option>
<option value="16">16th</option>
<option value="17">17th</option>
<option value="18">18th</option>
<option value="19">19th</option>
<option value="20">20th</option>
<option value="21">21st</option>
<option value="22">22nd</option>
<option value="23">23rd</option>
<option value="24">24th</option>
<option value="25">25th</option>
<option value="26">26th</option>
<option value="27">27th</option>
<option value="28">28th</option>
<option value="29">29th</option>
<option value="30">30th</option>
<option value="31">31st</option>
</select>
<select id="date-sel-mm" name="date-sel-mm">
<option value="-1">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 id="date-sel" name="date-sel">
<option value="-1">Year</option>
<option value="2012">2012</option>
<option value="2013">2013</option>
<option value="2014">2014</option>
</select>
<input type="submit" name="submit" id="submit" value="Submit" />
I need to get the values from these 3 differnt select fields and post it with the form to a new named: 'arrival'.
When I submit to the page I want my url to look like:
mydomain.php?arrival=date-sel-dd/date-sel-mm/date-sel
You could use an array.
Rename all select with arrival[].
In your php page you can get that value as an array. Try:
print_r($_POST['arrival']);
If you want to join the date use:
$date = implode('/', $_POST['arrival']);
header('Location: mydomain.php?arrival=' . $date);
If I am doing form validation for the user input, I have to put the phpcode in the page with form right?
Also in the <form> tag do I have to specify anything. I mean if there is an error the user will have to return to the same input page with errors showing up. If it was successful input, the user should goto order-process.php
PHP Validation Code:
<?php
$name = $_POST['name'];
$nameregex = '/^[a-zA-Z]+\s?[a-zA-Z]+$/';
if (!preg_match($nameregex, $name)) {
echo '<font color=red>Please enter a valid name</font>';
}
$email = $_POST['email'];
$emailregex = '/^[a-zA-Z\_\-\.0-9]+\#[a-zA-Z\_\-\.0-9]+$/';
if (!preg_match($emailegex, $email)) {
echo '<font color="red">please Enter a valid email id</font>';
}
$address = $_POST['address'];
$addressregex = '/^[0-9a-zA-Z\,\s]+$/';
if (!preg_match($$addressregex, $address)) {
echo '<font color="red">please Enter a valid Address</font>';
}
$state = $_POST['state'];
$stateregex = '/^[a-zA-Z]+\s?[a-zA-Z]+$/';
if (!preg_match($stateregex, $state)) {
echo '<font color="red">please Enter a valid state name</font>';
}
$pincode = $_POST['pincode'];
$pincoderegex = '/^[a-zA-Z]+\s?[a-zA-Z]+$/';
if (!preg_match($pincoderegex, $pincode)) {
echo '<font color="red">please Enter a valid pincode</font>';
}
?>
HTML Form Code:
<form name="orderform1" action="process-order.php" method="post" id="orderform">
<ol>
<li>
<label for="name">Your Name:*</label>
<input id="name" name="name" class="text" />
</li>
<li>
<label for="email">E-Mail:*</label>
<input id="email" name="email" class="text" />
</li>
<li>
<label for="address1">Address Line 1:*</label>
<input id="address1" name="address1" class="text" />
</li>
<li>
<label for="address2">Address Line 2:</label>
<input id="address2" name="address2" class="text" />
</li>
<li>
<label for="state">State/Province*:</label>
<input id="state" name="state" class="text" />
</li>
<li>
<label for="address">City:</label>
<input id="address" name="address" class="text" />
</li>
<li>
<label for="pincode">Pin Code:*</label>
<input id="pincode" name="pincode" class="text" />
</li>
<li>
<label for="country">Country:*</label>
<select name="country">
<option value="AF">Afghanistan</option>
<option value="AX">Ã…Land Islands</option>
<option value="AL">Albania</option>
<option value="DZ">Algeria</option>
<option value="AS">American Samoa</option>
<option value="AD">Andorra</option>
<option value="AO">Angola</option>
<option value="AI">Anguilla</option>
<option value="AQ">Antarctica</option>
<option value="AG">Antigua And Barbuda</option>
<option value="AR">Argentina</option>
<option value="AM">Armenia</option>
<option value="AW">Aruba</option>
<option value="AU">Australia</option>
<option value="AT">Austria</option>
<option value="AZ">Azerbaijan</option>
<option value="BS">Bahamas</option>
<option value="BH">Bahrain</option>
<option value="BD">Bangladesh</option>
<option value="BB">Barbados</option>
<option value="BY">Belarus</option>
<option value="BE">Belgium</option>
<option value="BZ">Belize</option>
<option value="BJ">Benin</option>
<option value="BM">Bermuda</option>
<option value="BT">Bhutan</option>
<option value="BO">Bolivia</option>
<option value="BA">Bosnia And Herzegovina</option>
<option value="BW">Botswana</option>
<option value="BV">Bouvet Island</option>
<option value="BR">Brazil</option>
<option value="IO">British Indian Ocean Territory</option>
<option value="BN">Brunei Darussalam</option>
<option value="BG">Bulgaria</option>
<option value="BF">Burkina Faso</option>
<option value="BI">Burundi</option>
<option value="KH">Cambodia</option>
<option value="CM">Cameroon</option>
<option value="CA">Canada</option>
<option value="CV">Cape Verde</option>
<option value="KY">Cayman Islands</option>
<option value="CF">Central African Republic</option>
<option value="TD">Chad</option>
<option value="CL">Chile</option>
<option value="CN">China</option>
<option value="CX">Christmas Island</option>
<option value="CC">Cocos (Keeling) Islands</option>
<option value="CO">Colombia</option>
<option value="KM">Comoros</option>
<option value="CG">Congo</option>
<option value="CD">Congo, The Democratic Republic Of The</option>
<option value="CK">Cook Islands</option>
<option value="CR">Costa Rica</option>
<option value="CI">Cote D'Ivoire</option>
<option value="HR">Croatia</option>
<option value="CU">Cuba</option>
<option value="CY">Cyprus</option>
<option value="CZ">Czech Republic</option>
<option value="DK">Denmark</option>
<option value="DJ">Djibouti</option>
<option value="DM">Dominica</option>
<option value="DO">Dominican Republic</option>
<option value="EC">Ecuador</option>
<option value="EG">Egypt</option>
<option value="SV">El Salvador</option>
<option value="GQ">Equatorial Guinea</option>
<option value="ER">Eritrea</option>
<option value="EE">Estonia</option>
<option value="ET">Ethiopia</option>
<option value="FK">Falkland Islands (Malvinas)</option>
<option value="FO">Faroe Islands</option>
<option value="FJ">Fiji</option>
<option value="FI">Finland</option>
<option value="FR">France</option>
<option value="GF">French Guiana</option>
<option value="PF">French Polynesia</option>
<option value="TF">French Southern Territories</option>
<option value="GA">Gabon</option>
<option value="GM">Gambia</option>
<option value="GE">Georgia</option>
<option value="DE">Germany</option>
<option value="GH">Ghana</option>
<option value="GI">Gibraltar</option>
<option value="GR">Greece</option>
<option value="GL">Greenland</option>
<option value="GD">Grenada</option>
<option value="GP">Guadeloupe</option>
<option value="GU">Guam</option>
<option value="GT">Guatemala</option>
<option value=" Gg">Guernsey</option>
<option value="GN">Guinea</option>
<option value="GW">Guinea-Bissau</option>
<option value="GY">Guyana</option>
<option value="HT">Haiti</option>
<option value="HM">Heard Island And Mcdonald Islands</option>
<option value="VA">Holy See (Vatican City State)</option>
<option value="HN">Honduras</option>
<option value="HK">Hong Kong</option>
<option value="HU">Hungary</option>
<option value="IS">Iceland</option>
<option value="IN">India</option>
<option value="ID">Indonesia</option>
<option value="IR">Iran, Islamic Republic Of</option>
<option value="IQ">Iraq</option>
<option value="IE">Ireland</option>
<option value="IM">Isle Of Man</option>
<option value="IL">Israel</option>
<option value="IT">Italy</option>
<option value="JM">Jamaica</option>
<option value="JP">Japan</option>
<option value="JE">Jersey</option>
<option value="JO">Jordan</option>
<option value="KZ">Kazakhstan</option>
<option value="KE">Kenya</option>
<option value="KI">Kiribati</option>
<option value="KP">Korea, Democratic People'S Republic Of</option>
<option value="KR">Korea, Republic Of</option>
<option value="KW">Kuwait</option>
<option value="KG">Kyrgyzstan</option>
<option value="LA">Lao People'S Democratic Republic</option>
<option value="LV">Latvia</option>
<option value="LB">Lebanon</option>
<option value="LS">Lesotho</option>
<option value="LR">Liberia</option>
<option value="LY">Libyan Arab Jamahiriya</option>
<option value="LI">Liechtenstein</option>
<option value="LT">Lithuania</option>
<option value="LU">Luxembourg</option>
<option value="MO">Macao</option>
<option value="MK">Macedonia, The Former Yugoslav Republic Of</option>
<option value="MG">Madagascar</option>
<option value="MW">Malawi</option>
<option value="MY">Malaysia</option>
<option value="MV">Maldives</option>
<option value="ML">Mali</option>
<option value="MT">Malta</option>
<option value="MH">Marshall Islands</option>
<option value="MQ">Martinique</option>
<option value="MR">Mauritania</option>
<option value="MU">Mauritius</option>
<option value="YT">Mayotte</option>
<option value="MX">Mexico</option>
<option value="FM">Micronesia, Federated States Of</option>
<option value="MD">Moldova, Republic Of</option>
<option value="MC">Monaco</option>
<option value="MN">Mongolia</option>
<option value="MS">Montserrat</option>
<option value="MA">Morocco</option>
<option value="MZ">Mozambique</option>
<option value="MM">Myanmar</option>
<option value="NA">Namibia</option>
<option value="NR">Nauru</option>
<option value="NP">Nepal</option>
<option value="NL">Netherlands</option>
<option value="AN">Netherlands Antilles</option>
<option value="NC">New Caledonia</option>
<option value="NZ">New Zealand</option>
<option value="NI">Nicaragua</option>
<option value="NE">Niger</option>
<option value="NG">Nigeria</option>
<option value="NU">Niue</option>
<option value="NF">Norfolk Island</option>
<option value="MP">Northern Mariana Islands</option>
<option value="NO">Norway</option>
<option value="OM">Oman</option>
<option value="PK">Pakistan</option>
<option value="PW">Palau</option>
<option value="PS">Palestinian Territory, Occupied</option>
<option value="PA">Panama</option>
<option value="PG">Papua New Guinea</option>
<option value="PY">Paraguay</option>
<option value="PE">Peru</option>
<option value="PH">Philippines</option>
<option value="PN">Pitcairn</option>
<option value="PL">Poland</option>
<option value="PT">Portugal</option>
<option value="PR">Puerto Rico</option>
<option value="QA">Qatar</option>
<option value="RE">Reunion</option>
<option value="RO">Romania</option>
<option value="RU">Russian Federation</option>
<option value="RW">Rwanda</option>
<option value="SH">Saint Helena</option>
<option value="KN">Saint Kitts And Nevis</option>
<option value="LC">Saint Lucia</option>
<option value="PM">Saint Pierre And Miquelon</option>
<option value="VC">Saint Vincent And The Grenadines</option>
<option value="WS">Samoa</option>
<option value="SM">San Marino</option>
<option value="ST">Sao Tome And Principe</option>
<option value="SA">Saudi Arabia</option>
<option value="SN">Senegal</option>
<option value="CS">Serbia And Montenegro</option>
<option value="SC">Seychelles</option>
<option value="SL">Sierra Leone</option>
<option value="SG">Singapore</option>
<option value="SK">Slovakia</option>
<option value="SI">Slovenia</option>
<option value="SB">Solomon Islands</option>
<option value="SO">Somalia</option>
<option value="ZA">South Africa</option>
<option value="GS">South Georgia And The South Sandwich Islands</option>
<option value="ES">Spain</option>
<option value="LK">Sri Lanka</option>
<option value="SD">Sudan</option>
<option value="SR">Suriname</option>
<option value="SJ">Svalbard And Jan Mayen</option>
<option value="SZ">Swaziland</option>
<option value="SE">Sweden</option>
<option value="CH">Switzerland</option>
<option value="SY">Syrian Arab Republic</option>
<option value="TW">Taiwan, Province Of China</option>
<option value="TJ">Tajikistan</option>
<option value="TZ">Tanzania, United Republic Of</option>
<option value="TH">Thailand</option>
<option value="TL">Timor-Leste</option>
<option value="TG">Togo</option>
<option value="TK">Tokelau</option>
<option value="TO">Tonga</option>
<option value="TT">Trinidad And Tobago</option>
<option value="TN">Tunisia</option>
<option value="TR">Turkey</option>
<option value="TM">Turkmenistan</option>
<option value="TC">Turks And Caicos Islands</option>
<option value="TV">Tuvalu</option>
<option value="UG">Uganda</option>
<option value="UA">Ukraine</option>
<option value="AE">United Arab Emirates</option>
<option value="GB">United Kingdom</option>
<option value="US">United States</option>
<option value="UM">United States Minor Outlying Islands</option>
<option value="UY">Uruguay</option>
<option value="UZ">Uzbekistan</option>
<option value="VU">Vanuatu</option>
<option value="VE">Venezuela</option>
<option value="VN">Viet Nam</option>
<option value="VG">Virgin Islands, British</option>
<option value="VI">Virgin Islands, U.S.</option>
<option value="WF">Wallis And Futuna</option>
<option value="EH">Western Sahara</option>
<option value="YE">Yemen</option>
<option value="ZM">Zambia</option>
<option value="ZW">Zimbabwe</option>
</select>
<li>
<label for="phone">Phone Number(With Country Code):*</label>
<input id="phone" name="phone" class="text" />
</li>
<li class="buttons">
<input type="submit" name="imageField" id="imageField" value="Proceed to Payment" class="send" />
<div class="clr"></div>
</li>
</ol>
</form>
You have to put the php code (for validation) in 'process-order.php'. It will receive the form data.
You can redirect to the same page (i.e. the order form) and choose to display different HTML content depending on the result of the validation:
<?php
// Validation routine here -- you can count the number of validation errors and use this as decision whether to show the form again or not
if ($_POST['submit']) {
$errorCount = 0;
// Validations here + count errors
}
// -- end of validation routine
if ($errorCount == 0) { ?>
<h1>Order Processed</h1>
<p>Your order was processed...</p>
<?php }
// If error count is above zero OR the submit button was never pressed, display form:
else { ?>
<form>...</form>
<?php } ?>
It will go to the form's ACTION (which is process-order.php).
If validation fails, though, the user will have to go back to the form page and everything will be blank.
To have all form fields pre-populated again so everything isn't blank, you can do, for instance
<input id="pincode" name="pincode" class="text" />
change to
<input id="pincode" name="pincode" class="text" value='<?php echo (isset($_POST['pincode'])) ? $_POST['pincode'] : '' ?>' />
I have some data in db,now i m making them to display in the front end so,i ii have a update button,if i click it the selected values to come to database
dpaste.com/hold/180863
Thnx in advance.
Chk does your query is giving you any output, here :$result = mysql_query("SELECT FROM customers");
echo ur query and paste in ur SQL query panel of ur PHPmyadmin. see do u get any value or not? if it does not then ur query is incorrect
u have not ended with proper tag here:
<? php
?>
"?>"
UPDATED
<?php
$result = mysql_query("SELECT * FROM Customer"); while($row = mysql_fetch_assoc($result)){ echo "Name: ".$row['0'].", Address:".$row['1'] .", City:".$row['city'].", pincode:".$row['pincode'].", State:".$row['state'].", Country:".$row['country'].", Phone:".$row['phone'].", Mobile:".$row['mobile'].", Fax:".$row['fax'].", Email:".$row['email'].", Website:".$row['url'].", Notes:".$row['notes'].";
?>
u didnt put the ">" at the end in script u refrenced to
UPDATED
DAF, your url : http://localhost/up.php?customer=aaaaa,sssssssssssssss,aaaaaaa,22222Andhra+Pradesh,in,2222221,1111111,0,v#gmail.com,,
is displaying all the values posted , its being appended in the url, I need to see the complete code you are working on
UPDATED
<html>
<body>
<form action="up.php">
<?php
// Create the connection and select the DB-->
$con = mysql_connect("localhost","root","");
if ($con) {
mysql_selectdb("form",$con);
// Select records from the DB
$query = "SELECT * FROM customer";
$result = mysql_query($query);
// Display records from the table
while ($row = mysql_fetch_array($result)) {
$value = $row;
}
}
?>
<p>
<label for="cname"><b>Name:</b></label>
<em>*</em><input id="cname" name="name" size="25" class="required" value="<?php echo $value['name'];?>" minlength="5" />
</p>
<p>
<label for="caddress"><b>Address:</b></label>
<em>*</em><textarea id="caddress" name="address" cols="22" class="required" minlength="3" /><?php echo $value['address'];?></textarea>
</p>
<p>
<label for="ccity"><b>City/Town:</b></label>
<em>*</em><input id="ccity" name="city" size="25" value="<?php echo $value['city'];?>" class="required" minlength="5" />
</p>
<p>
<label for="cpincode"><b>Pincode:</b></label>
<em>*</em><input id="cpincode" name="pincode" size="25" class="required" value="<?php echo $value['cpincode'];?>" digits="5" />
</p>
<p>
<label for="cstate"><b>State:</b></label>
<em>*</em><select class="state" id="cstate" name="state">
<option value="" >Select One</option>
<option <?php if($value['state'] == Andaman and Nicobar){ $selected = "selected='selected'";}else{$selected = "";} echo $selected;?>>Andaman and Nicobar</option>
<option <?php if($value['state'] == Andhra Pradesh){ $selected = "selected='selected'";}else{$selected = "";} echo $selected;?>>Andhra Pradesh</option>
<option <?php if($value['state'] == Arunachal Pradesh){ $selected = "selected='selected'";}else{$selected = "";} echo $selected;?>>Arunachal Pradesh</option>
---
---
---- similar as above
</select>
</p>
<p>
<label for="ccountry"><b>Country:</b></label>
<em>*</em><select class="country" id="ccountry" name="country">
// here as well do as above with $value['country']
<option value="" >Select One</option>
<option value="af" >Afghanistan</option>
<option value="ax" >Aland Islands</option>
<option value="al" >Albania</option>
<option value="dz" >Algeria</option>
<option value="as" >American Samoa</option>
<option value="ad" >Andorra</option>
<option value="ao" >Angola</option>
<option value="ai" >Anguilla</option>
<option value="aq" >Antarctica</option>
<option value="ag" >Antigua and Barbuda</option>
<option value="ar" >Argentina</option>
<option value="am" >Armenia</option>
<option value="aw" >Aruba</option>
<option value="au" >Australia</option>
<option value="at" >Austria</option>
<option value="az" >Azerbaijan</option>
<option value="bs" >Bahamas</option>
<option value="bh" >Bahrain</option>
<option value="bd" >Bangladesh</option>
<option value="bb" >Barbados</option>
<option value="by" >Belarus</option>
<option value="be" >Belgium</option>
<option value="bz" >Belize</option>
<option value="bj" >Benin</option>
<option value="bm" >Bermuda</option>
<option value="bt" >Bhutan</option>
<option value="bo" >Bolivia</option>
<option value="ba" >Bosnia and Herzegovina</option>
<option value="bw" >Botswana</option>
<option value="bv" >Bouvet Island</option>
<option value="br" >Brazil</option>
<option value="io" >British Indian Ocean Territory</option>
<option value="vg" >British Virgin Islands</option>
<option value="bn" >Brunei</option>
<option value="bg" >Bulgaria</option>
<option value="bf" >Burkina Faso</option>
<option value="bi" >Burundi</option>
<option value="kh" >Cambodia</option>
<option value="cm" >Cameroon</option>
<option value="ca" >Canada</option>
<option value="cv" >Cape Verde</option>
<option value="ky" >Cayman Islands</option>
<option value="cf" >Central African Republic</option>
<option value="td" >Chad</option>
<option value="cl" >Chile</option>
<option value="cn" >China</option>
<option value="cx" >Christmas Island</option>
<option value="cc" >Cocos (Keeling) Islands</option>
<option value="co" >Colombia</option>
<option value="km" >Comoros</option>
<option value="cg" >Congo</option>
<option value="ck" >Cook Islands</option>
<option value="cr" >Costa Rica</option>
<option value="hr" >Croatia</option>
<option value="cu" >Cuba</option>
<option value="cy" >Cyprus</option>
<option value="cz" >Czech Republic</option>
<option value="cd" >Democratic Republic of Congo</option>
<option value="dk" >Denmark</option>
<option value="xx" >Disputed Territory</option>
<option value="dj" >Djibouti</option>
<option value="dm" >Dominica</option>
<option value="do" >Dominican Republic</option>
<option value="tl" >East Timor</option>
<option value="ec" >Ecuador</option>
<option value="eg" >Egypt</option>
<option value="sv" >El Salvador</option>
<option value="gq" >Equatorial Guinea</option>
<option value="er" >Eritrea</option>
<option value="ee" >Estonia</option>
<option value="et" >Ethiopia</option>
<option value="fk" >Falkland Islands</option>
<option value="fo" >Faroe Islands</option>
<option value="fm" >Federated States of Micronesia</option>
<option value="fj" >Fiji</option>
<option value="fi" >Finland</option>
<option value="fr" >France</option>
<option value="gf" >French Guyana</option>
<option value="pf" >French Polynesia</option>
<option value="tf" >French Southern Territories</option>
<option value="ga" >Gabon</option>
<option value="gm" >Gambia</option>
<option value="ge" >Georgia</option>
<option value="de" >Germany</option>
<option value="gh" >Ghana</option>
<option value="gi" >Gibraltar</option>
<option value="gr" >Greece</option>
<option value="gl" >Greenland</option>
<option value="gd" >Grenada</option>
<option value="gp" >Guadeloupe</option>
<option value="gu" >Guam</option>
<option value="gt" >Guatemala</option>
<option value="gn" >Guinea</option>
<option value="gw" >Guinea-Bissau</option>
<option value="gy" >Guyana</option>
<option value="ht" >Haiti</option>
<option value="hm" >Heard Island and Mcdonald Islands</option>
<option value="hn" >Honduras</option>
<option value="hk" >Hong Kong</option>
<option value="hu" >Hungary</option>
<option value="is" >Iceland</option>
<option value="in" SELECTED >India</option>
<option value="id" >Indonesia</option>
<option value="ir" >Iran</option>
<option value="iq" >Iraq</option>
<option value="xe" >Iraq-Saudi Arabia Neutral Zone</option>
<option value="ie" >Ireland</option>
<option value="il" >Israel</option>
<option value="it" >Italy</option>
<option value="ci" >Ivory Coast</option>
<option value="jm" >Jamaica</option>
<option value="jp" >Japan</option>
<option value="jo" >Jordan</option>
<option value="kz" >Kazakhstan</option>
<option value="ke" >Kenya</option>
<option value="ki" >Kiribati</option>
<option value="kw" >Kuwait</option>
<option value="kg" >Kyrgyzstan</option>
<option value="la" >Laos</option>
<option value="lv" >Latvia</option>
<option value="lb" >Lebanon</option>
<option value="ls" >Lesotho</option>
<option value="lr" >Liberia</option>
<option value="ly" >Libya</option>
<option value="li" >Liechtenstein</option>
<option value="lt" >Lithuania</option>
<option value="lu" >Luxembourg</option>
<option value="mo" >Macau</option>
<option value="mk" >Macedonia</option>
<option value="mg" >Madagascar</option>
<option value="mw" >Malawi</option>
<option value="my" >Malaysia</option>
<option value="mv" >Maldives</option>
<option value="ml" >Mali</option>
<option value="mt" >Malta</option>
<option value="mh" >Marshall Islands</option>
<option value="mq" >Martinique</option>
<option value="mr" >Mauritania</option>
<option value="mu" >Mauritius</option>
<option value="yt" >Mayotte</option>
<option value="mx" >Mexico</option>
<option value="md" >Moldova</option>
<option value="mc" >Monaco</option>
<option value="mn" >Mongolia</option>
<option value="ms" >Montserrat</option>
<option value="ma" >Morocco</option>
<option value="mz" >Mozambique</option>
<option value="mm" >Myanmar</option>
<option value="na" >Namibia</option>
<option value="nr" >Nauru</option>
<option value="np" >Nepal</option>
<option value="nl" >Netherlands</option>
<option value="an" >Netherlands Antilles</option>
<option value="nc" >New Caledonia</option>
<option value="nz" >New Zealand</option>
<option value="ni" >Nicaragua</option>
<option value="ne" >Niger</option>
<option value="ng" >Nigeria</option>
<option value="nu" >Niue</option>
<option value="nf" >Norfolk Island</option>
<option value="kp" >North Korea</option>
<option value="mp" >Northern Mariana Islands</option>
<option value="no" >Norway</option>
<option value="om" >Oman</option>
<option value="pk" >Pakistan</option>
<option value="pw" >Palau</option>
<option value="ps" >Palestinian Occupied Territories</option>
<option value="pa" >Panama</option>
<option value="pg" >Papua New Guinea</option>
<option value="py" >Paraguay</option>
<option value="pe" >Peru</option>
<option value="ph" >Philippines</option>
<option value="pn" >Pitcairn Islands</option>
<option value="pl" >Poland</option>
<option value="pt" >Portugal</option>
<option value="pr" >Puerto Rico</option>
<option value="qa" >Qatar</option>
<option value="re" >Reunion</option>
<option value="ro" >Romania</option>
<option value="ru" >Russia</option>
<option value="rw" >Rwanda</option>
<option value="sh" >Saint Helena and Dependencies</option>
<option value="kn" >Saint Kitts and Nevis</option>
<option value="lc" >Saint Lucia</option>
<option value="pm" >Saint Pierre and Miquelon</option>
<option value="vc" >Saint Vincent and the Grenadines</option>
<option value="ws" >Samoa</option>
<option value="sm" >San Marino</option>
<option value="st" >Sao Tome and Principe</option>
<option value="sa" >Saudi Arabia</option>
<option value="sn" >Senegal</option>
<option value="sc" >Seychelles</option>
<option value="sl" >Sierra Leone</option>
<option value="sg" >Singapore</option>
<option value="sk" >Slovakia</option>
<option value="si" >Slovenia</option>
<option value="sb" >Solomon Islands</option>
<option value="so" >Somalia</option>
<option value="za" >South Africa</option>
<option value="gs" >South Georgia and South Sandwich Islands</option>
<option value="kr" >South Korea</option>
<option value="es" >Spain</option>
<option value="pi" >Spratly Islands</option>
<option value="lk" >Sri Lanka</option>
<option value="sd" >Sudan</option>
<option value="sr" >Suriname</option>
<option value="sj" >Svalbard and Jan Mayen</option>
<option value="sz" >Swaziland</option>
<option value="se" >Sweden</option>
<option value="ch" >Switzerland</option>
<option value="sy" >Syria</option>
<option value="tw" >Taiwan</option>
<option value="tj" >Tajikistan</option>
<option value="tz" >Tanzania</option>
<option value="th" >Thailand</option>
<option value="tg" >Togo</option>
<option value="tk" >Tokelau</option>
<option value="to" >Tonga</option>
<option value="tt" >Trinidad and Tobago</option>
<option value="tn" >Tunisia</option>
<option value="tr" >Turkey</option>
<option value="tm" >Turkmenistan</option>
<option value="tc" >Turks And Caicos Islands</option>
<option value="tv" >Tuvalu</option>
<option value="ug" >Uganda</option>
<option value="ua" >Ukraine</option>
<option value="ae" >United Arab Emirates</option>
<option value="uk" >United Kingdom</option>
<option value="xd" >United Nations Neutral Zone</option>
<option value="us" >United States</option>
<option value="um" >United States Minor Outlying Islands</option>
<option value="uy" >Uruguay</option>
<option value="vi" >US Virgin Islands</option>
<option value="uz" >Uzbekistan</option>
<option value="vu" >Vanuatu</option>
<option value="va" >Vatican City</option>
<option value="ve" >Venezuela</option>
<option value="vn" >Vietnam</option>
<option value="wf" >Wallis and Futuna</option>
<option value="eh" >Western Sahara</option>
<option value="ye" >Yemen</option>
<option value="zm" >Zambia</option>
<option value="zw" >Zimbabwe</option>
<option value="rs" >Serbia</option>
<option value="me" >Montenegro</option>
</select>
</p>
<p>
<label for="cphone"><b>Phone:</b></label>
<em>*</em><input id="cphone" name="phone" size="25" value="<?php echo $value['phone'];?>" class="required" digits="4" />
</p>
<p>
<label for="cmobile"><b>Mobile:</b></label>
<em>*</em><input id="cmobile" name="mobile" value="<?php echo $value['mobile'];?>" size="25" class="required" digits="4" />
</p>
<P>
<label for="num"><b>Fax:</b></label>
<em> </em ><input id="cnum" name="fax" size="25" class="num" value="<?php echo $value['fax'];?>" digits="10" />
</p>
<p>
<label for="cemail"><b>Email:</b></label>
<em>*</em><input id="cemail" name="email" size="25" value="<?php echo $value['email'];?>" class="email" />
</p>
<p>
<label for="curl"><b>Website:</b></label>
<em> </em><input id="curl" name="url" size="25" value="<?php echo $value['url'];?>" class="url" value="" />
</p>
<p>
<label for="cnotes"><b>Notes:</b></label>
<em> </em><textarea id="cnotes" name="notes" cols="22" class="notes" /><?php echo $value['notes'];?></textarea>
</p>
<input type ="submit" value="update" />
</body>
</html>
you're query should be atleast
$result = mysql_query("SELECT column FROM customers")
or
$result = mysql_query("SELECT * FROM customers")