drop down data to appear in form php - php

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")

Related

Why won't my PhP form send the Data to my email?

I am new to coding and Im trying to find out why my php code will not send my form data to my email if someone could direct me to somewhere Where i could learn how to get it to send or give me some tips I would really appreciate it.
HTML: [UPDATED]
<a id="faq-scroll"></a>
<section id="faq">
<div class="row pad-large">
<div class="row">
<div class="large-8 large-centered columns pad-bottom-small">
<div id="faq-form" class="text-center">
<form method = "POST" action = "mail.php">
<input id="firstname" type="text" placeholder="First Name" name="firstname" />
<input id="middleinitial" type="text" placeholder="Middle Name" name="middleinitial" />
<input id="lastname" type="text" placeholder="Last Name" name="lastname" />
<input id="email2" type="text" placeholder="E-mail address" name="email2" />
<select id="form_dob_month" name="dob_month">
<option value="-">Date</option>
<option value="1">January</option>
<option value="2">Febuary</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="form_dob_day" name="dob_day">
<option value="-">Of</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
<option value="24">24</option>
<option value="25">25</option>
<option value="26">26</option>
<option value="27">27</option>
<option value="28">28</option>
<option value="29">29</option>
<option value="30">30</option>
<option value="31">31</option>
</select>
<select id="form_dob_year" name="dob_year">
<option value="-">Birth</option>
<option value="2011">2011</option>
<option value="2010">2010</option>
<option value="2009">2009</option>
<option value="2008">2008</option>
<option value="2007">2007</option>
<option value="2006">2006</option>
<option value="2005">2005</option>
<option value="2004">2004</option>
<option value="2003">2003</option>
<option value="2002">2002</option>
<option value="2001">2001</option>
<option value="2000">2000</option>
<option value="1999">1999</option>
<option value="1998">1998</option>
<option value="1997">1997</option>
<option value="1996">1996</option>
<option value="1995">1995</option>
<option value="1994">1994</option>
<option value="1993">1993</option>
<option value="1992">1992</option>
<option value="1991">1991</option>
<option value="1990">1990</option>
<option value="1989">1989</option>
<option value="1988">1988</option>
<option value="1987">1987</option>
<option value="1986">1986</option>
<option value="1985">1985</option>
<option value="1984">1984</option>
<option value="1983">1983</option>
<option value="1982">1982</option>
<option value="1981">1981</option>
<option value="1980">1980</option>
<option value="1979">1979</option>
<option value="1978">1978</option>
<option value="1977">1977</option>
<option value="1976">1976</option>
<option value="1975">1975</option>
<option value="1974">1974</option>
<option value="1973">1973</option>
<option value="1972">1972</option>
<option value="1971">1971</option>
<option value="1970">1970</option>
<option value="1969">1969</option>
<option value="1968">1968</option>
<option value="1967">1967</option>
<option value="1966">1966</option>
<option value="1965">1965</option>
<option value="1964">1964</option>
<option value="1963">1963</option>
<option value="1962">1962</option>
<option value="1961">1961</option>
<option value="1960">1960</option>
<option value="1959">1959</option>
<option value="1958">1958</option>
<option value="1957">1957</option>
<option value="1956">1956</option>
<option value="1955">1955</option>
<option value="1954">1954</option>
<option value="1953">1953</option>
<option value="1952">1952</option>
<option value="1951">1951</option>
<option value="1950">1950</option>
<option value="1949">1949</option>
<option value="1948">1948</option>
<option value="1947">1947</option>
<option value="1946">1946</option>
<option value="1945">1945</option>
<option value="1944">1944</option>
<option value="1943">1943</option>
<option value="1942">1942</option>
<option value="1941">1941</option>
<option value="1940">1940</option>
<option value="1939">1939</option>
<option value="1938">1938</option>
<option value="1937">1937</option>
<option value="1936">1936</option>
<option value="1935">1935</option>
<option value="1934">1934</option>
<option value="1933">1933</option>
<option value="1932">1932</option>
<option value="1931">1931</option>
<option value="1930">1930</option>
<option value="1929">1929</option>
<option value="1928">1928</option>
<option value="1927">1927</option>
<option value="1926">1926</option>
<option value="1925">1925</option>
<option value="1924">1924</option>
<option value="1923">1923</option>
<option value="1922">1922</option>
<option value="1921">1921</option>
<option value="1920">1920</option>
<option value="1919">1919</option>
<option value="1918">1918</option>
<option value="1917">1917</option>
<option value="1916">1916</option>
<option value="1915">1915</option>
<option value="1914">1914</option>
<option value="1913">1913</option>
<option value="1912">1912</option>
<option value="1911">1911</option>
<option value="1910">1910</option>
</select>
<input id="social" type="text" placeholder="Social Security #" name="socialsecurity#" />
<input id="Driver" type="text" placeholder="Driver License #" name="driverlicense#" />
<input id="cellphone" type="text" placeholder="Cell Phone" name="cellphone" />
<input id="address" type="text" placeholder="Street Address" name="streetaddress" />
<input id="zip" type="text" placeholder="Zip Code" name="zipcode" />
<input id="city" type="text" placeholder="City" name="city" />
<select id="form_state" name="State">
<option value="-">State</option>
<option value="1">Alabama</option>
<option value="2">Alaska</option>
<option value="3">Arizona</option>
<option value="4">Arkansas</option>
<option value="5">California</option>
<option value="6">Colorado</option>
<option value="7">Connecticut</option>
<option value="8">Delaware</option>
<option value="9">Florida</option>
<option value="10">Georgia</option>
<option value="11">Hawaii</option>
<option value="12">Idaho</option>
<option value="13">Illinois</option>
<option value="14">Indiana</option>
<option value="15">Iowa</option>
<option value="16">Kansas</option>
<option value="17">Kentucky</option>
<option value="18">Louisiana</option>
<option value="19">Maine</option>
<option value="20">Maryland</option>
<option value="21">Massachusetts</option>
<option value="22">Michigan</option>
<option value="23">Minnesota</option>
<option value="24">Mississippi</option>
<option value="25">Missouri</option>
<option value="26">Montana</option>
<option value="27">Nebraska </option>
<option value="28">Nevada</option>
<option value="29">New Hampshire</option>
<option value="30">New Jersey</option>
<option value="31">New Mexico</option>
<option value="32">New York</option>
<option value="33">North Carolina</option>
<option value="34">North Dakota</option>
<option value="35">Ohio</option>
<option value="36">Oklahoma</option>
<option value="37">Oregon</option>
<option value="38">Pennsylvania</option>
<option value="39">Rhode Island</option>
<option value="40">South Carolina</option>
<option value="41">South Dakota</option>
<option value="42">Tennessee</option>
<option value="43">Texas</option>
<option value="44">Utah</option>
<option value="45">Vermont</option>
<option value="46">Virginia</option>
<option value="47">Washington</option>
<option value="48">West Virginia</option>
<option value="49">Wisconsin</option>
<option value="50">Wyoming</option>
</select>
<input id="timeataddress" type="text" placeholder="Time at Present Address" name="timeatpresentaddress" />
<input id="rent" type="text" placeholder="Monthly Rent/Mortgage Payment" name="monthlyrent/mortgagepayment" />
<input id="jobtitle" type="text" placeholder="Present Job Title" name="presentjobtitle" />
<input id="employer" type="text" placeholder="Present Employer" name="presentemployer" />
<input id="employerphone" type="text" placeholder="Employer Phone Number" name="employerphonenumber" />
<input id="jobtime" type="text" placeholder="Time at Present Job" name="timeatpresentjob" />
<input id="grossincome" type="text" placeholder="Monthly Gross Income" name="monthlygrossincome" />
<input id="question-ask" type="submit" value="SUBMIT YOUR APPLICATION" class="btn btn-green" />
<div id="details-error"><i class="icon-alert"> </i>Please enter all details correctly</div>
<div id="form-sent"><i class="icon-check"> </i>Message sent, thanks for your enquiry</div>
</form>
</div>
</div>
</div>
</section>
PHP: [UPDATED]
<?php
if ($_POST) {
$firstname = $_POST['firstname'];
$middleinitial = $_POST['middleinitial'];
$lastname = $_POST['lastname'];
$email2 = $_POST['emailaddress'];
$form_dob_month = $_POST['dob_month'];
$form_dob_day = $_POST['dob_day'];
$form_dob_year = $_POST['dob_year'];
$social = $_POST['socialsecurity#'];
$Driver = $_POST['driverlicense#'];
$cellphone = $_POST['cellphone'];
$address = $_POST['streetaddress'];
$zip = $_POST['zipcode'];
$city = $_POST['city'];
$form_state = $_POST['state'];
$timeataddress = $_POST['timeatpresentaddress'];
$rent = $_POST['monthlyrent/mortgagepayment'];
$jobtitle = $_POST['presentjobtitle'];
$employer = $_POST['presentemployer'];
$employerphone = $_POST['employerphonenumber'];
$jobtime = $_POST['timeatpresentjob'];
$grossincome = $_POST['monthlygrossincome'];
}
$body = $email2.' has submitted some data';
mail("iamdrivingleads#yahoo.com", "email enquiry", $body);
?>
you have multi errors:
You should use attribute [name] in all HTML elements
example:
<input id="firstname" type="text" placeholder="First Name" name="firstname" />
You didn't use data POST values in you email body
You have an error in mail function you must remove last [,] from parameters
mail("iamdrivingleads#yahoo.com", "email enquiry", $body);
Good luck
Your PHP form won't send the form data to your email because:
Your form is using the method _POST instead of POST
The POST'ed variables you are accessing in your PHP script $_POST[...] should be identified with name attribute (instead of the id attribute you used) in your HTML script
As a side-note, I believe this code is not for production server, because it still lacks some conventional mail sending sanity checks, such as headers that will decrease the chances of your message ending up in spam folder, etc.

