[dx] Posted October 10, 2009 Author Share Posted October 10, 2009 Link to comment Share on other sites More sharing options...
[dx] Posted October 11, 2009 Author Share Posted October 11, 2009 Anyone?Just remembering you on this topic Link to comment Share on other sites More sharing options...
justsomeguy Posted October 11, 2009 Share Posted October 11, 2009 That's just the profiler, is there any output from the script? Link to comment Share on other sites More sharing options...
[dx] Posted October 11, 2009 Author Share Posted October 11, 2009 No, nothing at all. If you want I can send you my IP via PM and you can test it. Link to comment Share on other sites More sharing options...
justsomeguy Posted October 11, 2009 Share Posted October 11, 2009 Did you add the code in post 25, and you're not seeing any of those messages show up in the console? Link to comment Share on other sites More sharing options...
[dx] Posted October 11, 2009 Author Share Posted October 11, 2009 Yes, I've added, and just see this thing on picture. Link to comment Share on other sites More sharing options...
dsonesuk Posted October 12, 2009 Share Posted October 12, 2009 Are you saying you don't get any warning output, even for missing required input fields?I've just tested your coding, with the sql to database stripped out, and i am getting the output, sent to the <div id="registracijastatus"></div>.i added "added to database" message in 'else' part to show a successful update/added message, which also worked. Link to comment Share on other sites More sharing options...
[dx] Posted October 12, 2009 Author Share Posted October 12, 2009 Did you edited something or what? Let me compare if you made some editions...I don't get any warning at all. Like page is dead... Link to comment Share on other sites More sharing options...
dsonesuk Posted October 12, 2009 Share Posted October 12, 2009 Ok! here's my coding stripped downajax.js:// JavaScript Documentfunction kreirajRO() { var katalog; if (window.XMLHttpRequest) { rez = new XMLHttpRequest(); } else if (window.ActiveXObject) { rez = new ActiveXObject("Microsoft.XMLHTTP"); } else { alert("Greska u kreiranju stranice! Pokusajte sa drugim browserom."); } return rez;}var katalog = kreirajRO();function ajax_katalog(sta) { if (katalog.readyState == 4) { var rez = katalog.responseText; if (rez) { document.getElementById(sta).innerHTML = rez; } }}function regU() { ime=document.getElementById("ime"); prezime=document.getElementById("prezime"); email=document.getElementById("email"); sifra=document.getElementById("sifra"); d_rodj=document.getElementById("d_rodj"); m_rodj=document.getElementById("m_rodj"); g_rodj=document.getElementById("g_rodj"); spol=document.getElementById("spol"); katalog.open('get', 'registracija_src.php?ime='+ime.value+'&prezime='+prezime.value+'&email='+email.value+'&sifra='+sifra.value+'&d_rodj='+d_rodj.value+'&m_rodj='+m_rodj.value+'&g_rodj='+g_rodj.value+'&spol='+spol.value, true); katalog.onreadystatechange = function () { if (katalog.readyState == 4) { var rez = katalog.responseText; if (rez == "1") { document.getElementById("registracijastatus").innerHTML = "Unesite vase ime"; } else if (rez == "2") { document.getElementById("registracijastatus").innerHTML = "Unesite vase prezime"; } else if (rez == "3") { document.getElementById("registracijastatus").innerHTML = "Unesite vas email"; } else if (rez == "4") { document.getElementById("registracijastatus").innerHTML = "Unesite vasu sifru"; } else if (rez == "5") { document.getElementById("registracijastatus").innerHTML = "Izaberite datum rodjenja"; } else if (rez == "6") { document.getElementById("registracijastatus").innerHTML = "Izaberite spol"; } else if (rez == "7") { document.getElementById("registracijastatus").innerHTML = "Sifra mora sadrzavati najmanje 5 znakova"; } else if (rez == "8") { document.getElementById("registracijastatus").innerHTML = "Ovaj email je vec registrovan"; } else if (rez == "9") { document.getElementById("registracijastatus").innerHTML = "Nepravilan format email adrese"; } else { document.getElementById("registracijastatus").innerHTML = rez; } } } katalog.send(null);}registracija.php:<?php//require_once("baza.php");echo '<script type="text/javascript" src="ajax.js"></script>';echo '<div id="registracijastatus"></div><form name="registracija" method="post" action=""> Ime: <input id="ime" onfocus="this.value=\'\'" value="Unesi ime" /><br /> Prezime: <input id="prezime" onfocus="this.value=\'\'" value="Unesi prezime" /><br /> Email: <input id="email" onfocus="this.value=\'\'" value="Unesi email" /><br /> Sifra: <input id="sifra" onfocus="this.value=\'\'" type="password" value="" /><br /> Datum rodjenja: <select id="d_rodj">'; $d = 1; while ($d <= 31) { echo '<option value="'.$d.'">'.$d.'</option>'; $d++; } echo '</select> <select id="m_rodj">'; $m = 1; while ($m <= 12) { echo '<option value="'.$m.'">'.$m.'</option>'; $m++; } echo '</select> <select id="g_rodj">'; $g = date(Y)-13; while ($g >= 1950) { echo '<option value="'.$g.'">'.$g.'</option>'; $g--; } echo '</select><br /> Spol: <select id="spol"><option value="m">Musko</option><option value="z">Zensko</option></select> <input type="button" value="Registruj se" onclick="regU()" /></form>';?>registracija_src.php<?PHP//require_once("baza.php");$ime = $_GET['ime'];$prezime = $_GET['prezime'];$email = $_GET['email'];$sifra = $_GET['sifra'];$d_rodj = $_GET['d_rodj'];$m_rodj = $_GET['m_rodj'];$g_rodj = $_GET['g_rodj'];$datum_rodjenja = "$d_rodj-$m_rodj-$g_rodj";$datum_rodjenja = strtotime($datum_rodjenja);$spol = $_GET['spol'];//$rez_email = mysql_query("SELECT email FROM korisnici WHERE email=$email");$email="fred@qwerty.com"; //this is what i added to validateif (empty($ime)) { echo "1"; }elseif (empty($prezime)) { echo "2"; }elseif (empty($email)) { echo "3"; }elseif (empty($sifra)) { echo "4"; }elseif (empty($datum_rodjenja)) { echo "5"; }elseif (empty($spol)) { echo "6"; }elseif (strlen($sifra) <= 4) { echo "7"; }//elseif (mysql_num_rows($rez_email) > 0) { echo "8"; }elseif (!preg_match('/^[^\x00-\x20()<>@,;:\\".[\]\x7f-\xff]+(?:\.[^\x00-\x20()<>@,;:\\".[\]\x7f-\xff]+)*\@[^\x00-\x20()<>@,;:\\".[\]\x7f-\xff]+(?:\.[^\x00-\x20()<>@,;:\\".[\]\x7f-\xff]+)+$/i', $email)) { echo "9"; }else {echo("added to database"); // added to produce successful message // Rest of code (mysql query) here}?> Link to comment Share on other sites More sharing options...
[dx] Posted October 12, 2009 Author Share Posted October 12, 2009 I don't see anything different :S Link to comment Share on other sites More sharing options...
dsonesuk Posted October 12, 2009 Share Posted October 12, 2009 copy my coding to same pages, in a different directory, and run it, to see if it works. Link to comment Share on other sites More sharing options...
[dx] Posted October 12, 2009 Author Share Posted October 12, 2009 Yeah, now works, but just this lineelse { document.getElementById("registracijastatus").innerHTML = rez; }and not others with if statement if (rez == "1") ...So, I should get some text error in <div id="registracijastatus"></div>, and I get just numberAnd I still don't see what's difference between these codes Link to comment Share on other sites More sharing options...
dsonesuk Posted October 12, 2009 Share Posted October 12, 2009 if you used my code exactly, run the form page (with password empty) submit it, a message 'Unesite vasu sifru' will appear within a second or so.running the form again, with password set, and using preset email address of $email="fred@qwerty.com"; (in 'registracija_src.php') it will pass the validation, and it will then show 'added to database' on top of form. Link to comment Share on other sites More sharing options...
[dx] Posted October 12, 2009 Author Share Posted October 12, 2009 With "sifra" empty Link to comment Share on other sites More sharing options...
dsonesuk Posted October 12, 2009 Share Posted October 12, 2009 its sending the values to 'registracija_src.php', its then processing the sent values, and sending appropriate rez ref response value, but it then fails in ajax.js to assign any message to the rez ref value? just the actual rez ref value itself (Well on your system anyway).try rez == "4" without quotes, rez == 4, and see what happens. Link to comment Share on other sites More sharing options...
[dx] Posted October 12, 2009 Author Share Posted October 12, 2009 Thanks God!Now works, and old script still won't work.Edit: Now it shows me "Greska!" when press button (with your code), and there's no Greska! anywhere in code :S Link to comment Share on other sites More sharing options...
dsonesuk Posted October 12, 2009 Share Posted October 12, 2009 well that is strange? only place i can see anything close to it is 'alert("Greska u kreiranju stranice! Pokusajte sa drugim browserom.")'is it picking up this message "Greska!" from some other script or page, which is causing a conflict in someway? Link to comment Share on other sites More sharing options...
[dx] Posted October 12, 2009 Author Share Posted October 12, 2009 :SWell, code calls value, or message. Everything is correct with it. I have some other folders in /www folder, but I don't think there's something which calls error Greska!And when I view source of page, there's no "Greska!" in <div> <script type="text/javascript" src="ajax.js"></script><div id="registracijastatus"></div><form name="registracija" method="post" action="">Ime: <input id="ime" onfocus="this.value=''" value="Unesi ime" /><br />Prezime: <input id="prezime" onfocus="this.value=''" value="Unesi prezime" /><br />Email: <input id="email" onfocus="this.value=''" value="Unesi email" /><br />Sifra: <input id="sifra" onfocus="this.value=''" type="password" value="" /><br />Datum rodjenja:<select id="d_rodj"><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="m_rodj"><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></select><select id="g_rodj"><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></select><br />Spol: <select id="spol"><option value="m">Musko</option><option value="z">Zensko</option></select><input type="button" value="Registruj se" onclick="regU()" /></form> Link to comment Share on other sites More sharing options...
dsonesuk Posted October 12, 2009 Share Posted October 12, 2009 in Firefox use "select all" within the page, right click anywhere within highlighted text then select "view selection source" this will show content produced by javascript. Link to comment Share on other sites More sharing options...
[dx] Posted October 12, 2009 Author Share Posted October 12, 2009 <html><head><script type="text/javascript" src="ajax.js"></script></head><div FirebugVersion="1.4.3" style="display: none;" id="_firebugConsole"></div><body><div id="registracijastatus">Greska!</div><form name="registracija" method="post" action="">Ime: <input id="ime" onfocus="this.value=''" value="Unesi ime"><br> Rest of code is same... Link to comment Share on other sites More sharing options...
dsonesuk Posted October 12, 2009 Share Posted October 12, 2009 is the "greska!" showing when you fill all the fields and validates, i'm wondering, if the javascript message now only works if the 'if' conditions matches the integer value:if (rez == 1)....if (rez == 2)....if (rez == 3)...maybe you should supply a numeric value, to relate to a successful update/insert to database, instead of text value of echo("added to database"); which i supplied?give it a high value of '999' so it will not conflict with any future input fields, you may enter.anyway try this, and see what other problem will turn up. Link to comment Share on other sites More sharing options...
[dx] Posted October 12, 2009 Author Share Posted October 12, 2009 When I fill all fileds, I get "Greska!" again.I don't get it what to do with 999 ? :SI'll search now all folders and JS files for "Greska!"EDIT: Nothing with "Greska!" Link to comment Share on other sites More sharing options...
dsonesuk Posted October 12, 2009 Share Posted October 12, 2009 instead of 'echo("added to database");' replace with echo "999";}else{echo "999";}AND REPLACE 'else { document.getElementById("registracijastatus").innerHTML = rez; }' with belowelse if (rez == 999) { document.getElementById("registracijastatus").innerHTML = "Successful"; } Link to comment Share on other sites More sharing options...
[dx] Posted October 12, 2009 Author Share Posted October 12, 2009 Still nothing, like in mine script. Nothing shown.. Link to comment Share on other sites More sharing options...
dsonesuk Posted October 13, 2009 Share Posted October 13, 2009 OK, for a experiment, move the echo "999"; above the if condition statements, this will become the default value (success), if an error is found that will overwrite the default value meaning a failure.thinking about this again maybe it would be better to collect the error value within a variable, and the echo the value at the end example: (remove the else {..} at end)$processref=999; //default value for successif (empty($ime)) { $processref=1; }elseif (empty($prezime)) { $processref=2; }elseif (empty($email)) { $processref=3; }elseif (empty($sifra)) { $processref=4; }elseif (empty($datum_rodjenja)) { $processref=5; }elseif (empty($spol)) { $processref=6; }elseif (strlen($sifra) <= 4) { $processref=7; }//elseif (mysql_num_rows($rez_email) > 0) { $processref=8; }elseif (!preg_match('/^[^\x00-\x20()<>@,;:\\".[\]\x7f-\xff]+(?:\.[^\x00-\x20()<>@,;:\\".[\]\x7f-\xff]+)*\@[^\x00-\x20()<>@,;:\\".[\]\x7f-\xff]+(?:\.[^\x00-\x20()<>@,;:\\".[\]\x7f-\xff]+)+$/i', $email)) { $processref=9; } echo $processref; Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.