PHP - Collect Unique Impression Of A Website
Hello every body
I want to track unique visitors of a website but failed to do.. first I thought of tracking their ip but ip changes very frequently. second I thought of tracking their mac address and date from which I can track unique visits but in some server tracking mac address is returning thier servers mac address instead of returning the visitors. so is their any way I can acheive it. I can easily do it with cookies but cookies can be altered by their owner so making this option as in blacklist. so is there any other way to do it... thanks in advance... Similar TutorialsI have a mysql table which will store users email addresses (each is unique and is the primary field) and a timestamp. I have added another column called `'unique_code' (varchar(64), utf8_unicode_ci)`. What I would very much appreciate assistance with is; a) Generating a 5 digit alphanumeric code, ie: 5ABH6 b) Check all rows the 'unique_code' column to ensure it is unique, otherwise re-generate and check again c) Insert the uniquely generated 5 digit alphanumeric code into `'unique_code'` column, corresponding to the email address just entered. d) display the code on screen. What code must I put and where? **My current php is as follows:** Code: [Select] require "includes/connect.php"; $msg = ''; if($_POST['email']){ // Requested with AJAX: $ajax = ($_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest'); try{ if(!filter_input(INPUT_POST,'email',FILTER_VALIDATE_EMAIL)){ throw new Exception('Invalid Email!'); } $mysqli->query("INSERT INTO coming_soon_emails SET email='".$mysqli->real_escape_string($_POST['email'])."'"); if($mysqli->affected_rows != 1){ throw new Exception('You are already on the notification list.'); } if($ajax){ die('{"status":1}'); } $msg = "Thank you!"; } catch (Exception $e){ if($ajax){ die(json_encode(array('error'=>$e->getMessage()))); } $msg = $e->getMessage(); } } Hi,
I am doing a survey and need a little guidance. I have data being selected from one table and I am trying to store it in another. I have no problem selecting the data and displaying it, I just can't get it to continue on with the new survey. Here is the file showing the data collected:
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <title>Question 1</title> </head> <body> <?php session_start(); $_SESSION['name'] = $_POST['name']; $_SESSION['cslogin'] = $_POST['cslogin']; $_SESSION['domain'] = $_POST['domain']; $_SESSION['project'] = $_POST['project']; $_SESSION['ODM'] = $_POST['ODM']; $_SESSION['hwphase'] = $_POST['hwphase']; $_SESSION['ppmid'] = $_POST['ppmid']; $_SESSION['survey'] = $_POST['survey']; $_SESSION['month'] = $_POST['month']; ?> Name: <?php echo $_POST['name'];?><br> CS Login: <?php echo $_POST['cslogin'];?><br> Domain: <?php echo $_POST['domain'];?><br> Project: <?php echo $_POST['project'];?><br> ODM: <?php echo $_POST['ODM'];?><br> HW Phase: <?php echo $_POST['hwphase'];?><br> PPM ID: <?php echo $_POST['ppmid'];?><br> Survey: <?php echo $_POST['survey'];?><br> Month: <?php echo $_POST['month'];?><br>Everything from table 1 is displayed above. No problem. Here is the next page after this. Question #1 has already been answered: <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <title>Question 2</title> </head> <body> <?php session_start(); $name = $_SESSION['name']; $cslogin = $_SESSION['cslogin']; $domain = $_SESSION['domain']; $project = $_SESSION['project']; $ODM = $_SESSION['ODM']; $hwphase = $_SESSION['hwphase']; $ppmid = $_SESSION['ppmid']; $survey = $_SESSION['survey']; $month = $_SESSION['month']; $Q1 = $_SESSION['Q1']; $comment1 = $_SESSION['comment1']; ?> Name: <?php echo $_SESSION['name'];?><br> Q1: <?php echo $_SESSION['Q1'];?><br> Comments: <?php echo $_SESSION['comment1'];?><br>It displays question 1 and comments with no problem. This is where the "name - month" is lost. How would I have name - month continue on to be store in a new table? I greatly appreciate your help. Thanks!! Note: based on the question for #1, the user is redirected to question 2 or question 3. Here is the file that is between Q1 and Q2 <?php session_start(); $_SESSION['name'] = $_POST['name']; $_SESSION['cslogin'] = $_POST['cslogin']; $_SESSION['domain'] = $_POST['domain']; $_SESSION['project'] = $_POST['project']; $_SESSION['ODM'] = $_POST['ODM']; $_SESSION['hwphase'] = $_POST['hwphase']; $_SESSION['ppmid'] = $_POST['ppmid']; $_SESSION['survey'] = $_POST['survey']; $_SESSION['month'] = $_POST['month']; $_SESSION['Q1'] = $_POST['Q1']; $_SESSION['comment1'] = $_POST['comment1']; switch ($_POST['Q1']) { case "No": $url = "filename"; break; case "Yes": $url = "http://odmQ3_a.php"; break; case "Supplier Assessment is ongoing and issues still being worked": $url = "odmQ3_a.php"; } header("Location: $url"); ?> Edited by Ch0cu3r, 19 January 2015 - 12:19 PM. Added code tags I want to create an animation using an image that refreshes every hour hosted at this url: http://www.bungie.net/stats/reach/nightmap.ashx What is the best way to store the images and then animate(loop) the 24 most recent images? Should I use a mysql database to store it or something else? What are your thoughts? Thanks I am realy doing my best , but i am bad at php , when i click update bottum on edit_profil.php page it put me over to update.php, but update.php is blank , and cant see any errors. and it has not updated mysql. Files: // form page. edit_profil.php // Data from edit_profil to mysql update.php ___________________________ edit_profil.php Code: [Select] <?php // Check if user is logged in session_start(); if ($_SESSION['s_logged_n'] == 'true'){ $username = $_SESSION['s_username']; $usermail = $_SESSION['s_usermail']; // Get the id if (isset($_GET['id'])){ // Include config file include "config.php"; // Define id $id = $_GET['id']; // Query table $query = "SELECT * FROM users WHERE user_id = '$id' AND username = '$username' LIMIT 1"; $result = mysql_query($query); $check = mysql_num_rows($result); // If user try to edit someone's else profile it will say it can't if (!$check == 1){ echo "You can edit your profile only"; // Else if everything is ok display form } else { ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <link href="css/test.css" rel="stylesheet" type="text/css" /> </head> <body> <div class="bodyContentCenter"> <h1>My Profile</h1> <div class="solidThickLine"></div> <div class="breakLine"><!-- --></div> <div class="loginColumnBorder" style="width:100%;"> <form action="update.php?id=<?php echo "$id" ?>" method="post"> <table border="0" width="100%" cellspacing="10" cellpadding="0"> <tbody><tr> <td> <div style="font-size:16px;font-weight:bold;">Edit Profile</div> <div class="breakLine"><!-- --></div> <div>Personal information obtained are used solely for the purpose of enhancing the functionality and level of service.</div> <div class="breakLine" style="height:20px;"><!-- --></div> <table border="0" width="100%" cellspacing="0" cellpadding="0"> <tbody><tr><td colspan="3" style="font-weight:bold">LOGIN E-MAIL & PASSWORD</td></tr> <tr><td colspan="3"><div class="breakLine"></div></td></tr> <tr style="height:45px;" valign="top"> <td style="width:120px;">E-mail Address:</td> <td style="width:220px;"> <label for="e_mail_address"></label> <input type="text" name="e_mail_address" value="<?php echo "$usermail"; ?>" id="e_mail_address"> *</td> </tr> <tr style="height:45px;" valign="top"> <td style="width:120px;">New Password:</td> <td style="width:220px;"> <label for="password"></label> <input type="password" name="password" id="password"> *</td> </tr> <tr style="height:45px;" valign="top"> <td style="width:120px;">Confirm New Password:</td> <td style="width:220px;"><label for="password_confirm"></label> <input type="password" name="password_confirm" id="password_confirm"> *</td> <td style="width:380px;"><div id="confirm_password_message"></div> </td> </tr> <tr><td colspan="3"><div class="dottedLine" style="lin-height: 2px;"> </div></td></tr> <!--tr><td colspan="3"><div class="breakLine"></div></td></tr--> <tr><td colspan="3" style="font-weight:bold" valign="top">PERSONAL DETAILS</td></tr> <tr><td colspan="3"><div class="breakLine"></div></td></tr> <tr style="height:45px;" valign="top"> <td style="width:120px;">First Name:</td> <td style="width:220px;"><input type="text" name="edit_profile_firstname" value="lasse" id="firstname"> *</td> </tr> <tr style="height:45px;" valign="top"> <td style="width:120px;">Last Name:</td> <td style="width:220px;"><input type="text" name="edit_profile_lastname" id="lastname"> *</td> </tr> <tr style="height:45px;" valign="top"> <td style="width:120px;">Country Code: </td> <td style="width:220px;"><select name="edit_profile_country_code" style="width:150px;" id="country"><option value="1">Afghanistan +93</option><option value="2">Albania +355</option><option value="3">Algeria +213</option><option value="4">American Samoa +684</option><option value="5">Andorra +376</option><option value="6">Angola +244</option><option value="7">Anguilla +1264</option><option value="8">Antarctica +672</option><option value="9">Antigua and Barbuda +1268</option><option value="10">Argentina +54</option><option value="11">Armenia +374</option><option value="12">Aruba +297</option><option value="13">Australia +61</option><option value="14">Austria +43</option><option value="15">Azerbaijan +994</option><option value="16">Bahamas +1242</option><option value="17">Bahrain +973</option><option value="18">Bangladesh +880</option><option value="19">Barbados +1246</option><option value="20">Belarus +375</option><option value="21">Belgium +32</option><option value="22">Belize +501</option><option value="23">Benin +229</option><option value="24">Bermuda +1441</option><option value="25">Bhutan +975</option><option value="26">Bolivia +591</option><option value="27">Bosnia and Herzegovina +387</option><option value="28">Botswana +267</option><option value="29">Bouvet Island +47</option><option value="30">Brazil +55</option><option value="31">British Indian Ocean Territory +246</option><option value="32">Brunei Darussalam +673</option><option value="33">Bulgaria +359</option><option value="34">Burkina Faso +226</option><option value="35">Burundi +257</option><option value="36">Cambodia +855</option><option value="37">Cameroon +237</option><option value="38">Canada +1</option><option value="39">Cape Verde +238</option><option value="40">Cayman Islands +1345</option><option value="41">Central African Republic +236</option><option value="42">Chad +235</option><option value="43">Chile +56</option><option value="44">China +86</option><option value="45">Christmas Island +61</option><option value="46">Cocos (Keeling) Islands +61</option><option value="47">Colombia +57</option><option value="48">Comoros +269</option><option value="49">Congo +242</option><option value="50">Cook Islands +682</option><option value="51">Costa Rica +506</option><option value="52">Cote D'Ivoire +225</option><option value="53">Croatia +385</option><option value="54">Cuba +53</option><option value="55">Cyprus +357</option><option value="56">Czech Republic +420</option><option value="57" selected="">Denmark +45</option><option value="58">Djibouti +253</option><option value="59">Dominica +1767</option><option value="60">Dominican Republic +1809</option><option value="61">East Timor +670</option><option value="62">Ecuador +593</option><option value="63">Egypt +20</option><option value="64">El Salvador +503</option><option value="65">Equatorial Guinea +240</option><option value="66">Eritrea +291</option><option value="67">Estonia +372</option><option value="68">Ethiopia +251</option><option value="69">Falkland Islands (Malvinas) +500</option><option value="70">Faroe Islands +298</option><option value="71">Fiji +679</option><option value="72">Finland +358</option><option value="73">France +33</option><option value="74">France, Metropolitan +33</option><option value="75">French Guiana +594</option><option value="76">French Polynesia +689</option><option value="77">French Southern Territories +</option><option value="78">Gabon +241</option><option value="79">Gambia +220</option><option value="80">Georgia +995</option><option value="81">Germany +49</option><option value="82">Ghana +233</option><option value="83">Gibraltar +350</option><option value="84">Greece +30</option><option value="85">Greenland +299</option><option value="86">Grenada +1473</option><option value="87">Guadeloupe +590</option><option value="88">Guam +1671</option><option value="89">Guatemala +502</option><option value="242">Guernsey +44</option><option value="90">Guinea +224</option><option value="91">Guinea-bissau +245</option><option value="92">Guyana +592</option><option value="93">Haiti +509</option><option value="94">Heard and Mc Donald Islands +672</option><option value="95">Honduras +504</option><option value="96">Hong Kong +852</option><option value="97">Hungary +36</option><option value="98">Iceland +354</option><option value="99">India +91</option><option value="100">Indonesia +62</option><option value="101">Iran (Islamic Republic of) +98</option><option value="102">Iraq +964</option><option value="103">Ireland +353</option><option value="104">Israel +972</option><option value="105">Italy +39</option><option value="106">Jamaica +1876</option><option value="107">Japan +81</option><option value="108">Jordan +962</option><option value="109">Kazakhstan +7</option><option value="110">Kenya +254</option><option value="111">Kiribati +686</option><option value="112">Korea, Democratic People's Republic of +850</option><option value="113">Korea, Republic of +82</option><option value="114">Kuwait +965</option><option value="115">Kyrgyzstan +996</option><option value="116">Lao People's Democratic Republic +856</option><option value="117">Latvia +371</option><option value="118">Lebanon +961</option><option value="119">Lesotho +266</option><option value="120">Liberia +231</option><option value="121">Libyan Arab Jamahiriya +218</option><option value="122">Liechtenstein +423</option><option value="123">Lithuania +370</option><option value="124">Luxembourg +352</option><option value="125">Macau +853</option><option value="126">Macedonia, The Former Yugoslav Republic of +389</option><option value="127">Madagascar +261</option><option value="128">Malawi +265</option><option value="129">Malaysia +60</option><option value="130">Maldives +960</option><option value="131">Mali +223</option><option value="132">Malta +356</option><option value="133">Marshall Islands +692</option><option value="134">Martinique +596</option><option value="135">Mauritania +222</option><option value="136">Mauritius +230</option><option value="137">Mayotte +269</option><option value="138">Mexico +52</option><option value="139">Micronesia, Federated States of +591</option><option value="140">Moldova, Republic of +373</option><option value="141">Monaco +377</option><option value="142">Mongolia +976</option><option value="241">Montenegro +382</option><option value="143">Montserrat +1664</option><option value="144">Morocco +212</option><option value="145">Mozambique +258</option><option value="146">Myanmar +95</option><option value="147">Namibia +264</option><option value="148">Nauru +674</option><option value="149">Nepal +977</option><option value="150">Netherlands +31</option><option value="151">Netherlands Antilles +599</option><option value="152">New Caledonia +687</option><option value="153">New Zealand +64</option><option value="154">Nicaragua +505</option><option value="155">Niger +227</option><option value="156">Nigeria +234</option><option value="157">Niue +683</option><option value="158">Norfolk Island +672</option><option value="159">Northern Mariana Islands +1670</option><option value="160">Norway +47</option><option value="161">Oman +968</option><option value="162">Pakistan +92</option><option value="163">Palau +680</option><option value="164">Panama +507</option><option value="165">Papua New Guinea +675</option><option value="166">Paraguay +595</option><option value="167">Peru +51</option><option value="168">Philippines +63</option><option value="169">Pitcairn +872</option><option value="170">Poland +48</option><option value="171">Portugal +351</option><option value="172">Puerto Rico +1787</option><option value="173">Qatar +974</option><option value="174">Reunion +262</option><option value="175">Romania +40</option><option value="176">Russian Federation +7</option><option value="177">Rwanda +250</option><option value="178">Saint Kitts and Nevis +1869</option><option value="179">Saint Lucia +1758</option><option value="180">Saint Vincent and the Grenadines +1784</option><option value="181">Samoa +685</option><option value="182">San Marino +378</option><option value="183">Sao Tome and Principe +239</option><option value="184">Saudi Arabia +966</option><option value="185">Senegal +221</option><option value="240">Serbia +381</option><option value="186">Seychelles +248</option><option value="187">Sierra Leone +232</option><option value="188">Singapore +65</option><option value="189">Slovakia (Slovak Republic) +421</option><option value="190">Slovenia +386</option><option value="191">Solomon Islands +677</option><option value="192">Somalia +252</option><option value="193">South Africa +27</option><option value="194">South Georgia and the South Sandwich Islands +</option><option value="195">Spain +34</option><option value="196">Sri Lanka +94</option><option value="197">St. Helena +290</option><option value="198">St. Pierre and Miquelon +508</option><option value="199">Sudan +249</option><option value="200">Suriname +597</option><option value="201">Svalbard and Jan Mayen Islands +79</option><option value="202">Swaziland +268</option><option value="203">Sweden +46</option><option value="204">Switzerland +41</option><option value="205">Syrian Arab Republic +963</option><option value="206">Taiwan +886</option><option value="207">Tajikistan +992</option><option value="208">Tanzania, United Republic of +255</option><option value="209">Thailand +66</option><option value="210">Togo +228</option><option value="211">Tokelau +690</option><option value="212">Tonga +676</option><option value="213">Trinidad and Tobago +1868</option><option value="214">Tunisia +216</option><option value="215">Turkey +90</option><option value="216">Turkmenistan +993</option><option value="217">Turks and Caicos Islands +1649</option><option value="218">Tuvalu +688</option><option value="219">Uganda +256</option><option value="220">Ukraine +380</option><option value="221">United Arab Emirates +971</option><option value="222">United Kingdom +44</option><option value="223">United States +1</option><option value="224">United States Minor Outlying Islands +1</option><option value="225">Uruguay +598</option><option value="226">Uzbekistan +998</option><option value="227">Vanuatu +678</option><option value="228">Vatican City State (Holy See) +39</option><option value="229">Venezuela +58</option><option value="230">Vietnam +84</option><option value="231">Virgin Islands (British) +284</option><option value="232">Virgin Islands (U.S.) +1340</option><option value="233">Wallis and Futuna Islands +681</option><option value="234">Western Sahara +212</option><option value="235">Yemen +967</option><option value="237">Zaire +243</option><option value="238">Zambia +260</option><option value="239">Zimbabwe +263</option></select> *</td> </tr> <tr style="height:60px;" valign="top"> <td style="width:120px;">Contact Number: </td> <td style="width:220px;"><input type="text" name="edit_profile_contact_number" autocomplete="off" id="contact_number"> *</td> </tr> <tr style="height:45px;" valign="top"> <td style="width:120px;">Gender:</td> <td style="width:220px;"> <select name="edit_profile_gender" id="edit_profile_gender"><option>Female</option><option>Male</option> </select> </td> <td style="width:380px;"> </td> </tr> <tr style="height:45px;" valign="top"> <td style="width:120px;">Date of Birth:</td> <td style="width:220px;"><select name="dob_month" id="month"><option value="01">January</option><option value="02">February</option><option value="03">March</option><option value="04">April</option><option value="05">May</option><option value="06">June</option><option value="07" selected="">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="dob_day" id="day"><option value="01">01</option><option value="02">02</option><option value="03">03</option><option value="04">04</option><option value="05">05</option><option value="06">06</option><option value="07">07</option><option value="08">08</option><option value="09">09</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" selected="">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="dob_year" id="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" selected="">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></select></td> <td style="width:380px;"><div id="dob_message"></div> </td> </tr> <tr style="height:45px;" valign="top"> </tr> <tr><td colspan="3"><a name="ba"></a><div class="breakLine"></div></td></tr> <tr> <td colspan="3" style="font-weight:bold">ADDRESS</td></tr> <tr><td colspan="3"><div class="breakLine"></div></td></tr> <tr style="height:45px;" valign="top"> <td style="width:120px;">Address1: </td> <td style="width:220px;"> <input type="text" name="edit_profile_billing_address1" id="billing_address1"> *</td> </tr> <tr style="height:45px;" valign="top"> <td style="width:120px;">Address2: </td> <td style="width:220px;"> <input type="text" name="edit_profile_billing_address2" id="billing_address2"> *</td> </tr> <tr style="height:45px;" valign="top"> <td style="width:120px;">City:</td> <td style="width:220px;"> <input type="text" name="edit_profile_billing_city" id="billing_city"> *</td> </tr> <tr style="height:45px;" valign="top"> <td style="width:120px;">Zip/Post Code:</td> <td style="width:220px;"> <input type="text" name="edit_profile_billing_postcode" id="billing_postcode"> *</td> </tr> <tr style="height:45px;" valign="top"> <td style="width:120px;">Country:</td> <td style="width:220px;"> <select name="edit_profile_billing_country" style="width:150px;" id="billing_country"><option value="1">Afghanistan</option><option value="2">Albania</option><option value="3">Algeria</option><option value="4">American Samoa</option><option value="5">Andorra</option><option value="6">Angola</option><option value="7">Anguilla</option><option value="8">Antarctica</option><option value="9">Antigua and Barbuda</option><option value="10">Argentina</option><option value="11">Armenia</option><option value="12">Aruba</option><option value="13">Australia</option><option value="14">Austria</option><option value="15">Azerbaijan</option><option value="16">Bahamas</option><option value="17">Bahrain</option><option value="18">Bangladesh</option><option value="19">Barbados</option><option value="20">Belarus</option><option value="21">Belgium</option><option value="22">Belize</option><option value="23">Benin</option><option value="24">Bermuda</option><option value="25">Bhutan</option><option value="26">Bolivia</option><option value="27">Bosnia and Herzegovina</option><option value="28">Botswana</option><option value="29">Bouvet Island</option><option value="30">Brazil</option><option value="31">British Indian Ocean Territory</option><option value="32">Brunei Darussalam</option><option value="33">Bulgaria</option><option value="34">Burkina Faso</option><option value="35">Burundi</option><option value="36">Cambodia</option><option value="37">Cameroon</option><option value="38">Canada</option><option value="39">Cape Verde</option><option value="40">Cayman Islands</option><option value="41">Central African Republic</option><option value="42">Chad</option><option value="43">Chile</option><option value="44">China</option><option value="45">Christmas Island</option><option value="46">Cocos (Keeling) Islands</option><option value="47">Colombia</option><option value="48">Comoros</option><option value="49">Congo</option><option value="50">Cook Islands</option><option value="51">Costa Rica</option><option value="52">Cote D'Ivoire</option><option value="53">Croatia</option><option value="54">Cuba</option><option value="55">Cyprus</option><option value="56">Czech Republic</option><option value="57" selected="">Denmark</option><option value="58">Djibouti</option><option value="59">Dominica</option><option value="60">Dominican Republic</option><option value="61">East Timor</option><option value="62">Ecuador</option><option value="63">Egypt</option><option value="64">El Salvador</option><option value="65">Equatorial Guinea</option><option value="66">Eritrea</option><option value="67">Estonia</option><option value="68">Ethiopia</option><option value="69">Falkland Islands (Malvinas)</option><option value="70">Faroe Islands</option><option value="71">Fiji</option><option value="72">Finland</option><option value="73">France</option><option value="74">France, Metropolitan</option><option value="75">French Guiana</option><option value="76">French Polynesia</option><option value="77">French Southern Territories</option><option value="78">Gabon</option><option value="79">Gambia</option><option value="80">Georgia</option><option value="81">Germany</option><option value="82">Ghana</option><option value="83">Gibraltar</option><option value="84">Greece</option><option value="85">Greenland</option><option value="86">Grenada</option><option value="87">Guadeloupe</option><option value="88">Guam</option><option value="89">Guatemala</option><option value="242">Guernsey</option><option value="90">Guinea</option><option value="91">Guinea-bissau</option><option value="92">Guyana</option><option value="93">Haiti</option><option value="94">Heard and Mc Donald Islands</option><option value="95">Honduras</option><option value="96">Hong Kong</option><option value="97">Hungary</option><option value="98">Iceland</option><option value="99">India</option><option value="100">Indonesia</option><option value="101">Iran (Islamic Republic of)</option><option value="102">Iraq</option><option value="103">Ireland</option><option value="104">Israel</option><option value="105">Italy</option><option value="106">Jamaica</option><option value="107">Japan</option><option value="108">Jordan</option><option value="109">Kazakhstan</option><option value="110">Kenya</option><option value="111">Kiribati</option><option value="112">Korea, Democratic People's Republic of</option><option value="113">Korea, Republic of</option><option value="114">Kuwait</option><option value="115">Kyrgyzstan</option><option value="116">Lao People's Democratic Republic</option><option value="117">Latvia</option><option value="118">Lebanon</option><option value="119">Lesotho</option><option value="120">Liberia</option><option value="121">Libyan Arab Jamahiriya</option><option value="122">Liechtenstein</option><option value="123">Lithuania</option><option value="124">Luxembourg</option><option value="125">Macau</option><option value="126">Macedonia, The Former Yugoslav Republic of</option><option value="127">Madagascar</option><option value="128">Malawi</option><option value="129">Malaysia</option><option value="130">Maldives</option><option value="131">Mali</option><option value="132">Malta</option><option value="133">Marshall Islands</option><option value="134">Martinique</option><option value="135">Mauritania</option><option value="136">Mauritius</option><option value="137">Mayotte</option><option value="138">Mexico</option><option value="139">Micronesia, Federated States of</option><option value="140">Moldova, Republic of</option><option value="141">Monaco</option><option value="142">Mongolia</option><option value="241">Montenegro</option><option value="143">Montserrat</option><option value="144">Morocco</option><option value="145">Mozambique</option><option value="146">Myanmar</option><option value="147">Namibia</option><option value="148">Nauru</option><option value="149">Nepal</option><option value="150">Netherlands</option><option value="151">Netherlands Antilles</option><option value="152">New Caledonia</option><option value="153">New Zealand</option><option value="154">Nicaragua</option><option value="155">Niger</option><option value="156">Nigeria</option><option value="157">Niue</option><option value="158">Norfolk Island</option><option value="159">Northern Mariana Islands</option><option value="160">Norway</option><option value="161">Oman</option><option value="162">Pakistan</option><option value="163">Palau</option><option value="164">Panama</option><option value="165">Papua New Guinea</option><option value="166">Paraguay</option><option value="167">Peru</option><option value="168">Philippines</option><option value="169">Pitcairn</option><option value="170">Poland</option><option value="171">Portugal</option><option value="172">Puerto Rico</option><option value="173">Qatar</option><option value="174">Reunion</option><option value="175">Romania</option><option value="176">Russian Federation</option><option value="177">Rwanda</option><option value="178">Saint Kitts and Nevis</option><option value="179">Saint Lucia</option><option value="180">Saint Vincent and the Grenadines</option><option value="181">Samoa</option><option value="182">San Marino</option><option value="183">Sao Tome and Principe</option><option value="184">Saudi Arabia</option><option value="185">Senegal</option><option value="240">Serbia</option><option value="186">Seychelles</option><option value="187">Sierra Leone</option><option value="188">Singapore</option><option value="189">Slovakia (Slovak Republic)</option><option value="190">Slovenia</option><option value="191">Solomon Islands</option><option value="192">Somalia</option><option value="193">South Africa</option><option value="194">South Georgia and the South Sandwich Islands</option><option value="195">Spain</option><option value="196">Sri Lanka</option><option value="197">St. Helena</option><option value="198">St. Pierre and Miquelon</option><option value="199">Sudan</option><option value="200">Suriname</option><option value="201">Svalbard and Jan Mayen Islands</option><option value="202">Swaziland</option><option value="203">Sweden</option><option value="204">Switzerland</option><option value="205">Syrian Arab Republic</option><option value="206">Taiwan</option><option value="207">Tajikistan</option><option value="208">Tanzania, United Republic of</option><option value="209">Thailand</option><option value="210">Togo</option><option value="211">Tokelau</option><option value="212">Tonga</option><option value="213">Trinidad and Tobago</option><option value="214">Tunisia</option><option value="215">Turkey</option><option value="216">Turkmenistan</option><option value="217">Turks and Caicos Islands</option><option value="218">Tuvalu</option><option value="219">Uganda</option><option value="220">Ukraine</option><option value="221">United Arab Emirates</option><option value="222">United Kingdom</option><option value="223">United States</option><option value="224">United States Minor Outlying Islands</option><option value="225">Uruguay</option><option value="226">Uzbekistan</option><option value="227">Vanuatu</option><option value="228">Vatican City State (Holy See)</option><option value="229">Venezuela</option><option value="230">Vietnam</option><option value="231">Virgin Islands (British)</option><option value="232">Virgin Islands (U.S.)</option><option value="233">Wallis and Futuna Islands</option><option value="234">Western Sahara</option><option value="235">Yemen</option><option value="237">Zaire</option><option value="238">Zambia</option><option value="239">Zimbabwe</option></select> </td> <td style="width:380px;"><div id="billing_country_message"></div> </td> </tr> <tr style="height:45px;" valign="top"> <td style="width:120px;">State/Province:</td> <td style="width:220px;"> <span id="state_div" style="float:left;"> <label for="state_province"></label> <input type="text" name="state_province" id="state_province"> *</span></td> </tr> <tr valign="top"> <td colspan="3" style="width:100%;"> <div class="breakLine"><!-- --></div> <div class="dottedLine"><!-- --></div> <div class="breakLine"><!-- --></div> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <tbody> </tbody></table> <div class="breakLine"><!-- --></div> </td> </tr> <tr><td colspan="3"><div class="dottedLine"> </div></td></tr> <!--tr><td colspan="3"><div class="breakLine"></div></td></tr--> <tr> <td colspan="3"> <div style="height:66px; display: block;"> <div style="float:left; width:50px; display: inline-block;"> <div class="loginBoxLink"<a href="#"><a href="index.php"><img src="images/buttoms/button_back.gif" border="0" width="51" height="17" longdesc="index.php" /></a></div> </div> <div style="float:right;"> <INPUT TYPE="image" SRC="images/buttoms/button_update.gif" HEIGHT="17" WIDTH="66" BORDER="0" ALT="Submit Form"> </div> </div> </td> </tr> </tbody></table> </td> </tr> </tbody></table> </form> </div> <div class="break_line"></div> </div> <?php } } } else { // If user is not logged in and opens edit page output that he must be logged in echo "You must be logged in to edit profile"; } ?> </body> </html> update.php Code: [Select] <?php // Start session session_start(); if($_SESSION['s_logged_n'] == 'true'){ // Define $username $username = $_SESSION['s_username']; $new_user_mail = $_POST["e_mail_address"]; $year = $_POST["year"]; $day = $_POST["day"]; $month = $_POST["month"]; $state_province = $_POST["state_province"]; $billing_postcode = $_POST["billing_postcode"]; $billing_country = $_POST["billing_country"]; $billing_city = $_POST["billing_city"]; $billing_address2 = $_POST["billing_address2"]; $billing_address1 = $_POST["billing_address1"]; $edit_profile_gender = $_POST["edit_profile_gender"]; $lastname = $_POST["lastname"]; $contact_number = $_POST["contact_number"]; $country = $_POST["country"]; $firstname = $_POST["firstname"]; // Check if form button update has been pressed if(isset($_POST['update'])){ // Get the id $id = $_GET['id']; // Include config file include "config.php"; // Add slashes and trim password $password = addslashes(trim($password)); $password_confirm = addslashes(trim($password_confirm)); // Check if passwords match each other if ($password == $password_confirm){ // If they do then do md5 hash on it $password = md5($password); // Query users table $query = "UPDATE users SET password = '$password', email = '$new_user_mail', dateofbirth = '$month$day$year', first_name = '$firstname', last_name = '$lastname', country_code = '$billing_postcode', contact_cumber = '$contact_number', gender = '$edit_profile_gender', address_1 = '$billing_address1', address_2 = '$billing_address2', city = '$country', zip_post_code = '$billing_postcode', country = '$country', state_province = '$state_province' WHERE user_id = '$id' AND username = '$username' LIMIT 1"; $result = mysql_query($query); // If it was successfull change of pass then output it if($result){ echo "You have successfully edited your password"; } else { // Else output error echo "There was an error editing your password"; } } else { // If passwords don't match each other say so echo "Your passwords don't match each other"; } } } else { // If someone just try to open file then stop them echo "You must be logged in to access this area"; } ?> mysql database table: users Code: [Select] username email password date ip actkey activated user_id points first_name last_name country_code contact_cumber gender dateofbirth address_1 address_2 city zip_post_code country state_province so if some one please give me a hit or help to get it done thanks Say there is a complex opt in process where people start to enter their data but certain questions stop them where they close out of the page. They already entered their data and I feel there is a way to grab it and post it to mysql even though they do not click submit.
How would this be done?
A super simple example (proof of concept) or a link to a tutorial would be very useful.
Edited by brentman, 23 September 2014 - 10:42 AM. Hello PHP freaks,
my codes dont allow me to log-in to Student Home with unique id. It says "Invalid Login or Password"
this is my form
<tr bgcolor="#E1E1E1" class="stylesmall"> <td width="35%" align="left" class="style7 style1">Learner Id : </td> <td width="65%" align="left"><input name="learner_id" type="text" id="learner_id" action="Student_Home.php" method="post"></td> </tr> <tr bgcolor="#E1E1E1" class="stylesmall"> <td align="left" class="style7 style1">Password:</td> <td align="left"><input name="student_password" type="password" id="student_password">< /td>and this is my handler. <?php session_start(); include 'Connect.php'; $flag = ""; $learner_id = $_POST['learner_id']; $student_id = $_POST['student_id']; $student_password = $_POST['student_password']; $query = "select last_login_date from student_information where student_id='$student_id' and student_password='$student_password'"; $result = mysql_query($query,$link_id); if(mysql_error() != null){ die(mysql_error()); } if($date = mysql_fetch_array($result)) { $lastdate = $date['last_login_date']; $date2 = date("d-m-Y h:i A",strtotime($lastdate)); $_SESSION["student_id"] = $_POST["student_id"]; $_SESSION["lastlogin"] =$date2; $_SESSION["type"] = "Student"; mysql_query("UPDATE student_information SET last_login_date=now() where student_id='$student_id'",$link_id); if(mysql_error() != null){ die(mysql_error()); } header("location: Student_Home.php?id={$student_id}"); die(); } else { $flag = "invalid"; header("location:Student_login.php?flag=$flag"); die(); } ?>PLease help me PHP friends to correct my codes. Hi: Not sure if this is where to ask this (maybe it's a mySQL Issue)?? I am working on a zip code locator. The field/column "zip" (which holds the zip codes) is set as a UNIQUE Key in the database. Problem is: I want to allow people to enter a new city if there is one they want to add. The only way I can do this is to remove the UNIQUE Key from the column, or I get an error. Some cities - like Malvern, PA and Frazer, PA - have the same zip code: 19355 This works fine, but the issue that now happens is the zip locator on the frontend will no longer find that zip code. Does anyone know what a solution might be? I can post the zip locator code, and maybe there's a chunk of code I can remove or alter to fix this? Not sure how to address this one. ok so i have an array which has duplicate values in it. i used array_unique() to remove duplicate values. the array had values 1,2,2,3. after the following code: $unique = array_unique($suggest); $size = count($unique); for ($x=0;$x<=$size;$x++) { echo $unique[$x]; echo "<br>"; } it prints out 1,2 and then gives an error, "Notice: Undefined offset: 2 in E:\wamp\www\Copy of pro2\Classes.php on line 1074" and then finally 3. any ideas how i can solve this. im assuming that array_unique() assigns the index 0,1,3 of the duplicate value array to unique array at the same indexs 0,1,3. since the index 2 of duplicate array is a duplicate value it is ommited but the unique array does not have an array at index 2. Hi i'm making a new website based on PHP. I bumped on a problem now... The problem is that I have a loop where i get all records out of my sql database and get them into a form. Every record has a differend form with a button to. Every button then has a unique ID. Now i tried everyting i could think of to get the value out of a button when a button is clicked. But nothing worked... here is the part of the code where everything is for the form and the POST. Code: [Select] while($record = mysql_fetch_object($result)){ $id = $record->id; echo"<form action='home.php' method='post'>"; echo"<b>name:</b>".$record->name." <b>Price: </b>".$record->price.""; echo'<input type="hidden" name="id" value='.$id.'>'; echo"<input type='submit' value='Buy' /><br />"; echo"</form>"; } if($_POST) { $ID = intval($_POST['id']); $query1 = "SELECT price FROM items WHERE id = ".$ID.""; $result1 = mysql_query($query1); list($cost) = mysql_fetch_row($result1); $gold = getStat('gc',$userID); if($gold > $cost) { setStat('gc',$userID,($gold - $cost)); $queryw = "INSERT INTO users_inventory(item_id,user_id, quantity) VALUES ('".$ID."','".$userID."','1')"; $resultw = mysql_query($queryw); } else { echo"You can't afford this weapons."; } } The only thing that doesn't seem to work is this part Code: [Select] $ID = intval($_POST['id']); is always gives me this error: Notice: Undefined index: id in shop.php on line 26 Please help me out here i have no idea what to do from here on... what is the easiest way to get unqiue sub arrays based on date from within my larger array? here is what i mean in detail. I have an array that outputs this... Code: [Select] [0] => Array ( [date] => 2010-11-02 [time] => 7:00 p.m. [location] => Illinois [team1] => [team1sc] => [team2] => [team2sc] => [winner] => Illinois ) [1] => Array ( [date] => 2010-11-02 [time] => 7:15 p.m. [location] => Purdue [team1] => University of Indianapolis [team1sc] => 59 [team2] => Purdue [team2sc] => 82 [winner] => Purdue ) [2] => Array ( [date] => 2010-11-06 [time] => 3:05 p.m. [location] => Southern Illinois [team1] => University of Indianapolis [team1sc] => 58 [team2] => Southern Illinois [team2sc] => 65 [winner] => Southern Illinois ) I don't need value [ 1 ] because value [ 0 ] already has the same date! My goal is to get a list of all the unique [date]s from this entire multidemonsional array. (FYI - I know I will be loosing blocks of arrays that have duplicate dates - THATS OK). But it's a bit of a struggle for me unique array sections out of this...any help or advice would be great! thanks! Whats the easiest way to rename uploaded files to a unique name that would never be duplicated? Hi, I just need someone to check that a couple of lines I've written do what I believe them to do... i.e. check my logic! I'm developing a booking form for booking on events. Each booking needs a unique reference, which needs to be meaningless to the customer, so I am BASE36 encloding it. As the booking is be saved to a MySql database, my approach is to use the auto-incremented ID for the record to make the reference unique. The increment starts at 10000, and I add a random number before coding to make the encoded reference longer. I then BASE36 encode it to make it appear random. Am I right in thinking the reference produced WILL be unique ... provided the auto-inc ID is unique? $ref = rand(100,999) . $auto_incremented_id; //e.g. 354 & 10012 = 35410001 $ref_encoded = strtoupper(base_convert($rand, 10, 36)); // e.g.UD4J8P Thanks I have a foreach parsing as foreach ($posttags as $tag) { $test = $tag->name; $pattern = "/something/"; if(preg_match($pattern, $test)) { $test2 = "$test is $test"; echo $test2; } } I selected those containing a given word, but I do not know how to remove duplicates to have uniqueness. I was unable to use array_unique, as I am within a foreach loop. hi, im trying to create a website and only now started thinking about the security part(noob mistake). say for example i have home.php page and an index.php page. index.php is where users would sign up/log in. the login and sign up processes are all done but i was thinking of creating a unique id of some sort for when the user logs in. or something like this site (forum.phpfreaks) when we sign in, you are signed but the url stays the same = forums.phpfreaks.com. like if we were signed out we will be permanantly signed out and typing in forums.phpfreaks.com would just land us at the main page where we need to sign in.
right now ,my home.php can be accessed with or without logging in even with sessions.
hope im making sense, thanks in advanced!
**haha that rhymed.
i tried adding:
<?php echo $_SERVER[PHP_SELF] . '?name=' . $userData['name'];?> in the index.php:
<?php ob_start(); session_start(); if(isset($_POST['login'])) { $email = $_POST['email']; $password = $_POST['pass']; require "connection.php"; $emails = mysqli_real_escape_string($con, $email); $query = "SELECT id, name, email, password, salt FROM users WHERE email = '$emails';"; $result = mysqli_query($con, $query); if(mysqli_num_rows($result) == 0) // User not found. So, redirect to login_form again. { echo "<script>alert(\"User does not exist!\")</script>"; } $userData = mysqli_fetch_array($result, MYSQLI_ASSOC); $hash = hash('sha256', $userData['salt'] . hash('sha256', $password) ); if($hash != $userData['password']) { echo "<script>alert(\"Incorrect Password!\")</script>"; }else{ session_regenerate_id(); $_SESSION['sess_user_id'] = $userData['id']; $_SESSION['sess_name'] = $userData['name']; session_write_close(); header('Location: home.php?user='); } } ob_flush(); ?> <!DOCTYPE html> <form name="login" method="post" action="<?php echo $_SERVER[PHP_SELF] . '?name=' . $userData['name'];?>">but i got access forbidden! Edited by noobdood, 19 May 2014 - 10:05 PM. Hey guys. I need to know how to get a time that is constant. What I want to achieve: I need to make a clock on my website showing only one time (HH:MM:SS), wherever the page is requested from. And I need to use this "time" in calculations, like finding the time difference between two time values stored in my MYSQL Databases. I hope that I am clear with my question. Thanks for any help in advance! Howdy, The following code wil geenrate a dynamic pull-down list based on column values. Can someone help me tweak it so that is will NOT display a duplicate record value. That is, if the sponsors values in the table were Hart, Michaels, Michaels, Morella ...it would only display Hart, Michaels, Morella in the pull-down menu. <form name="form0"> <? $result = @mysql_query("select distinct sponsor from table ORDER BY sponsor ASC"); if (mysql_num_rows($result) > 0) { print "<select name=\"link\">"; ?> <option <?php if(empty($_GET['sponsor'])){ echo "selected=\"selected\""; } ?> value="<? echo "$page_name" ?>">SELECT A SPONSOR</option> <? while ($row = mysql_fetch_array($result)) { print "<option "; if($_GET['sponsor'] == $row['sponsor'] ){ echo "selected=\"selected\""; } print " value=\"index?sponsor=" . $row['sponsor'] . "\">" . $row['sponsor'] . "</option>\n"; } print "</select>"; } ?> </form> Thank you. ~Wayne Need a bit of help with some php and a few kind members helped me in the past. My code is: $query = "SELECT names FROM table WHERE type='$type'"; $result = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_array($result)) { foreach(unserialize($row['names']) as $key => $value){ echo $value . '<br />'; } } Basically, a field on my table is called names. The information in this field is serialized (so many names are together in a single field, for a single row). I want to be able to search the whole table (where type='$type' - so many rows) for all names and then show unique names only. My code above unserializes the names from each field and then lists them, but doesn't deal with any duplicates (which I need removing). I have looked at functions like "unique_array()", and have tried using it in different places but it isn't doing the job. Any help appreciated. i have table in my db that has rows of dates, for example... id | date | created | display | group | 1 | 2011-05-24 00:00:00 | 2011-05-24 20:00:00 | Y | 20 | 2 | 2011-05-24 00:00:00 | 2011-05-24 22:00:00 | N | 20 | 3 | 2011-05-26 00:00:00 | 2011-05-26 22:00:00 | N | 20 | 4 | 2011-05-27 00:00:00 | 2011-05-26 22:00:00 | N | 20 | 5 | 2011-05-27 00:00:00 | 2011-05-30 22:00:00 | N | 20 | Now i'm trying to make sure that each group has no duplicate dates. If they do delete all but the newest. So in this case, after the code ran, it would have deleted row 2 and row 5 because they both have duplicate dates and they're the oldest of those particular duplicates. I posted in the PHP board and not the MySQL board because it's the logic i can't figure out. I believe array_unique() would come in handy but i can't wrap my head around how to use it to do what i want. Hey everyone. I have been working on a cart for my site and I've reached an impasse. I coded up the cart, the add to cart, the delete from cart and the subtract from cart. Problem is I now see a need to put an image for everything that is added to the cart. I think i have devised a way to do it with frames, the left frame being the cart and the main frame is purely for the images. I am having trouble getting the code right between the two pages to work. I need a picture on the right of every item added to the cart. Here is the url for the cart: http://www.theblack44s.com/Merchant%20pages/index3.php I know this kind of thing can get extensive and I don't mean to take up any more of your time than necessary so if there are any suggestions or ideas of where I can find this information to learn it that would be just as good. Hey thanks for your time! A |