Why doesn't my PHP code Submit the application to my email? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 7 years ago.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Improve this question
I cannot figure out why my PHP code will not send the application I have to my email. The website is live and still has a lot of bugs but I’m trying to figure out why after I submit the application why won’t it go to my email. If someone could please help me out or point me into a direction were I could learn more about it I would greatly appreciate it as I am new to code.
PHP:
<?php
if ($POST) {
$firstname = $_POST['firstname'];
$middleinitial = $_POST['middleinitial'];
$lastname = $_POST['lastname'];
$email2 = $_POST['emailaddress'];
$form_dob_month = $_POST['month'];
$form_dob_day = $_POST['day'];
$form_dob_year = $_POST['year'];
$social = $_POST['socialsecurity#'];
$Driver = $_POST['driverlicense#'];
$cellphone = $_POST['cellphone'];
$address = $_POST['streetaddress'];
$zip = $_POST['zipcode'];
$city = $_POST['city'];
$form_state = $_POST['state'];
$timeataddress = $_POST['timeatpresentaddress'];
$rent = $_POST['monthlyrent/mortgagepayment'];
$jobtitle = $_POST['presentjobtitle'];
$employer = $_POST['presentemployer'];
$employerphone = $_POST['employerphonenumber'];
$jobtime = $_POST['timeatpresentjob'];
$grossincome = $_POST['monthlygrossincome'];
}
//send email
mail("iamdrivingleads#yahoo.com", "email enquiry", $text, "From:" . $email);
?>
HTML:
<section id="faq">
<div class="row pad-large">
<div class="row">
<div class="large-8 large-centered columns pad-bottom-small">
<div id="faq-form" class="text-center">
<form method = "_POST" action = "mail.php">
<input id="firstname" type="text" placeholder="First Name" />
<input id="middleinitial" type="text" placeholder="Middle Name" />
<input id="lastname" type="text" placeholder="Last Name" />
<input id="email2" type="text" placeholder="E-mail address" />
<select id="form_dob_month" name="dob_month">
<option value="-">Date</option>
<option value="1">January</option>
<option value="2">Febuary</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="form_dob_day" name="dob_day">
<option value="-">Of</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
<option value="24">24</option>
<option value="25">25</option>
<option value="26">26</option>
<option value="27">27</option>
<option value="28">28</option>
<option value="29">29</option>
<option value="30">30</option>
<option value="31">31</option>
</select>
<select id="form_dob_year" name="dob_year">
<option value="-">Birth</option>
<option value="2011">2011</option>
<option value="2010">2010</option>
<option value="2009">2009</option>
<option value="2008">2008</option>
<option value="2007">2007</option>
<option value="2006">2006</option>
<option value="2005">2005</option>
<option value="2004">2004</option>
<option value="2003">2003</option>
<option value="2002">2002</option>
<option value="2001">2001</option>
<option value="2000">2000</option>
<option value="1999">1999</option>
<option value="1998">1998</option>
<option value="1997">1997</option>
<option value="1996">1996</option>
<option value="1995">1995</option>
<option value="1994">1994</option>
<option value="1993">1993</option>
<option value="1992">1992</option>
<option value="1991">1991</option>
<option value="1990">1990</option>
<option value="1989">1989</option>
<option value="1988">1988</option>
<option value="1987">1987</option>
<option value="1986">1986</option>
<option value="1985">1985</option>
<option value="1984">1984</option>
<option value="1983">1983</option>
<option value="1982">1982</option>
<option value="1981">1981</option>
<option value="1980">1980</option>
<option value="1979">1979</option>
<option value="1978">1978</option>
<option value="1977">1977</option>
<option value="1976">1976</option>
<option value="1975">1975</option>
<option value="1974">1974</option>
<option value="1973">1973</option>
<option value="1972">1972</option>
<option value="1971">1971</option>
<option value="1970">1970</option>
<option value="1969">1969</option>
<option value="1968">1968</option>
<option value="1967">1967</option>
<option value="1966">1966</option>
<option value="1965">1965</option>
<option value="1964">1964</option>
<option value="1963">1963</option>
<option value="1962">1962</option>
<option value="1961">1961</option>
<option value="1960">1960</option>
<option value="1959">1959</option>
<option value="1984">1958</option>
<option value="1983">1957</option>
<option value="1982">1956</option>
<option value="1981">1955</option>
<option value="1980">1954</option>
<option value="1979">1953</option>
<option value="1978">1952</option>
<option value="1977">1951</option>
<option value="1976">1950</option>
<option value="1975">1949</option>
<option value="1974">1948</option>
<option value="1973">1947</option>
<option value="1972">1946</option>
<option value="1971">1945</option>
<option value="1970">1944</option>
<option value="1969">1943</option>
<option value="1968">1942</option>
<option value="1967">1941</option>
<option value="1966">1940</option>
<option value="1965">1939</option>
<option value="1964">1938</option>
<option value="1963">1937</option>
<option value="1962">1936</option>
<option value="1961">1935</option>
<option value="1960">1934</option>
<option value="1959">1933</option>
<option value="1961">1932</option>
<option value="1960">1931</option>
<option value="1959">1930</option>
<option value="1984">1929</option>
<option value="1983">1928</option>
<option value="1982">1927</option>
<option value="1981">1926</option>
<option value="1980">1925</option>
<option value="1979">1924</option>
<option value="1978">1923</option>
<option value="1977">1922</option>
<option value="1976">1921</option>
<option value="1975">1920</option>
<option value="1974">1919</option>
<option value="1973">1918</option>
<option value="1972">1917</option>
<option value="1971">1916</option>
<option value="1970">1915</option>
<option value="1969">1914</option>
<option value="1968">1913</option>
<option value="1967">1912</option>
<option value="1966">1911</option>
<option value="1965">1910</option>
</select>
<input id="social" type="text" placeholder="Social Security #" />
<input id="Driver" type="text" placeholder="Driver License #" />
<input id="cellphone" type="text" placeholder="Cell Phone" />
<input id="address" type="text" placeholder="Street Address" />
<input id="zip" type="text" placeholder="Zip Code" />
<input id="city" type="text" placeholder="City" />
<select id="form_state" name="State">
<option value="-">State</option>
<option value="1">Alabama</option>
<option value="2">Alaska</option>
<option value="3">Arizona</option>
<option value="4">Arkansas</option>
<option value="5">California</option>
<option value="6">Colorado</option>
<option value="7">Connecticut</option>
<option value="8">Delaware</option>
<option value="9">Florida</option>
<option value="10">Georgia</option>
<option value="11">Hawaii</option>
<option value="12">Idaho</option>
<option value="13">Illinois</option>
<option value="14">Indiana</option>
<option value="15">Iowa</option>
<option value="16">Kansas</option>
<option value="17">Kentucky</option>
<option value="18">Louisiana</option>
<option value="19">Maine</option>
<option value="20">Maryland</option>
<option value="21">Massachusetts</option>
<option value="22">Michigan</option>
<option value="23">Minnesota</option>
<option value="24">Mississippi</option>
<option value="25">Missouri</option>
<option value="26">Montana</option>
<option value="27">Nebraska </option>
<option value="28">Nevada</option>
<option value="29">New Hampshire</option>
<option value="30">New Jersey</option>
<option value="31">New Mexico</option>
<option value="32">New York</option>
<option value="33">North Carolina</option>
<option value="34">North Dakota</option>
<option value="35">Ohio</option>
<option value="36">Oklahoma</option>
<option value="37">Oregon</option>
<option value="38">Pennsylvania</option>
<option value="39">Rhode Island</option>
<option value="40">South Carolina</option>
<option value="41">South Dakota</option>
<option value="42">Tennessee</option>
<option value="43">Texas</option>
<option value="44">Utah</option>
<option value="45">Vermont</option>
<option value="46">Virginia</option>
<option value="47">Washington</option>
<option value="48">West Virginia</option>
<option value="49">Wisconsin</option>
<option value="50">Wyoming</option>
</select>
<input id="timeataddress" type="text" placeholder="Time at Present Address" />
<input id="rent" type="text" placeholder="Monthly Rent/Mortgage Payment" />
<input id="jobtitle" type="text" placeholder="Present Job Title" />
<input id="employer" type="text" placeholder="Present Employer" />
<input id="employerphone" type="text" placeholder="Employer Phone Number" />
<input id="jobtime" type="text" placeholder="Time at Present Job" />
<input id="grossincome" type="text" placeholder="Monthly Gross Income" />
<input id="question-ask" type="submit" value="SUBMIT YOUR APPLICATION" class="btn btn-green" />
<div id="details-error"><i class="icon-alert"> </i>Please enter all details correctly</div>
<div id="form-sent"><i class="icon-check"> </i>Message sent, thanks for your enquiry</div>
</form>
Whatever you are doing it is wrong.
1.First visit the mail.php file in your browswer , Check if any error .If there is solve it.
2.If there is no error , its time to debug why its not submitting.I see you are trying to email all the $_post contents to your email.To do so try this
<?php
if ($_POST) {
$firstname = $_POST['firstname'];
$middleinitial = $_POST['middleinitial'];
$lastname = $_POST['lastname'];
$email2 = $_POST['emailaddress'];
$form_dob_month = $_POST['month'];
$form_dob_day = $_POST['day'];
$form_dob_year = $_POST['year'];
$social = $_POST['socialsecurity#'];
$Driver = $_POST['driverlicense#'];
$cellphone = $_POST['cellphone'];
$address = $_POST['streetaddress'];
$zip = $_POST['zipcode'];
$city = $_POST['city'];
$form_state = $_POST['state'];
$timeataddress = $_POST['timeatpresentaddress'];
$rent = $_POST['monthlyrent/mortgagepayment'];
$jobtitle = $_POST['presentjobtitle'];
$employer = $_POST['presentemployer'];
$employerphone = $_POST['employerphonenumber'];
$jobtime = $_POST['timeatpresentjob'];
$grossincome = $_POST['monthlygrossincome'];
}
$body = $email2.' has submitted some data';
mail("iamdrivingleads#yahoo.com", "email enquiry", $body,);
?>

