Jump to content

Search the Community

Showing results for tags 'ajax'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

  1. hi im working with instagram API and it uses Curl ... i sorta get it but is there a site where i could learn more or anyone here that knows about curl?
  2. Hello, I am trying to pass PHP variables in a jquery function with the javascript onclick but its not working(i know it sounds confusing but I will explain). I define my $output in first.php then echo it in second.php. Here is my first.php $answer = "some text"; $output .= '<div id="'.$k.'"> <form id='.$f.' > <input type="radio" name="accuracy" value="yes" checked>Accurate <input type="radio" name="accuracy" value="no">Not Accurate <input type="button" id='.$j.' value="Submit" onclick="sendData('.$answer.')"> </form> </div>'; My jquery function in second.php function sendData(feel) { $.get("test.php", { feeling: 'feel'} ); } My test.php : $f= $_GET["feeling"]; $con = mysql_connect('localhost', 'username', 'pass'); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("mydatabase", $con); $sql="INSERT INTO testtable (testcolumn) VALUES ('$f')"; $result = mysql_query($sql); echo '<p2> Thank you. Your opinion is much appreciated!</p2>'; mysql_close($con); An entry is added in the database but with an empty value. Any idea where is the problem? Thanks
  3. I have called some ajax to bring in some html. In their html there is a form with select box's which i have a replacement plugin. However, i have included my plugin and applied it in the main html document and wrapped in in the document ready function but it just won’t apply to new dom elements with the ajax call. Andy ideas?
  4. Hi, Im new to ajax. i have to use partial page rendering(PPR) techique to complete my project. Project Description: im doing a livescore system. what i plan is the client site should get the latest score once it has been uploaded by admin in database. This score update should not refresh the complete page. This is something like facebook upadate peoples comment on a post while we seeing it. the notification numbers in facebook automatically increase whn people comment or like for us even we didnt reload the page. Need help: i need help to create this system. how to auto trigger the PPR in client site to get latest score in Database once it has been inserted. can anyone help me doing this? is there any related tutorial videos to refer? Thanks in advance
  5. Hi there, Basically what i need is for my site to not refresh every time i click one of the buttons. I have got as far as finding out that it requires AJAX but i don’t have a clue how to use it This is some of my code...it basically covers the main parts but if you need more then please ask... <html> <head> <script> $(function() { var tabs = $( "#tabs" ).tabs({collapsible: true, active:"flase"}); tabs.find( ".ui-tabs-nav" ).sortable({axis:"x", stop:function() {tabs.tabs( "refresh" );} }); }); $(function() { $( ".box" ).draggable({containment: "#restrictor", scroll: false, snap: true, opacity: 0.35, cancel: ".box-content" }); $( ".box" ).addClass( "ui-widget ui-widget-content ui-corner-all" ) .find( ".box-header" ) .addClass( "ui-widget-header ui-corner-all" ) .prepend( "<span class='ui-icon ui-icon-minusthick'></span>") .end() .find( ".box-content" ); $( ".box-header .ui-icon" ).click(function() { $( this ).toggleClass( "ui-icon-minusthick" ).toggleClass( "ui-icon-plusthick" ); $( this ).parents( ".box:first" ).find( ".box-content" ).toggle(); }); $( "#container" ).disableSelection(); }); $(function() { $( "input[type=submit], #Buttons, button" ) .button() .click(function( event ) { event.preventDefault(); }); }); setInterval(function() { $('#timeval').load('Home_Automation/Includes/time.php'); }, 1000); </script> </head> <body> <!------------------------Serial Port/Commands/Functions---------------------------> <?php if (isset($_GET['action'])) { require("Home_Automation/Includes/php_serial.class.php"); $serial = new phpSerial(); $serial->deviceSet("COM3"); exec('mode COM3 BAUD=96 PARITY=n DATA=8 STOP=1 xon=off octs=off rts=on'); $serial->deviceOpen(); if ($_GET['action'] == "on") { $serial->sendMessage("L"); $file = fopen("Home_Automation/Includes/lights.txt","w"); fwrite($file, "1"); fclose($file); } else if ($_GET['action'] == "off") { $serial->sendMessage("l"); $file = fopen("Home_Automation/Includes/lights.txt","w"); fwrite($file, "0"); fclose($file); } else if ($_GET['action'] == "unlock") { $serial->sendMessage("D"); $file = fopen("Home_Automation/Includes/doors.txt","w"); fwrite($file, "1"); fclose($file); } $serial->deviceClose(); } ?> <!--------------------------------Main Container-----------------------------------> <div id="restrictor" class="ui-widget-content"> <!--------------------------------Controll Switches--------------------------------> <!-------------------------------------Doors---------------------------------------> <div class="box"> <div class="box-header">Doors</div> <div class="box-content"> <a class="button" href="<?php echo $_SERVER['PHP_SELF'] . '?action=unlock' ?>">Unlock</a> <div id="PHP"> <?php $file = fopen("Home_Automation/Includes/doors.txt", "r") or exit("Unable to open file!"); if (fgetc($file)==1) echo "<img src=\"Home_Automation/Images/Door_Open.gif\" />"; else echo "<img src=\"Home_Automation/Images/Door_Closed.gif\" />"; fclose($file); ?> </div> <a class="button" href="<?php echo $_SERVER['PHP_SELF'] . '?action=lock' ?>">Lock</a> </div></div> </div> </html> It’s not really in order as i cut bits out but that covers the basic code... If someone could please show me some code snippets that i would need to include or something that would be great Thanks, Chris
  6. hi guys please could you help do this i tried to read about jquery , ajax , json but i just got really lost so i am asking for help to guide me to the right way and thank you so much. what i want to do is this : take this from in html <form method="GET" action="https://exemple.com/.../api/work.php"> <input type="hidden" name="method" value="link"/> <input type="text" name="params[login]" value="ready" /> </br><input type="text" name="params[pass]" value="download"/></br> <input type="text" size="80" name="params[link]" placeholder="get ready"/></br> <input type="submit" formtarget="txt" value="Submit"> </form> <iframe type="hidden" name="txt"></iframe> And turn it to this <form> <input type="text" size="80" name="params[link]" placeholder="get ready"/></br> <input type="submit" formtarget="txt" value="Submit"> </form> <iframe type="hidden" name="txt"></iframe> i want to validate - the the first input with name="method" value="link" -the second input with name="params[login]" value="ready" -the third input with name="params[pass]" value="download" to this url https://exemple.com/api/work.php ( this is a different domain "cross domain") with the GET request conclusion i don't want the visitor the see the url or the 3 inputs they can pnly submit the link they want to check thank you so much i hope someone can guide me to the right way i am so lost now
  7. I would like to develop a system that makes remote reading of the result of some search sites. These results are paginated and many sites use ajax to load pages. How can I accomplish this system with php? example of a site search page result: http://busca.submarino.com.br/busca.php?q=celular&sessao=4b712361eee996720660b5d6bde5dfc1f22066c9&idbusca=c9aeb969a4e7fb45bbbf152c85f1234cd768f5e7 As you can see at the bottom of the page, there is some javascript attached to the pagination link. Can anyone help with some idea? Thanks
  8. For some reason i need to submit a form to an external website without changing the page. I'm a newbie with AJAX and i don't know how to do it so i would really appreciate if someone could help me. Here's the form i need to submit: Thanks a lot !
  9. I am trying to send multiple values to ajax variable(value) from multiple dropdown list. However, this is not working. I want multiple values to be stored in ajax variable if I select more than one dropdown value. Any help plz? Below is the ajax code: var xmlHttp1; var xmlHttp1; var str = new Array(); //xmlHttp.setRequestHeader( "Content-Type", "application/json" ); function showState1(str){ if (typeof XMLHttpRequest != "undefined"){ xmlHttp1= new XMLHttpRequest(); } else if (window.ActiveXObject){ xmlHttp1= new ActiveXObject("Microsoft.XMLHTTP"); } if (xmlHttp1==null){ alert("Browser does not support XMLHTTP Request"); return; } var url="test.jsp"; url +="?value=" +str; xmlHttp1 .onreadystatechange = stateChange1; xmlHttp1.open("POST", url, false); xmlHttp1.send(null); } function stateChange1(){ if (xmlHttp1.readyState==4 || xmlHttp1.readyState=="complete"){ document.getElementById("functUnit").innerHTML=xmlHttp1.responseText ; } }
  10. In a regular form, how would I go about to populate a php session variable with the value of the checkbox the user checked, all without reloading the page? I don't need to error check or anything for this, as I do that once the user submits the form. I just want to add a value to an existing session variable as soon as the user check the box. Any help is greatly appreciated.
  11. Hi guys, ive got an awkward problem that doesn't seem to want to fix itself no matter how hard i try. Basically, I have in my Database a table called horses and the columns are I then have a php webpage with a dropdown box which is populated from the database. <form action="" method="post" align="center"> <fieldset> <select name="horses" onchange="benSucksDick(this.value)" align="center"> <option value="">Select a Horse</option><Br><br><br> <!-- RUN QUERY TO POPULATE DROP DOWN --> <?php mysql_connect("localhost", "root", "") or die("Connection Failed"); mysql_select_db("horse")or die("Connection Failed"); $query = "SELECT * FROM horses ORDER by ID"; $result = mysql_query($query) or die(mysql_error()); /*$num = mysql_num_rows($result);*/ while($row = mysql_fetch_array($result)) { echo "<option value='".$row['ID']."'>".$row['Name']."</option>"; } ?> </select></fieldset> I also have a AJAX call to edit.php which fetches the data in column web_horse and outputs it to a CKeditor instance. AJAX code <script type="text/javascript"> function benSucksDick(str) { if (str=="") { document.getElementById("maincontent").innerHTML=""; return; } if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("maincontent").innerHTML=xmlhttp.responseText; } } xmlhttp.open("GET","content/edit.php?q="+str,true); xmlhttp.send(); } </script> edit.php Code <?php error_reporting(-1); // Make sure you are using a correct path here. include 'ckeditor/ckeditor.php'; $ckeditor = new CKEditor(); $ckeditor->basePath = '/ckeditor/'; $ckeditor->config['filebrowserBrowseUrl'] = '/ckfinder/ckfinder.html'; $ckeditor->config['filebrowserImageBrowseUrl'] = '/ckfinder/ckfinder.html?type=Images'; $ckeditor->config['filebrowserFlashBrowseUrl'] = '/ckfinder/ckfinder.html?type=Flash'; $ckeditor->config['filebrowserUploadUrl'] = '/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Files'; $ckeditor->config['filebrowserImageUploadUrl'] = '/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Images'; $ckeditor->config['filebrowserFlashUploadUrl'] = '/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Flash'; mysql_connect("localhost", "root", "") or die("Connection Failed"); mysql_select_db("horse")or die("Connection Failed"); $q=$_GET["q"]; $sql="SELECT web_content FROM horses WHERE id = '".$q."'"; $resultab = mysql_query($sql); while($row = mysql_fetch_array($resultab)) { echo $row['web_content']; } ?> Now, the CKeditor initialises when the page is loaded, but when i change the dropdown to a different value from the database it just shows the html code and/or a text area WITHOUT the CKeditor instance. If anyone can help me, that would be grand!!
  12. Hi Guys, I have a set of script to send data via checkbox toggle. After a checkbox is checked. A value is sent from PHP as 1. So I test the value within success callback. Everythings works fine but I can't make the background color change according to the given value from php. Please have give me a hand. <script type="text/javascript"> jQuery(function($){ $('input[name=alm]').click(function(){ var id=$(this).attr('id'); var alm=$(this).val(); $.ajax({ type:'GET', url:'inc/villas_allotment_ajax_update.php', data:'id='+id+'&alm='+alm, /*success: function (result) {$('#bg').css("background-color", "#66cc00");alert(data);}, error: function (result) {$('#bg').css("background-color", "#ff8080");},*/ success: function(html) { if(html=="1"){//change td bg to green if succeed $('#bg').css("background-color", "#66cc00"); alert(html); }else{ $('#bg').css("background-color", "#ff8080"); alert(html); } } }); }); }); </script> Here's my html: <table> [indent=1]<tr>[/indent] [indent=2]<td id="2012-11-01-001" align="center"><input type="checkbox" id="2012-11-01-001" name="alm" value="1" checked /></td>[/indent] [indent=2]<td id="2012-11-02-001" align="center"><input type="checkbox" id="2012-11-02-001" name="alm" value="1" checked /></td>[/indent] [indent=2]<td id="2012-11-03-001" align="center"><input type="checkbox" id="2012-11-03-001" name="alm" value="1" checked /></td>[/indent] [indent=2]...[/indent] [indent=2]<td id="2012-11-30-001" align="center"><input type="checkbox" id="2012-11-30-001" name="alm" value="1" checked /></td>[/indent] [indent=1]</tr>[/indent] </table> The questions is: How can I change the td background-color after a callback is proved (html=="1") according to its td.id (not #bg as I wrote) Please help me out, I've spent many hours to solve this including some samples from this website.
  13. Greetings everyone, I really hope someone would be able to help me quickly... I'm not very clued up on ajax,jquery or javascript, and would really love some help in converting the attached js file to use a database instead of cookies. Please guys, thanx in advance.
  14. Hi dear friends, I hope u are all fine. I want to make a next button for getting more data from mysql database. For example: $sql = mysql_query("SELECT * FROM table LIMIT 0,7"); It get 7 rows.For next data code is that. $sql = mysql_query("SELECT * FROM table LIMIT 7,7"); I can i do that using ajax. As you can see in many website like facebook,When you click on comment it give a limited comment and when you click on more comment it give more and so on.In this proccess you can see that the other content of page does not change.It means it can use ajax and how can I do that in ajax. Please help me.Thanks.
  15. style3.csstesting.phpmakesend.phpstyle3.cssi really do hope to get a helpful answer. i've been working on a way to make a chatbox that allows private sessions between two users,one where only two users chat with the option of joining the general chatroom, i'm doing this without any xmpp,sockets etc, i'm just using files which would serve as logs, i'll explain the concept: a user has logged in, they are directed to the chat-page, where a list of their friends stored in a database is loaded to their right, this part is working fine: //i've declared all the variables previously //skip to the part that loads the names: while($rowb=mysql_fetch_array($done)) { $rafiki=$rowb['name']; //show the names,when the user clicks on any of them, the name(variable $jina) of the user //and the friend's name are sent to the function makefile() echo "<a href='Javascript:makefile(".$jina.",".$rafiki.")'>"."$rafiki"."</a>"."<br/>"; } when the user clicks on any name, they are sent to the javascript function, which takes both parameters, the user's name and the name of the friend, and then adds an extension at the end, to make a log file that would serve as the chat log between both of them: function makefile(username,friendname) { //add file extension var ext=".html"; //concatenate var dash="-"; var full=username.concat(dash,friendname,dash,ext); var str=friendname.concat(dash,username,dash,ext); so each pair would have their own file, the variable full is sent to a script via ajax to make the process seamless, the script does a number of things: it first checks to see if a log file, that bears the data sent from the client side exists, either beginning with the user's name or the friend's name,if either file exists,it checks to see if any messages have been sent and writes them to the file, if neither file exists, it creates a new file,and prompts a user that a friend wants to start a chat, when the friend clicks on the user's name, the first condition will succeed, because a file would already have been made: <?php session_start(); $full=$_POST['full']; //first, check to see if variations of the file already exist //start by exploding the sent data $result=explode("-",$full); $usrnme=$result[0]; $frndnme=$result[1]; $ext=$result[2]; //make varied names for comparison $vrdfull=array($result[1],$result[0],$result[2]); $str=implode("-",$vrdfull); $_SESSION['str']=$str; $_SESSION['full']=$full; //start actual comparison if(file_exists($full)||file_exists($str)) { //stuff to do if first file exists if(file_exists($full)) { //check to see if message has been sent if (isset($_POST['message'])) { $message=$_POST['message']; //update existing file with message $fp=fopen($full,'a'); fwrite($fp, "<div id=\"sent\">".$usrnme." :"." ".$message."<br/>"."</div>"); //close the file fclose($fp); } } else //stuff to do if second file exists {if(file_exists($str)) { //check to see if message has been sent if (isset($_POST['message'])) { $message=$_POST['message']; //update existing file with message $fpp=fopen($str,'a'); fwrite($fpp, "<div id=\"sent\">".$usrname." :"." ".$message."<br/>"."</div>"); //close the file fclose($fpp); } } } } else { //create file, since neither files exist $fhandel=fopen($full,'a'); //check if message has been sent if(isset($_POST['message'])) { $messssage=$_POST['message']; fwrite($fhandel,"<div id=\"sent\">".$usrname." "." : ".$messssage."<br/>"."</div>"); } fclose($fhandel); //send msg to friend, incurring them to accept $ext=".html"; $frrnme=$frndnme.$ext; $fpp=fopen($frrnme,'a'); //prompt the user to initiate chat by opening file,by clicking on the name he/she would see fwrite($fpp,"<div id=\"msg\">".$frndnme." wants to chat, click on their name to accept"."</div>"); fclose($fpp); } ?> i don't think this part has any problems, just posted it to help convey the idea across.here's the ajax that sends the string full to the script (i think it may be wrong): $.ajax({ type:'POST', url:'makesend.php', data: {full:full}, //what to do if data was sent: success: function(full){ $('#myResponse').html(full);[/font][/color] [color=#000000][font=Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif]} }); return false; no data is shown in the div "myresponse", so i think there's a problem here, i don't know what. the next thing would be to handle messages sent by the users,here's the form that would get their input: <form name="message" action=""> <input name="message" type="text" id="usermsg" size="63" /> <input name="submitmsg" type="submit" onclick="send()" id="submitmsg" value="Send" /> </form> and here's the function send() that sends data to the makesend.php file: function send(){ var clientmsg = $("#usermsg").val(); $.post("makesend.php", {message: clientmsg}); $("#usermsg").attr("value", ""); return false; } again, when i tested this and wrote a message, the page reloaded and no data was sent to the script! there's a problem here as well,i don't know what it is. moving on, after the file has been created and the user's begin interaction, it needs to be uploaded to a message area where the user can see it, here's the message area div: remember that i'll need to load a file that exists, so before loading it to this area, i'll need to use php to see which version exists, either one with the user's name first or with the friend's name (either $full or $str): $("#msgarea").html( "<?php //check to see if either file exists if(file_exists($_SESSION['full'])||file_exists($_SESSION['str'])){ //check to see if the first file exists: if(file_exists($_SESSION['full'])) { $full=$_SESSION['full']; $handlle = fopen($full, "r"); $contents = fread($handlle, filesize($full)); fclose($handlle); //load it's contents to the division if it does echo $contents;} else { //if first file doesn't exist, load the second one: $str=$_SESSION['str']; //check to see if it exists before loading it if(file_exists($str)) { $handle = fopen($str, 'r'); $contents = fread($handle, filesize($str)); fclose($handle); //load it to the division echo $contents; } } } ?>" ); i think it's legal to do that, add php code to the innerHTML of an element, so this code would load whatever version of the file that exists. i get the file names from the session because this part of the code gets executed after data is sent to the makesend.php file, which starts a session and gives them ($_SESSION['full'] and $_SESSION['str']) values. this part that loads the file is the last piece of code within the function makefile(), first, the function obtains data from the user in form of the name they clicked, it sends them to a script (makesend.php) which creates the chat log file, after this, comes the last part, which loads the data onto the division "msgarea". next, i'd need to refresh/reload the created log file after a certain amount of time to show the messages sent by the users, i chose to use 2.5 seconds, this part is outside the function makefile(),i had to use php within the jquery to first check which file exists, i'd then use jquery in the php to reload and animate(auto-scroll) the existing one,this php is inside the 'javascript' tags: <?php //set up the conditions[/font][/color] $full=$_SESSION['full']; $str=$_SESSION['str']; //check whether either file exists if(file_exists($full)||file_exists($str)) { //reload the first file if it exists if(file_exists($full)){ //this is the jquery inside the php(which is also in javascript tags) echo '<script type="text/javascript" src="jquery-1.8.0.min (1).js"></script>'; echo '<script type="text/javascript">'; echo 'function loadLog(){ var oldscrollHeight = $("#msgarea").attr("scrollHeight") - 20; $.ajax({ url: <?php session_start(); echo $_SESSION[\'full\']?>, cache: false, success: function(html){ $("#msgarea").html(html); //Insert chat log into the #msgarea div var newscrollHeight = $("#msgarea").attr("scrollHeight") - 20; if(newscrollHeight > oldscrollHeight){ $("#msgarea").animate({ scrollTop: newscrollHeight }, \'normal\'); //Autoscroll to bottom of div } }, }); } setInterval (loadLog, 2500); //Reload file every 2.5 seconds'; } else{ //this will reload the second file since the first doesn't exist: echo 'function lloadLog(){ var oldscrollHeight = $("#msgarea").attr("scrollHeight") - 20; $.ajax({ url: <?php session_start(); echo $_SESSION[\'str\']?>, cache: false, success: function(html){ $("#msgarea").html(html); //Insert chat log into the #msgarea div var newscrollHeight = $("#msgarea").attr("scrollHeight") - 20; if(newscrollHeight > oldscrollHeight){ $("#msgarea").animate({ scrollTop: newscrollHeight }, \'normal\'); //Autoscroll to bottom of div } }, }); } setInterval (lloadLog, 2500); //Reload file every 2.5 secsonds'; } echo '</script>'; } ?> and i think that's it, the entire system, also, there's a problem with the logout call, here's the code, it's at the very end of the file: $("#exit").click(function(){ var exit = confirm("Are you sure you want to end the session?"); if(exit==true){window.location = 'testing.php?logout=true';} }); here's the markup for it: <p class="logout"><a id="exit" href="#">Exit Chat</a></p> and at the top of the file, here's the part that checks whether it's set to true: session_start(); //logout function if(isset($_GET['logout'])) { if(file_exists($_SESSION['full'])||file_exists($_SESSION['str'])) { if(file_exists($_SESSION['full'])) { $full=$_SESSION['full']; $flogout=fopen($full,'a'); fwrite($flogout, $_SESSION['username']." has left the anichat!!! "."<br>"); fclose($flogout); } else { $str=$_SESSION['str']; if(file_exists($str)) { $flogoout=fopen($str,'a'); fwrite($flogoout, $_SESSION['username']." has left the chat "."<br>"); fclose($flogoout); } } } session_destroy(); header("Location:testing.php");//user redircect. } the user's page is not even refreshed so that the session is destroyed, it just refreshes and the session data is still present(this is because the login form isn't shown, it's supposed to be shown if the $_SESSION['name'] is empty). i know that this is a long question, but i am a beginner and i really need help with this, i think the main issues are with the ajax, but if you can spot anything else i will be very thankful, i kindly ask for a relevant answer that will help me implement this, if you would like me to post the entire code present in both testing.php and makesend.php,in a way that is not separated like the way i've done here to illustrate, please ask if it helps.i thank all you advanced programmers who go out of their way to help others, thanks in advance. i used phpmyadmin to set up the tables etc. i think that the ajax could be the problem any help will be highly appreciated, thanks in advance, i've attatched the relevant files.
  16. I am having some real trouble getting my head around php (just starting out) I have successfully implemented this triple drop down ajax script http://roshanbh.com....ax-and-php.html my problem is getting it to populate text boxes as well. <? $country=intval($_GET['country']); $link = mysql_connect('localhost', 'root', ''); //changet the configuration in required if (!$link) { die('Could not connect: ' . mysql_error()); } mysql_select_db('db_ajax'); $query="SELECT id,statename,phone,contact FROM state WHERE countryid='$country'"; $result=mysql_query($query); ?> <select name="state" onchange="getCity(<?=$country?>,this.value)"> <option>Select State</option> <? while($row=mysql_fetch_array($result)) { ?> <option value=<?=$row['id']?> <?=$row['statename']?> <?=$row['phone']?> <?=$row['contact']?></option> <? } ?> </select> <br/> on change update this to the selected contact <br/> <input type=text value=<?=$row['contact']?>> <br/> on change update this to the selected phone <br/> <input type=text value=<?=$row['phone']?>> I have been battling this for about a week now it getting beyond a joke Free hugs for help
  17. I have installed a PHP/AJAX "instant search" (like Google) on our website. The results should appear immediately below the input box, but they appear way up and to the left. Using a document.getelementByID(name).style.position along with top and left have no effect on the result box location. Here's the details: Here's the problem in action: Enter an a into the search box at http://www.woofwoofwoof.org/is01/search.htm and you'll see the results up and to the left rather than just below the input box. The original search code on the w3school's site (located at http://www.w3schools..._livesearch.asp ) has worked well until I inserted into our web site; can anyone spot the problem? Here's our HTML-- I believe the problem lies in the relevant CSS, javascript or the inputbox lines. I've tried to mark them in green and surrounded them with a title and lots of equal signs. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Search page - SupportWorks</title> <meta name="description" content="Directory of resources in the Charlotte, NC region for nonprofit non-poltical support groups"> <meta name="keywords" content="SupportWorks search page, Charlotte NC, support groups"> <meta name="generator" content="WYSIWYG [url="http://www.php-forum.com/phpforum/viewtopic.php?f=26&t=21108#"]Web Builder[/url] 8 - http://www.wysiwygwebbuilder.com"> <style type="text/css"> div#container { width: 994px; position: relative; margin-top: 0px; margin-left: auto; margin-right: auto; text-align: left; } body { text-align: center; margin: 0; background-color: #9999CC; color: #000000; } </style> <style type="text/css"> a { color: #282828; text-decoration: none; } a:visited { color: #282828; } a:active { color: #282828; } a:hover { color: #FF0000; text-decoration: none; } </style> <style type="text/css"> #Line1 { color: #3300CC; background-color: #3300CC; border-width: 0px; } #wb_Shape8 a img { position: absolute; } #wb_Shape8 span { position: absolute; } #wb_Shape8 a .hover { visibility: hidden; } #wb_Shape8 a:hover .hover { visibility: visible; } #wb_Shape8 a:hover span { visibility: hidden; } #wb_Shape9 a img { position: absolute; } #wb_Shape9 span { position: absolute; } #wb_Shape9 a .hover { visibility: hidden; } #wb_Shape9 a:hover .hover { visibility: visible; } #wb_Shape9 a:hover span { visibility: hidden; } #wb_Shape10 a img { position: absolute; } #wb_Shape10 span { position: absolute; } #wb_Shape10 a .hover { visibility: hidden; } #wb_Shape10 a:hover .hover { visibility: visible; } #wb_Shape10 a:hover span { visibility: hidden; } #wb_Shape4 a img { position: absolute; } #wb_Shape4 span { position: absolute; } #wb_Shape4 a .hover { visibility: hidden; } #wb_Shape4 a:hover .hover { visibility: visible; } #wb_Shape4 a:hover span { visibility: hidden; } #Image2 { border: 0px #000000 solid; } #Layer1 { background-color: #FAFAFA; opacity: 0.00; -moz-opacity: 0.00; -khtml-opacity: 0.00; filter: alpha(opacity=0); } #Image1 { border: 0px #000000 solid; } [color=#008000][b]================================ CSS and SCRIPT ============================== [color=#800080][color=#8000FF][list]#Editbox1 { border: 2px #000000 solid; -moz-border-radius: 25px; -webkit-border-radius: 25px; border-radius: 25px; background-color: #CCFFFF; color :#282828; font-family: Arial; font-size: 20px; padding: 0px 0px 0px 20px; text-align: left; vertical-align: middle; } [/color][/list][/color]</style> [b][color=#4000FF]<script type="text/javascript"> function showResult(str) { if (str.length==0) { document.getElementById("livesearch").innerHTML=""; document.getElementById("livesearch").style.border="0px" return; } if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("livesearch").innerHTML=xmlhttp.responseText; document.getElementById("livesearch").style.fontFamily="Arial"; document.getElementByID("livesearch").style.position="absolute"; document.getElementByID("livesearch").style.top="500px"; document.getElementByID("livesearch").style.left="500px" } } xmlhttp.open("GET","livesearch.php?q="+str,true); xmlhttp.send(); } </script>[/b][/color] [/color]</head> [/b] ===================== END CSS AND SCRIPT ================================= <body> <div id="container"> <div id="wb_Shape2" style="position:absolute;left:73px;top:142px;width:753px;height:44px;z-index:1;"> <img src="images/img0026.gif" id="Shape2" alt="" style="border-width:0;width:753px;height:44px;"></div> <div id="wb_Shape7" style="position:absolute;left:2px;top:28px;width:959px;height:578px;z-index:2;"> <img src="images/img0027.gif" id="Shape7" alt="" style="border-width:0;width:959px;height:578px;"></div> <hr id="Line1" style="margin:0;padding:0;position:absolute;left:437px;top:116px;width:442px;height:3px;z-index:3;"> <div id="wb_Shape5" style="position:absolute;left:511px;top:63px;width:2px;height:44px;z-index:4;"> <img src="images/img0028.gif" id="Shape5" alt="" style="border-width:0;width:2px;height:44px;"></div> <div id="wb_Shape8" style="position:absolute;left:599px;top:56px;width:111px;height:66px;z-index:5;"> <a href="./discover.htm"><img class="hover" src="images/img0029_hover.png" alt="" style="border-width:0;width:111px;height:66px;"><span><img src="images/img0029.png" id="Shape8" alt="" style="border-width:0;width:111px;height:66px;"></span></a></div> <div id="wb_Shape9" style="position:absolute;left:712px;top:57px;width:98px;height:66px;z-index:6;"> <a href="./learn.htm"><img class="hover" src="images/img0030_hover.png" alt="" style="border-width:0;width:98px;height:66px;"><span><img src="images/img0030.png" id="Shape9" alt="" style="border-width:0;width:98px;height:66px;"></span></a></div> <div id="wb_Shape10" style="position:absolute;left:812px;top:57px;width:89px;height:66px;z-index:7;"> <a href="./contact.htm"><img class="hover" src="images/img0031_hover.png" alt="" style="border-width:0;width:89px;height:66px;"><span><img src="images/img0031.png" id="Shape10" alt="" style="border-width:0;width:89px;height:66px;"></span></a></div> <div id="wb_Shape11" style="position:absolute;left:592px;top:63px;width:2px;height:44px;z-index:8;"> <img src="images/img0032.gif" id="Shape11" alt="" style="border-width:0;width:2px;height:44px;"></div> <div id="wb_Shape12" style="position:absolute;left:706px;top:61px;width:2px;height:44px;z-index:9;"> <img src="images/img0033.gif" id="Shape12" alt="" style="border-width:0;width:2px;height:44px;"></div> <div id="wb_Shape13" style="position:absolute;left:805px;top:61px;width:2px;height:44px;z-index:10;"> <img src="images/img0034.gif" id="Shape13" alt="" style="border-width:0;width:2px;height:44px;"></div> <div id="wb_Shape4" style="position:absolute;left:517px;top:55px;width:81px;height:69px;z-index:11;"> <a href="./form.htm"><img class="hover" src="images/img0035_hover.png" alt="" style="border-width:0;width:81px;height:69px;"><span><img src="images/img0035.png" id="Shape4" alt="" style="border-width:0;width:81px;height:69px;"></span></a></div> <div id="wb_Shape1" style="position:absolute;left:436px;top:55px;width:81px;height:68px;z-index:12;"> <img src="images/img0036.png" id="Shape1" alt="" style="border-width:0;width:81px;height:68px;"></div> <div id="wb_Image2" style="position:absolute;left:64px;top:53px;width:334px;height:61px;z-index:13;"> <img src="images/SWLavLogo.JPG" id="Image2" alt="" border="0" style="width:334px;height:61px;"></div> <div id="Layer1" style="position:absolute;text-align:left;left:50px;top:36px;width:368px;height:96px;z-index:14;" title="Go home!"> <div id="wb_Image1" style="position:absolute;left:11px;top:5px;width:344px;height:82px;opacity:0.00;-moz-opacity:0.00;-khtml-opacity:0.00;filter:alpha(opacity=0);z-index:0;"> <a href="./index.htm"><img src="images/SW-Logo.jpg" id="Image1" alt="" border="0" style="width:344px;height:82px;"></a></div> </div> [color=#008000]=========================== HTML FOR INPUT BOX FORM ========================= [color=#4000FF]<form> <input type="text" id="Editbox1" onkeyup="showResult(this.value)" style="position:absolute;left:107px;top:139px;width:724px;height:41px;line-height:41px;z-index:15;" name="SearchBox" value="" autocomplete="off" placeholder="Start your search here" autofocus="autofocus" placeholder="Start your search here"> <div id="livesearch"></div> </form> =================================END FORM HTML =============================[/color] [/color]<div id="wb_Shape6" style="position:absolute;left:787px;top:146px;width:53px;height:28px;z-index:16;"> <img src="images/img0038.gif" id="Shape6" alt="" style="border-width:0;width:53px;height:28px;"></div> </div> </body> </html> Thank you very much for taking the time. -- DrC
  18. Hi, I am new in php and trying to build a database driven web site. In every step I deal with a new problem . In the image I attached I have a diagram of how the website looks. As you can see I have a side bar with two dropdown menus and on the right is the main content of the page. The procedure goes like this: When I select a value from the drop down menu and click the button, a request is sent through Ajax to the database (I use the $.ajax function). All the php code is written in a different file which I define in the url of ajax method. That way my page is not refreshed every time that I click the button. But the problem is that the results are not appearing where I want. As you can see in the diagram(attached) I want them to be in the main content of the page (1) but they appear on the sidebar (2). This must be really easy question but as I said I started learning only some time ago. Any suggestions? Thanks Dimitris
  19. I have tried this code below to solve my problem , but in front end number is increasing buy in Mysql the numbers are not increasing <?php $con=mysqli_connect('localhost','root','','youtube'); $alias=$_GET['alias']; $sql="SELECT * FROM articles where alias='$alias'"; $res=mysqli_query($con,$sql); $row=mysqli_fetch_assoc($res); ?> <!DOCTYPE html> <html lang="en"> <head> <title>Like Dislike</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css" rel="stylesheet"> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js"></script> <script src="https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js" integrity="sha256-Lsk+CDPOzTapLoAzWW0G/WeQeViS3FMzywpzPZV8SXk=" crossorigin="anonymous"></script> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.1/jquery.min.js"></script> </head> <body> <div class="container"> <div class="row main_box"> <div class="col-md-6 title"> <h3><?php echo $row['title']; ?></h3> </div> <div class="col-md-3"> <a href="javascript:void(0)" class="btn btn-info"> <span class="glyphicon glyphicon-thumbs-up" onclick="like_update('<?php echo $row['id']; ?>')">Like (<span id="like_loop_<?php echo $row['id']; ?>"><?php echo $row['like_count']; ?></span>)</span> </a> </div> <div class="col-md-3"> <a href="javascript:void(0)" class="btn btn-info"> <span class="glyphicon glyphicon-thumbs-down" onclick="dislike_update('<?php echo $row['id']; ?>')">Dislike (<span id="dislike_loop_<?php echo $row['id']; ?>"><?php echo $row['dislike_count']; ?></span>)</span> </a> </div> </div> <script> function like_update(id) { var cur_count=jQuery('#like_loop_'+id).html(); cur_count++; jQuery('#like_loop_'+id).html(cur_count); jQuery.ajax({ url:'update_count.php', type:'post', data:'type=like&id='+id, success:function(result){ } }); } function dislike_update(id) { var cur_count=jQuery('#dislike_loop_'+id).html(); cur_count++; jQuery('#dislike_loop_'+id).html(cur_count); jQuery.ajax({ url:'update_count.php', type:'post', data:'type=dislike&id='+id, success:function(result){ } }); } </script> </div> </body> </html> update_count.php <?php $con=mysqli_connect('localhost','root','','youtube'); $type=$_POST['type']; $id=$_POST['id']; if ($type=='like') { $sql="UPDATE articles SET like_count=like_count+1 WHERE id=$id"; } else { $sql="UPDATE articles SET dislike_count=dislike_count+1 WHERE id=$id"; } $res_count=mysqli_query($con,$sql); ?> Please help me my seniors here... Thanks in advance
  20. I am attempting to create a php AJAX contact form , however the email never seems to arrive in my outlook. /* Jquery Validation using jqBootstrapValidation example is taken from jqBootstrapValidation docs */ $(function() { $("input,textarea").jqBootstrapValidation( { preventSubmit: true, submitError: function($form, event, errors) { // something to have when submit produces an error ? // Not decided if I need it yet }, submitSuccess: function($form, event) { event.preventDefault(); // prevent default submit behaviour // get values from FORM var name = $("input#name").val(); var email = $("input#email").val(); var phone = $("input#phone").val(); var message = $("textarea#message").val(); var firstName = name; // For Success/Failure Message // Check for white space in name for Success/Fail message if (firstName.indexOf(' ') >= 0) { firstName = name.split(' ').slice(0, -1).join(' '); } $.ajax({ url: "./bin/contact_me.php", type: "POST", data: {name: name,phone:phone, email: email, message: message}, cache: false, success: function() { // Success message $('#success').html("<div class='alert alert-success'>"); $('#success > .alert-success').html("<button type='button' class='close' data-dismiss='alert' aria-hidden='true'>×") .append( "</button>"); $('#success > .alert-success') .append("<strong>Your message has been sent. </strong>"); $('#success > .alert-success') .append('</div>'); //clear all fields $('#contactForm').trigger("reset"); }, error: function() { // Fail message $('#success').html("<div class='alert alert-danger'>"); $('#success > .alert-danger').html("<button type='button' class='close' data-dismiss='alert' aria-hidden='true'>×") .append( "</button>"); $('#success > .alert-danger').append("<strong>Sorry "+firstName+" it seems that my mail server is not responding...</strong> Could you please email me directly ? Sorry for the inconvenience!"); $('#success > .alert-danger').append('</div>'); //clear all fields $('#contactForm').trigger("reset"); }, }) }, filter: function() { return $(this).is(":visible"); }, }); $("a[data-toggle=\"tab\"]").click(function(e) { e.preventDefault(); $(this).tab("show"); }); }); /*When clicking on Full hide fail/success boxes */ $('#name').focus(function() { $('#success').html(''); }); <?php require("../lib/phpmailer/PHPMailerAutoload.php"); if(empty($_POST['name']) || empty($_POST['email']) || empty($_POST['phone']) || empty($_POST['message']) || !filter_var($_POST['email'],FILTER_VALIDATE_EMAIL)) { echo "No arguments Provided!"; return false; } $m = new PHPMailer(); $m->IsSMTP(); $m->SMTPAuth = true; $m->SMTPDebug = 2; $m->Host = "smtp-mail.outlook.com"; $m->Username = ""; $m->Password = ""; $m->SMTPSecure = 'tls'; $m->Port = 587; $m->addAddress('EXAMPLE@outlook.com', $name); $name = $_POST['name']; $email_address = $_POST['email']; $phone = $_POST['phone']; $message = $_POST['message']; $m->Subject = "Contact Form has been submitted"; $m->Body = "You have received a new message. <br><br>". " Here are the details:<br> Name: $name <br> Phone Number: $phone <br>". "Email: $email_address<br> Message <br> $message"; if(!$m->Send()) { echo "Mailer Error: " . $m->ErrorInfo; exit; } ?>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.