Mysql PHP edit form errors

I have an error in my form and I am not sure how to fix it. I receive a Notice Line 353 and 354 Undefined Variable after clicking the button to modify the record. I also see that all of the input boxes have:
Notice: Undefined variable: row in C:\xampp\htdocs\group\modify.php on line 35
Not sure how to fix any help is appreciated. code to the form below:
<?php
//require "admin_login.php";
//include "admin_connect.php"
$conn = mysqli_connect("localhost", "admin",
"admin9090", "linkyoutube");
mysql_select_db("linkyoutube");
if (mysqli_connect_errno()){
echo 'Cannot connect to database: ' .
mysqli_connect_error($conn);
}
if (!isset($_POST['submit'])) {
$query = "select * from submited left join person on person.person_id=submited.person_id where person.person_id= $_GET[id];";
$result = mysqli_query($conn,$query);
$row = mysqli_fetch_array($result) ;
}
?>
<!doctype html>
<head>
<meta charset="utf-8">
<title>LAB 1 6203</title>
<meta name="description" content="6203 Lab 1 ">
<link rel="stylesheet" href="css/style.css?v=1">
</head>
<body>
<h1>Submit a link</h1>
<?php include "menu2.php";?><br>
<h1>Modifying Record</h1>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" id="Form1" method="post" onSubmit="return validateForm();">
<p>First Name: <input type="text" name="fname" value="<?php echo $row['firstname']; ?>" size="60"></p>
<p>Last Name: <input type="text" name="lname" value="<?php echo $row['lastname']; ?>" size="60"></p>
<p>Email: <input type="text" name="email" value="<?php echo $row['email']; ?>" size="60"></p>
<p>Telephone: <input id="phone" name="phone" type="text" placeholder="Eg. +447000 000000" value="<?php echo $row['telephone']; ?>" required></p>
<p>Address: <input type="text" textarea name="address" type="text" value="<?php echo $row['address']; ?>" cols="30" rows="10"></textarea></p>
<p>Select a State <select id="state" type="text" name="state" >
<option value="<?php echo $row['state']; ?>" ><?php echo $row['state']; ?></option>
<option value="">Select State</option>
<option value="AL">Alabama</option>
<option value="AK">Alaska</option>
<option value="AZ">Arizona</option>
<option value="AR">Arkansas</option>
<option value="CA">California</option>
<option value="CO">Colorado</option>
<option value="CT">Connecticut</option>
<option value="DE">Delaware</option>
<option value="DC">District Of Columbia</option>
<option value="FL">Florida</option>
<option value="GA">Georgia</option>
<option value="HI">Hawaii</option>
<option value="ID">Idaho</option>
<option value="IL">Illinois</option>
<option value="IN">Indiana</option>
<option value="IA">Iowa</option>
<option value="KS">Kansas</option>
<option value="KY">Kentucky</option>
<option value="LA">Louisiana</option>
<option value="ME">Maine</option>
<option value="MD">Maryland</option>
<option value="MA">Massachusetts</option>
<option value="MI">Michigan</option>
<option value="MN">Minnesota</option>
<option value="MS">Mississippi</option>
<option value="MO">Missouri</option>
<option value="MT">Montana</option>
<option value="NE">Nebraska</option>
<option value="NV">Nevada</option>
<option value="NH">New Hampshire</option>
<option value="NJ">New Jersey</option>
<option value="NM">New Mexico</option>
<option value="NY">New York</option>
<option value="NC">North Carolina</option>
<option value="ND">North Dakota</option>
<option value="OH">Ohio</option>
<option value="OK">Oklahoma</option>
<option value="OR">Oregon</option>
<option value="PA">Pennsylvania</option>
<option value="RI">Rhode Island</option>
<option value="SC">South Carolina</option>
<option value="SD">South Dakota</option>
<option value="TN">Tennessee</option>
<option value="TX">Texas</option>
<option value="UT">Utah</option>
<option value="VT">Vermont</option>
<option value="VA">Virginia</option>
<option value="WA">Washington</option>
<option value="WV">West Virginia</option>
<option value="WI">Wisconsin</option>
<option value="WY">Wyoming</option>
<option value="AS">American Samoa</option>
<option value="GU">Guam</option>
<option value="MP">Northern Mariana Islands</option>
<option value="PR">Puerto Rico</option>
<option value="UM">United States Minor Outlying Islands</option>
<option value="VI">Virgin Islands</option>
</select></p>
<p>Select a Country <select id="country" name="country" ">
<option value="<?php echo $row['country']; ?>"><?php echo $row['country']; ?></option>
<option value="Afganistan">Afghanistan</option>
<option value="Albania">Albania</option>
<option value="Algeria">Algeria</option>
<option value="American Samoa">American Samoa</option>
<option value="Andorra">Andorra</option>
<option value="Angola">Angola</option>
<option value="Anguilla">Anguilla</option>
<option value="Antigua & Barbuda">Antigua & Barbuda</option>
<option value="Argentina">Argentina</option>
<option value="Armenia">Armenia</option>
<option value="Aruba">Aruba</option>
<option value="Australia">Australia</option>
<option value="Austria">Austria</option>
<option value="Azerbaijan">Azerbaijan</option>
<option value="Bahamas">Bahamas</option>
<option value="Bahrain">Bahrain</option>
<option value="Bangladesh">Bangladesh</option>
<option value="Barbados">Barbados</option>
<option value="Belarus">Belarus</option>
<option value="Belgium">Belgium</option>
<option value="Belize">Belize</option>
<option value="Benin">Benin</option>
<option value="Bermuda">Bermuda</option>
<option value="Bhutan">Bhutan</option>
<option value="Bolivia">Bolivia</option>
<option value="Bonaire">Bonaire</option>
<option value="Bosnia & Herzegovina">Bosnia & Herzegovina</option>
<option value="Botswana">Botswana</option>
<option value="Brazil">Brazil</option>
<option value="British Indian Ocean Ter">British Indian Ocean Ter</option>
<option value="Brunei">Brunei</option>
<option value="Bulgaria">Bulgaria</option>
<option value="Burkina Faso">Burkina Faso</option>
<option value="Burundi">Burundi</option>
<option value="Cambodia">Cambodia</option>
<option value="Cameroon">Cameroon</option>
<option value="Canada">Canada</option>
<option value="Canary Islands">Canary Islands</option>
<option value="Cape Verde">Cape Verde</option>
<option value="Cayman Islands">Cayman Islands</option>
<option value="Central African Republic">Central African Republic</option>
<option value="Chad">Chad</option>
<option value="Channel Islands">Channel Islands</option>
<option value="Chile">Chile</option>
<option value="China">China</option>
<option value="Christmas Island">Christmas Island</option>
<option value="Cocos Island">Cocos Island</option>
<option value="Colombia">Colombia</option>
<option value="Comoros">Comoros</option>
<option value="Congo">Congo</option>
<option value="Cook Islands">Cook Islands</option>
<option value="Costa Rica">Costa Rica</option>
<option value="Cote DIvoire">Cote D'Ivoire</option>
<option value="Croatia">Croatia</option>
<option value="Cuba">Cuba</option>
<option value="Curaco">Curacao</option>
<option value="Cyprus">Cyprus</option>
<option value="Czech Republic">Czech Republic</option>
<option value="Denmark">Denmark</option>
<option value="Djibouti">Djibouti</option>
<option value="Dominica">Dominica</option>
<option value="Dominican Republic">Dominican Republic</option>
<option value="East Timor">East Timor</option>
<option value="Ecuador">Ecuador</option>
<option value="Egypt">Egypt</option>
<option value="El Salvador">El Salvador</option>
<option value="Equatorial Guinea">Equatorial Guinea</option>
<option value="Eritrea">Eritrea</option>
<option value="Estonia">Estonia</option>
<option value="Ethiopia">Ethiopia</option>
<option value="Falkland Islands">Falkland Islands</option>
<option value="Faroe Islands">Faroe Islands</option>
<option value="Fiji">Fiji</option>
<option value="Finland">Finland</option>
<option value="France">France</option>
<option value="French Guiana">French Guiana</option>
<option value="French Polynesia">French Polynesia</option>
<option value="French Southern Ter">French Southern Ter</option>
<option value="Gabon">Gabon</option>
<option value="Gambia">Gambia</option>
<option value="Georgia">Georgia</option>
<option value="Germany">Germany</option>
<option value="Ghana">Ghana</option>
<option value="Gibraltar">Gibraltar</option>
<option value="Great Britain">Great Britain</option>
<option value="Greece">Greece</option>
<option value="Greenland">Greenland</option>
<option value="Grenada">Grenada</option>
<option value="Guadeloupe">Guadeloupe</option>
<option value="Guam">Guam</option>
<option value="Guatemala">Guatemala</option>
<option value="Guinea">Guinea</option>
<option value="Guyana">Guyana</option>
<option value="Haiti">Haiti</option>
<option value="Hawaii">Hawaii</option>
<option value="Honduras">Honduras</option>
<option value="Hong Kong">Hong Kong</option>
<option value="Hungary">Hungary</option>
<option value="Iceland">Iceland</option>
<option value="India">India</option>
<option value="Indonesia">Indonesia</option>
<option value="Iran">Iran</option>
<option value="Iraq">Iraq</option>
<option value="Ireland">Ireland</option>
<option value="Isle of Man">Isle of Man</option>
<option value="Israel">Israel</option>
<option value="Italy">Italy</option>
<option value="Jamaica">Jamaica</option>
<option value="Japan">Japan</option>
<option value="Jordan">Jordan</option>
<option value="Kazakhstan">Kazakhstan</option>
<option value="Kenya">Kenya</option>
<option value="Kiribati">Kiribati</option>
<option value="Korea North">Korea North</option>
<option value="Korea Sout">Korea South</option>
<option value="Kuwait">Kuwait</option>
<option value="Kyrgyzstan">Kyrgyzstan</option>
<option value="Laos">Laos</option>
<option value="Latvia">Latvia</option>
<option value="Lebanon">Lebanon</option>
<option value="Lesotho">Lesotho</option>
<option value="Liberia">Liberia</option>
<option value="Libya">Libya</option>
<option value="Liechtenstein">Liechtenstein</option>
<option value="Lithuania">Lithuania</option>
<option value="Luxembourg">Luxembourg</option>
<option value="Macau">Macau</option>
<option value="Macedonia">Macedonia</option>
<option value="Madagascar">Madagascar</option>
<option value="Malaysia">Malaysia</option>
<option value="Malawi">Malawi</option>
<option value="Maldives">Maldives</option>
<option value="Mali">Mali</option>
<option value="Malta">Malta</option>
<option value="Marshall Islands">Marshall Islands</option>
<option value="Martinique">Martinique</option>
<option value="Mauritania">Mauritania</option>
<option value="Mauritius">Mauritius</option>
<option value="Mayotte">Mayotte</option>
<option value="Mexico">Mexico</option>
<option value="Midway Islands">Midway Islands</option>
<option value="Moldova">Moldova</option>
<option value="Monaco">Monaco</option>
<option value="Mongolia">Mongolia</option>
<option value="Montserrat">Montserrat</option>
<option value="Morocco">Morocco</option>
<option value="Mozambique">Mozambique</option>
<option value="Myanmar">Myanmar</option>
<option value="Nambia">Nambia</option>
<option value="Nauru">Nauru</option>
<option value="Nepal">Nepal</option>
<option value="Netherland Antilles">Netherland Antilles</option>
<option value="Netherlands">Netherlands (Holland, Europe)</option>
<option value="Nevis">Nevis</option>
<option value="New Caledonia">New Caledonia</option>
<option value="New Zealand">New Zealand</option>
<option value="Nicaragua">Nicaragua</option>
<option value="Niger">Niger</option>
<option value="Nigeria">Nigeria</option>
<option value="Niue">Niue</option>
<option value="Norfolk Island">Norfolk Island</option>
<option value="Norway">Norway</option>
<option value="Oman">Oman</option>
<option value="Pakistan">Pakistan</option>
<option value="Palau Island">Palau Island</option>
<option value="Palestine">Palestine</option>
<option value="Panama">Panama</option>
<option value="Papua New Guinea">Papua New Guinea</option>
<option value="Paraguay">Paraguay</option>
<option value="Peru">Peru</option>
<option value="Phillipines">Philippines</option>
<option value="Pitcairn Island">Pitcairn Island</option>
<option value="Poland">Poland</option>
<option value="Portugal">Portugal</option>
<option value="Puerto Rico">Puerto Rico</option>
<option value="Qatar">Qatar</option>
<option value="Republic of Montenegro">Republic of Montenegro</option>
<option value="Republic of Serbia">Republic of Serbia</option>
<option value="Reunion">Reunion</option>
<option value="Romania">Romania</option>
<option value="Russia">Russia</option>
<option value="Rwanda">Rwanda</option>
<option value="St Barthelemy">St Barthelemy</option>
<option value="St Eustatius">St Eustatius</option>
<option value="St Helena">St Helena</option>
<option value="St Kitts-Nevis">St Kitts-Nevis</option>
<option value="St Lucia">St Lucia</option>
<option value="St Maarten">St Maarten</option>
<option value="St Pierre & Miquelon">St Pierre & Miquelon</option>
<option value="St Vincent & Grenadines">St Vincent & Grenadines</option>
<option value="Saipan">Saipan</option>
<option value="Samoa">Samoa</option>
<option value="Samoa American">Samoa American</option>
<option value="San Marino">San Marino</option>
<option value="Sao Tome & Principe">Sao Tome & Principe</option>
<option value="Saudi Arabia">Saudi Arabia</option>
<option value="Senegal">Senegal</option>
<option value="Serbia">Serbia</option>
<option value="Seychelles">Seychelles</option>
<option value="Sierra Leone">Sierra Leone</option>
<option value="Singapore">Singapore</option>
<option value="Slovakia">Slovakia</option>
<option value="Slovenia">Slovenia</option>
<option value="Solomon Islands">Solomon Islands</option>
<option value="Somalia">Somalia</option>
<option value="South Africa">South Africa</option>
<option value="Spain">Spain</option>
<option value="Sri Lanka">Sri Lanka</option>
<option value="Sudan">Sudan</option>
<option value="Suriname">Suriname</option>
<option value="Swaziland">Swaziland</option>
<option value="Sweden">Sweden</option>
<option value="Switzerland">Switzerland</option>
<option value="Syria">Syria</option>
<option value="Tahiti">Tahiti</option>
<option value="Taiwan">Taiwan</option>
<option value="Tajikistan">Tajikistan</option>
<option value="Tanzania">Tanzania</option>
<option value="Thailand">Thailand</option>
<option value="Togo">Togo</option>
<option value="Tokelau">Tokelau</option>
<option value="Tonga">Tonga</option>
<option value="Trinidad & Tobago">Trinidad & Tobago</option>
<option value="Tunisia">Tunisia</option>
<option value="Turkey">Turkey</option>
<option value="Turkmenistan">Turkmenistan</option>
<option value="Turks & Caicos Is">Turks & Caicos Is</option>
<option value="Tuvalu">Tuvalu</option>
<option value="Uganda">Uganda</option>
<option value="Ukraine">Ukraine</option>
<option value="United Arab Erimates">United Arab Emirates</option>
<option value="United Kingdom">United Kingdom</option>
<option value="United States of America">United States of America</option>
<option value="Uraguay">Uruguay</option>
<option value="Uzbekistan">Uzbekistan</option>
<option value="Vanuatu">Vanuatu</option>
<option value="Vatican City State">Vatican City State</option>
<option value="Venezuela">Venezuela</option>
<option value="Vietnam">Vietnam</option>
<option value="Virgin Islands (Brit)">Virgin Islands (Brit)</option>
<option value="Virgin Islands (USA)">Virgin Islands (USA)</option>
<option value="Wake Island">Wake Island</option>
<option value="Wallis & Futana Is">Wallis & Futana Is</option>
<option value="Yemen">Yemen</option>
<option value="Zaire">Zaire</option>
<option value="Zambia">Zambia</option>
<option value="Zimbabwe">Zimbabwe</option>
</select>
<p>Gender <p><input type="radio" name="gender" value="Male" <?php if ($row['sex'] == 'Male') echo 'checked="checked"'; ?>> Male</p>
<p><input type="radio" name="gender" value="Female" <?php if ($row['sex'] == 'Female') echo 'checked="checked"'; ?>> Female</p>
<p>Link Address: <input type="text" name="link" size="60" value="<?php echo $row['link']; ?>"></p>
<p>Description of the link: <textarea name="description" cols="50" rows="20" value="<?php echo $row['description']; ?>"><?php echo $row['description']; ?></textarea></p>
<p>Link Category 1 <select id="type1" name="type1" value="" >
<option value="<?php echo $row['type1']; ?>"><?php echo $row['type1']; ?></option>
<option value="Video">Video</option>
<option value="Article">Article</option>
<option value="Newspaper">Newspaper</option>
<option value="Magazine">Magazine</option>
<option value="Social Media">Social Media</option>
<option value="Book">Book</option>
<option value="Other">Other</option>
</select></p>
<p>Link Category 2 <select id="type2" name="type2" value="">
<option value="<?php echo $row['type2']; ?>"><?php echo $row['type2']; ?></option>
<option value="Science">Science</option>
<option value="Health">Health</option>
<option value="Technology">Technology</option>
<option value="Comedy">Comedy</option>
<option value="National News">National News</option>
<option value="Home">Home</option>
<option value="Education">Education</option>
</select></p>
<input type="hidden" name="id" value="<?php echo $_GET['id']; ?>" />
<p><input type="submit" name="submit" value="Modify"> </p>
</form>
<?php
if(isset($_POST['submit'])) {
$update1 ="update person set firstname='$_POST[fname]', lastname='$_POST[lname]',email='$_POST[email]',
telephone='$_POST[phone]',address='$_POST[address]',state='$_POST[state]',
country='$_POST[country]',sex='$_POST[gender]'where person_id=$_POST[id]";
mysqli_query($conn,$update1) or die(mysql_error());
echo "User had been modified!";
//header("Location: admint.php");
}
?>
You are trying to access $row which are not set after form submission ie, $row is available only before you have submitted the form . Access the $row only if it is set. Try with this
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" id="Form1" method="post" onSubmit="return validateForm();">
<p>First Name: <input type="text" name="fname" value="<?php if(isset($row['firstname'])) echo $row['firstname']; ?>" size="60"></p>
<p>Last Name: <input type="text" name="lname" value="<?php if(isset($row['lastname'])) echo $row['lastname']; ?>" size="60"></p>
<p>Email: <input type="text" name="email" value="<?php if(isset($row['email'])) echo $row['email']; ?>" size="60"></p>
<p>Telephone: <input id="phone" name="phone" type="text" placeholder="Eg. +447000 000000" value="<?php if(isset($row['telephone'])) echo $row['telephone']; ?>" required></p>
<p>Address: <input type="text" textarea name="address" type="text" value="<?php if(isset($row['address'])) echo $row['address']; ?>" cols="30" rows="10"></textarea></p>

FILE_APPEND not working properly with file_put_contents

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));

Where to put the validation code of php form validation

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'] : '' ?>' />

Categories