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. Admin - please delete this post. I don't know how so many post duplicated were generated.
  2. I am having a problem understanding why when I run my script and I put the results inside a select statement it does not show the values but when I remove the select statement the values or visible . The following code will show you what I mean. If you comment out the select statement in the html script it will work. I don't understand way <?php // CONNECT TO THE DATABASE $DB_NAME = 'notary'; $DB_HOST = 'localhost'; $DB_USER = 'root'; $DB_PASS = ''; $db=$mysqli = new mysqli($DB_HOST, $DB_USER, $DB_PASS, $DB_NAME); if (mysqli_connect_errno()) { printf("Connect failed: %s\n", mysqli_connect_error()); exit(); } ?> <?php include("db.php"); $sql='SELECT * FROM customer'; $result=$db->query($sql); while($row = mysqli_fetch_array($result,MYSQLI_BOTH)) { echo "<option value=" . $row['name'] . ">" .$row['name'] . "</option>"; } <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>ready demo</title> <script src="js/jquery.js"></script> <script> $( document ).ready(function() { $.ajax({ //create an ajax request to load_page.php type: "GET", url: "php/display.php", dataType: "text", //expect html to be returned success: function(response){ $("#responsetext").text(response); //alert(response); } }); /*$( "p" ).text( "The DOM is now loaded and can be manipulated." );*/ }); </script> </head> <body> <div align="center"> <select name="customer"> <!--<---comment out this line--> <div id="responsetext"> </select> <!--<---comment out this line--> </div> </body> </html>
  3. Hello All, I am doing a tutorial on username availability using AJAX for immediate username validation. I have made it from the tutorial but decided to use PDO instead of the old "mysql" statements just FYI, I do not think it play's into the issue but might. I keep getting this error from my Chrome console Uncaught TypeError: Object [object global] has no method 'addEvent' I researched the error and made sure MooTools is up and running on my index page but this did not solve my issue. Any help would be much appreciated, here is my code index.php <html> <head> <title>Username Availability</title> <link rel="stylesheet" type="text/css" href="style/style.css"> <script type="text/javascript" src="js/main.js"></script> <script src="//ajax.googleapis.com/ajax/libs/mootools/1.4.5/mootools-yui-compressed.js"></script> </head> <body> <div id="container"> <div id="content"> <fieldset> <form method="post" action="js/json.php" id="signup"> <ul class="form"> <li> <label for="user_name">Username</label> <input type="text" name="user_name" id="user_name" /> </li> <li><input type="submit" value="Sign Up Now!" /></li> </ul> </form> </fieldset> </div> </div> </body> </html> main.js window.addEvent('domready', function() { alert('The DOM is ready!'); $('user_name').addEvent('keyup', function(){ new Request.JSON({ url: "json.php", onSuccess: function(response){ if (response.action == 'success') { $('user_name').removeClass('error'); $('user_name').addClass('success'); } else { $('user_name').removeClass('success'); $('user_name').addClass('error'); } } }).get($('signup')); }); }); json.php <?php $config['db'] = array( 'host' => 'localhost', 'username' => 'username', 'password' => 'password', 'dbname' => 'database' ); try { $DBH = new PDO('mysql:host=' . $config['db']['host']. ';dbname=' .$config['db']['dbname'], $config['db']['username'], $config['db']['password']); $DBH->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $DBH->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); $DBH->exec('SET CHARACTER SET utf8'); } catch (PDOException $e) { echo 'Connection failed: ' . $e->getMessage(); } $result = null; $user_name = mysql_real_escape_string($_POST['user_name']); $stmt = $DBH->prepare("SELECT user_name FROM ajax_users WHERE user_name = :user_name"); $stmt->bindParam(':user_name', $user_name); $stmt->execute(); $result = $stmt->fetch(PDO::FETCH_ASSOC); if ($result == 0){ $result['action'] = 'success'; } else { $result['action'] = 'error'; } $result['user_name'] = $_POST['user_name']; echo json_encode($result); ?> style.css input.success{ border: 3px solid #9ad81f; } input.error{ border: 3px solid #b92929; } The database is called "stuff" and it has a table called "ajax_users". If something turned off? I am not sure where to go with this one. Thanks for the help in advance
  4. Hi, I dont know if this is a wrong category to post. I have a registration form in my website. I need a overlay popup after the sucessfull registration process. Can someone help me. Thanks in advance. Regards..
  5. I would like to know how to call a php function using javascript. I've done some googling and found that I need to use ajax. I read some tutorials and don't understand how to use ajax. All I want to do is execute a php function, which writes to a txt file, from the execution of a javascript function. I don't care if the webpage refreshes or not; I'll just make the javascript function refresh the page. Something like this: <?php include 'banusers.php'; ?> <script> function banUser() { <?php writeIPToFile(); ?> alert("You have been banned!"); window.location.reload(); } </script> <p>Click <a href="javascript:banUser();">HERE</a> to ban yourself!</p> Would someone be kind enought to write an example for me? Edit: fixed typo
  6. If you look at this code it gets the left coordinate of the div tag - http://jsfiddle.net/JuPA4/ which is pretty much what I need. I am using a program on the Mac called Hype, it is like flash but all HTML 5, my demonstration is here - http://snooker-magazine.co.uk/phpfreaks/black.html (I have asked on the Hype forums and have had no answer for 3 days now) The black dot element is within a div tag called #black for some reason the code posted above does not work with the hype file! I know I can interact with it and I have added a demonstration to the page click Hide / Show to interact with the dot. I am not the best with Javascript so if anybody has any ideas then the help would be appreciated. There is a zip file in the parent folder with all the files if anybody needs them. The end result of this is that the coordinates for both left and top are updated to a text input so I can place them into a database.
  7. I'm trying to create a ten button menu that will change the content of a DIV. I have a smaller version as follows: <!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="include/layout.css" type="text/css" rel="stylesheet" /> <script> function changeContent() { document.getElementById('myTable').innerHTML=document.getElementById('showTable').innerHTML; } </script> <script type="text/html" id="showTable"> <?php See2(); ?> </script> </head> <body> <div class="signup"> <form> <input type="image" src="images/BECOME_A_MEMBER.png" border=0 width=150 height=150 onClick="changeContent();return false;" value="Change content"> </form> </div> </div> <div class="content" id="myTable"> <?php See1(); ?> </div> </body> </html> <?php function See1() {echo "See One";} function See2() {echo "See Two";} ?> I would like a similar script like this: index.php <?php include'func.php'; ?> <!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> </head> <link href="include/layout.css" type="text/css" rel="stylesheet" /> <script> function changeContent(func) { document.getElementById('myTable').innerHTML=document.getElementById('showTable').innerHTML; } </script> <script type="text/html" id="showTable"> if (func=='HomePage') {<?php Homepage(); ?>} if (func=='Messages') {<?php Messages(); ?>} if (func=='Notifications') {<?php Notifications(); ?>} if (func=='MyStuff') {<?php MyStuff(); ?>} if (func=='Community') {<?php Community(); ?>} if (func=='LiveAction') {<?php LiveAction(); ?>} if (func=='WhatsHot') {<?php WhatsHot(); ?>} if (func=='RatePics') {<?php RatePics(); ?>} if (func=='Upload') {<?php Upload(); ?>} if (func=='IMessanger') {<?php IMessanger(); ?>} </script> <body> <a class="home_out" href="index.php" onClick="changeContent(HomePage);return false;" value="Change content" title="HomePage"></a> <a class="email_out" href="index.php" onClick="changeContent(Messages);return false;" value="Change content" title="Messages"></a> <a class="notify_out" href="index.php" onClick="changeContent(Notifications);return false;" value="Change content" title="Notifications"></a> <a class="mine_out" href="index.php" onClick="changeContent(MyStuff);return false;" value="Change content" title="My Stuff"></a> <a class="comm_out" href="index.php" onClick="changeContent(Community);return false;" value="Change content" title="Community"></a> <a class="live_out" href="index.php" onClick="changeContent(LiveAction);return false;" value="Change content" title="Live Action"></a> <a class="hot_out" href="index.php" onClick="changeContent(WhatsHot);return false;" value="Change content" title="What's Hot"></a> <a class="rate_out" href="index.php" onClick="changeContent(RatePics);return false;" value="Change content" title="Rate Pics"></a> <a class="upload_out" href="index.php" onClick="changeContent(Upload);return false;" value="Change content" title="Upload Pics/Vids/Audio"></a> <a class="im_out" href="index.php" onClick="changeContent(IMessanger);return false;" value="Change content" title="Instant Messanger"></a> <div class="content" id="myTable"> <?php HomePage(); ?> </div> </body> </html> func.php <? function HomePage() {echo"HomePage";} function Messages() {echo"Messages";} function Notifications() {echo"Notifications";} function MyStuff() {echo"MyStuff";} function Community() {echo"Community";} function LiveAction() {echo"LiveAction";} function WhatsHot() {echo"WhatsHot";} function RatePics() {echo"RatePics";} function Upload() {echo"Upload";} function IMessanger() {echo"IMessanger";} ?> I get nothing displayed besides the background with the way index.php is. And if I remove the second script ID'd as showTable, I get a Fatal error: Call to undefined function HomePage() even tho its in func.php that was included at the start of index.php
  8. I'm using a method call from ajax. But how do I prevent the method not to be access directly? I try. if(isset($_POST)){ } else{ die('Unauthorize page!'); } but still i can be access directly. What is the safest way to prevent it accessing directly?
  9. I have a list of checkboxes, for a filter for manufacturers. I want the checkboxes to update the search results on click, when a new manufacturer is selected or de-selected. The ajax code picks up the checked items from the form like this $('.new_make_button').click(function(){ // when a feature button is selected var serialize = $('#new_make_form').serialize(); // takes all the values of the filter $.ajax({ type : 'POST', url : '../ajax/new_makes.php', // sends the values to ajax file data : serialize, success : function(data) { $("#new_results").html(data); } }); }); I want to add all the selected manufacturer_ids into a list like (1,4,7,10), and set them in a session and run the class, with the updated session. <?php if(isset($_POST['makes'])) $_SESSION['new_results']['makes'] = $_POST['makes']; include '../classes/new-results.php'; $result = new NewResults; $_SESSION['user']['new']; return $result->results(); ?> How can I pass the manufacturer IDs of only the selected manufacturers to the ajax file through the form #new_make_form. How should the html form work to accomplish this? Or do I need to make adjustments in the ajax files? I also am not sure about what the variable for $_POST should be, I have used 'makes' as an example, but not sure how it can catch them all at once.
  10. Hi , I am having two categories in a form with check boxes. one is Location and secong is Salary. if i click on a location and a salary range , the database values matching those fields should be displayed.If i uncheck them they should become invisible. I am trying for this since 4 days.Please help me with some code to do this. Thanks in advance.search-result.php
  11. I want to create a real esatte website. This is part of my code. The user selects a category.Then ajaxhelp is called and sends the cariable category to ajax.php. There it gets the type of estate wuering the database. however i want to enable the selected="selected" option, in order in category php in id=category in the bottom to print the option the user has already selected. i don't know how to it. The selected option doesnt work <script> function ajaxhelp(str) { if (str=="") { document.getElementById("category").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("category").innerHTML=xmlhttp.responseText; } } xmlhttp.open("GET","prosthiki_akinitou_form_ajax.php?category="+str,true); xmlhttp.send(); } </sqript> //category.php <tr > <td><h4>Category:<small class="red">*</small></h4></td> <td ><select name="category" onChange="ajaxhelp(this.value);"> <?php $category_array = get_categories(); //estate_fns echo '<option value=""><h4>- Choose Estate Category -</h4></option>'; foreach ($category_array as $row) { if($estate_array['catid'] === $row['catid']) { echo '<option selected="selected" value="'. $row['catid'].'"><h4>' . $row['catname'].'</h4></option>'; } else { echo '<option value="'. $row['catid'].'"><h4>' . $row['catname'].'</h4></option>';} } ?> </select> </td></tr> <?php echo '<tr >'; echo '<td><h4>Estate type:</h4></td> <td ><select name="eidos" id="category" >'; echo '</select> </td></tr>'; ?> //ajax.php include ('estate_sc_fns.php'); $katigoria = $_GET['category']; //get the value from ajax.php $estate_array = get_estate_details($_SESSION['estate_code']); //get the estate type the user already has entered from mysql $eidos_array = get_estate_type($category); //get all possible estate types from mysql foreach ($eidos_array as $row) { if($estate_array['estate_type'] === $row['estate_type'] ) { echo '<option selected="selected" value="'. $row['estate_type'].'"><h4>' . $row['estate_name'].'</h4></option>'; } else { echo '<option value="'. $row['estate_type'].'"><h4>' . $row['estate_name'].'</h4></option>';} } But the selected="selected" doesn't work! Please help how to do it?
  12. Hallo. I have a form <form id="form2" method="post" action="insert_data.php>"> <select name="catid" id="catid" onChange="showkatigoria(this.value);"> <option value="'. $row['catid'].'"><h4>' . $row['catname'].'</option> // something i need with php, i dont' think it matters <option value="'. $row['catid'].'"><h4>' . $row['catname'].'</option> <option value="'. $row['catid'].'"><h4>' . $row['catname'].'</option> //option value bla bla bla bla i have 4-5 options value. </select> My javascript: <script type="type/javascript"> function showkatigoria(str) { if (str=="") { document.getElementById("catid").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("catid").innerHTML=xmlhttp.responseText; } } xmlhttp.open("GET","insert_data.php?category="+str,true); xmlhttp.send(); } </script> It doesn't work what ever i do. Please help! I don't know javascript, let alone ajax. It's urgent. Please help!
  13. This may sound like a weird one. I'm in the process of making a HTML5 game where I need to make contact with a MYSQL database. I planned on doing this using PHP scripts that the game sends AJAX requests to with post data. Is there a way of securing these scripts so no one on the outside can access (or just run) them, but the game can. The game will be ran on the same server as the scripts. Does this sound ridiculous or is it possible? Or am I going about this the entirely wrong way, thanks for any answers in advance!!
  14. Hello, I am looking for someone that can redesign my old form and make some validation changes... Things I need the form to do: Confirm leaving the page, if it is done other than by submitting the form There is a place for three different phone numbers, home, work, and mobile, I only need to ensure that at least one of those is filled out, more can be, but one is required Proper character input type validation, phone numbers, zip code, email address Required fields, some of which are of the HTML "select" type of input Format masking, e.g. phone numbers Needs to be multi-browser compatible, Firefox, Chrome, IE, Safari The form needs to be smooth and curvy, very jQuery / AJAX Convert the MySQL to MySQLi The form should have it's own css, so that it can stand alone on it's own, but not conflict with other css either, e.g. start all of it's css with something like "form_" or something Improve upon the PHP as you see fit If you can make or add a better way to put in a date of birth, other than 3 drop-down boxes, then that would be good as well In the form there is also a question of whether or not an address is the same as another address, if so, it copies the address info, if not, it shows a new div, for a new address, the form will still need that functionality as well P.S. The form is called via an SSL secure page Please contact me with your quotes and any forms that you would like to show off, at motorsportfun2013 [@] gmail dot com Since I apparently can't attach the page, I'll post the code of what I'm currently using... <? require 'includes/auth.php'; $AgentID = $_SESSION['AgentID']; $AgentName = $_SESSION['AgentName']; if (isset($_GET['orderticketid'])) { $orderticketid = clean($_GET['orderticketid']); $result = mysql_query(" SELECT OrderTickets.*, Agencies.AgencyName, InsuranceCarriers.InsuranceCarrier FROM OrderTickets LEFT JOIN Agencies ON OrderTickets.AgencyID = Agencies.AgencyID LEFT JOIN InsuranceCarriers ON OrderTickets.InsuranceCarrierID = InsuranceCarriers.InsuranceCarrierID WHERE OrderTickets.OrderTicketID = '$orderticketid' AND OrderTickets.AgentID = '$AgentID' "); while ($OrderTicketRow = mysql_fetch_assoc($result)) { $InsuranceCarrierID = $OrderTicketRow['InsuranceCarrierID']; $InsuranceCarrierPolicyNumber = $OrderTicketRow['InsuranceCarrierPolicyNumber']; $OrderTicketFirstName = $OrderTicketRow['OrderTicketFirstName']; $OrderTicketMiddleName = $OrderTicketRow['OrderTicketMiddleName']; $OrderTicketLastName = $OrderTicketRow['OrderTicketLastName']; $OrderTicketAddress = $OrderTicketRow['OrderTicketAddress']; $OrderTicketCity = $OrderTicketRow['OrderTicketCity']; $OrderTicketState = $OrderTicketRow['OrderTicketState']; $OrderTicketZipCode = $OrderTicketRow['OrderTicketZipCode']; $OrderTicketExamLocation = $OrderTicketRow['OrderTicketExamLocation']; $OrderTicketExamLocationAddress = $OrderTicketRow['OrderTicketExamLocationAddress']; $OrderTicketExamLocationCity = $OrderTicketRow['OrderTicketExamLocationCity']; $OrderTicketExamLocationState = $OrderTicketRow['OrderTicketExamLocationState']; $OrderTicketExamLocationZipCode = $OrderTicketRow['OrderTicketExamLocationZipCode']; $OrderTicketHomePhone = $OrderTicketRow['OrderTicketHomePhone']; $OrderTicketWorkPhone = $OrderTicketRow['OrderTicketWorkPhone']; $OrderTicketMobilePhone = $OrderTicketRow['OrderTicketMobilePhone']; $OrderTicketEmailAddress = $OrderTicketRow['OrderTicketEmailAddress']; $OrderTicketDOBMonth = date('m', strtotime($OrderTicketRow['OrderTicketDOB'])); $OrderTicketDOBDay = date('d', strtotime($OrderTicketRow['OrderTicketDOB'])); $OrderTicketDOBYear = date('Y', strtotime($OrderTicketRow['OrderTicketDOB'])); $OrderTicketGender = $OrderTicketRow['OrderTicketGender']; $OrderTicketSmoker = $OrderTicketRow['OrderTicketSmoker']; $OrderTicketPolicyType = $OrderTicketRow['OrderTicketPolicyType']; $OrderTicketPolicyAmount = $OrderTicketRow['OrderTicketPolicyAmount']; $OrderTicketSpecialInstructions = $OrderTicketRow['OrderTicketSpecialInstructions']; } } ?> <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <link href="StyleSheet.css" rel="stylesheet" type="text/css" /> <link rel="shortcut icon" href="images/favicon.ico" /> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js" type="text/javascript"></script> <script type="text/javascript" src="includes/JavaScriptValidationFunctions.js"></script> <script type="text/javascript" src="includes/Modernizr-2.5.3.forms.js"></script> <script type="text/javascript" data-webforms2-support="validation" src="includes/html5Forms.js"></script> <script src="includes/jquery.maskedinput-1.3.min.js" type="text/javascript"></script> <script type="text/javascript"> jQuery(document).ready(function() { jQuery("#OrderTicketHomePhone").mask("(999) 999-9999"); jQuery("#OrderTicketWorkPhone").mask("(999) 999-9999"); jQuery("#OrderTicketMobilePhone").mask("(999) 999-9999"); }); </script> <script type="text/javascript"> window.onbeforeunload = function() { return 'You have unsaved changes!'; } </script> <script type="text/javascript"> function ShowHide(){ if (document.getElementById("OrderTicketExamLocation").value == '') { $('.show_hide').hide(); } if (document.getElementById("OrderTicketExamLocation").value != 'Home') { $('.show_hide').show(); } else if (document.getElementById("OrderTicketExamLocation").value == 'Home') { $('.show_hide').hide(); } } </script> <title>Submit Order Ticket</title> </head> <body> <div id="LogoHeader"> <img src="images/logo.png" /> </div> <div id="Menu"> <? include 'includes/menu.php'; ?> </div> <div class="jQueryErrors"> </div> <div id="OrderForm"> <br /> <form id="submitorderform" action="submitorderticket-action.php" method="post" onsubmit="return validateOrderSubmissionForm();"> <input id="submitneworderticket" name="submitneworderticket" value="submitneworderticket" type="hidden" /> <fieldset> <div class="FormRow"> <div class="FormLabel"> <label for="InsuranceCarrierID">* Insurance Carrier:</label> </div> <div class="FormInput"> <? $CarriersResult = mysql_query("SELECT InsuranceCarriersAgents.InsuranceCarrierID, InsuranceCarriers.InsuranceCarrier FROM InsuranceCarriersAgents LEFT JOIN InsuranceCarriers ON InsuranceCarriersAgents.InsuranceCarrierID = InsuranceCarriers.InsuranceCarrierID WHERE InsuranceCarriersAgents.AgentID = '$AgentID'") or die(mysql_error()); $rowCounter = mysql_num_rows($CarriersResult); if ($rowCounter == 0) { echo '<span style="background-color: #C0C0C0; color: red; padding: 2px;">You Are Not Associated With Any Insurance Carriers, Click On <a href="carrier-agent-correlations.php">Insurance Carriers</a> To Add It/Them.<span>'; } if ($rowCounter > 1) { echo '<select id="InsuranceCarrierID" name="InsuranceCarrierID">'; echo '<option value=""> ... </option>'; } while ($temprow = mysql_fetch_assoc($CarriersResult)) { if ($rowCounter == 1) { echo '<input type="hidden" id="InsuranceCarrierID" name="InsuranceCarrierID" value="'.$temprow['InsuranceCarrierID'].'" />'; echo '<input style="color: #515151;" type="text" id="InsuranceCarrier" name="InsuranceCarrier" value="'.$temprow['InsuranceCarrier'].'" size="50" READONLY />'; } if ($rowCounter > 1) { echo '<option value="'.$temprow['InsuranceCarrierID'].'">'.$temprow['InsuranceCarrier'].'</option>'; } } if ($rowCounter > 1) { echo '</select>'; } ?> </div> </div> <br /> <div class="FormRow"> <div class="FormLabel"> <label for="AgencyID">* Agency Name:</label> </div> <div class="FormInput"> <? $AgenciesResult = mysql_query("SELECT AgenciesAgents.AgencyID, Agencies.AgencyName FROM AgenciesAgents LEFT JOIN Agencies ON AgenciesAgents.AgencyID = Agencies.AgencyID WHERE AgenciesAgents.AgentID = '$AgentID'") or die(mysql_error()); $rowCounter = mysql_num_rows($AgenciesResult); if ($rowCounter == 0) { echo '<span style="background-color: #C0C0C0; color: red; padding: 2px;">You Are Not Associated With Any Agencies, Please Call ParaMedDirect.<span>'; } if ($rowCounter > 1) { echo '<select id="AgencyID" name="AgencyID">'; echo '<option value=""> ... </option>'; } while ($temprow = mysql_fetch_assoc($AgenciesResult)) { if ($rowCounter == 1) { echo '<input type="hidden" id="AgencyID" name="AgencyID" value="'.$temprow['AgencyID'].'" />'; echo '<input style="color: #515151;" type="text" id="AgencyName" name="AgencyName" value="'.$temprow['AgencyName'].'" size="50" READONLY />'; } if ($rowCounter > 1) { echo '<option value="'.$temprow['AgencyID'].'">'.$temprow['AgencyName'].'</option>'; } } if ($rowCounter > 1) { echo '</select>'; } ?> </div> </div> <br /> <div class="FormRow"> <div class="FormLabel"> <label for="AgentID">* Agent Name:</label> </div> <div class="FormInput"> <input type="hidden" id="AgentID" name="AgentID" value="<? echo $AgentID; ?>" /> <input style="color: #515151;" type="text" id="AgentName" name="AgentName" value="<? echo $AgentName; ?>" READONLY /> </div> </div> <br /> <div class="FormRow"> <div class="FormLabel"> <label for="InsuranceCarrierPolicyNumber"> Policy Number:</label> </div> <div class="FormInput"> <input id="InsuranceCarrierPolicyNumber" name="InsuranceCarrierPolicyNumber" type="text" value="<? echo $InsuranceCarrierPolicyNumber; ?>" /> </div> </div> <br /> <div class="FormRow"> <div class="FormLabel"> <label for="OrderTicketFirstName">* Client Name:</label> </div> <div class="FormInput"> <input id="OrderTicketFirstName" name="OrderTicketFirstName" type="text" value="<? echo $OrderTicketFirstName; ?>" required /> <input id="OrderTicketMiddleName" name="OrderTicketMiddleName" type="text" value="<? echo $OrderTicketMiddleName; ?>" size="1" /> <input id="OrderTicketLastName" name="OrderTicketLastName" type="text" value="<? echo $OrderTicketLastName; ?>" required /> </div> </div> <br /> <div class="FormRow"> <div class="FormLabel"> <label for="OrderTicketAddress">* Address:</label> </div> <div class="FormInput"> <input id="OrderTicketAddress" name="OrderTicketAddress" type="text" value="<? echo $OrderTicketAddress; ?>" required size="50" /> </div> </div> <br /> <div class="FormRow"> <div class="FormLabel"> <label for="OrderTicketCity">* City:</label> </div> <div class="FormInput"> <input id="OrderTicketCity" name="OrderTicketCity" type="text" value="<? echo $OrderTicketCity; ?>" required /> </div> </div> <br /> <div class="FormRow"> <div class="FormLabel"> <label for="OrderTicketState">* State:</label> </div> <div class="FormInput"> <select id="OrderTicketState" name="OrderTicketState"> <option value=""> ... </option> <? $StateResult = mysql_query("SELECT * FROM States WHERE 1"); while ($StateRow = mysql_fetch_assoc($StateResult)) { echo '<option value="'.$StateRow['StateAbbr'].'"'; if ($StateRow['StateAbbr'] == $OrderTicketState){echo ' SELECTED';} elseif ($StateRow['StateAbbr'] == "MO"){echo ' SELECTED';} echo '>'.$StateRow['State'].'</option>'; } ?> </select> </div> </div> <br /> <div class="FormRow"> <div class="FormLabel"> <label for="OrderTicketZipCode">* Zip Code:</label> </div> <div class="FormInput"> <input id="OrderTicketZipCode" name="OrderTicketZipCode" type="text" value="<? echo $OrderTicketZipCode; ?>" pattern="[0-9]{5}" required /> </div> </div> <br /> <div class="FormRow"> <span style="font-weight: 600;">Enter Exam Location if Different from Client Location.</span> </div> <br /> <div class="FormRow"> <div class="FormLabel" style="padding-left: 15px;"> <label for="OrderTicketExamLocation">Exam Location:</label> </div> <div class="FormInput"> <select id="OrderTicketExamLocation" name="OrderTicketExamLocation" onchange="ShowHide()"> <? $ExamLocationResult = mysql_query("SELECT * FROM ExamLocations"); while ($ExamLocationRow = mysql_fetch_assoc($ExamLocationResult)) { echo '<option value="'.$ExamLocationRow['ExamLocation'].'"'; if ($ExamLocationRow['ExamLocation'] == $OrderTicketExamLocation){echo ' SELECTED';} echo '>'.$ExamLocationRow['ExamLocation'].'</option>'; } ?> </select> </div> </div> <br /> <div class="show_hide"> <div class="FormLabel" style="padding-left: 15px;"> <label for="OrderTicketExamLocationAddress">Exam Location Address:</label> </div> <div class="FormInput"> <input id="OrderTicketExamLocationAddress" name="OrderTicketExamLocationAddress" type="text" value="<? echo $OrderTicketExamLocationAddress; ?>" size="50" /> </div> </div> <br /> <div class="show_hide"> <div class="FormLabel" style="padding-left: 15px;"> <label for="OrderTicketExamLocationCity">Exam Location City:</label> </div> <div class="FormInput"> <input id="OrderTicketExamLocationCity" name="OrderTicketExamLocationCity" type="text" value="<? echo $OrderTicketExamLocationCity; ?>" /> </div> </div> <br /> <div class="show_hide"> <div class="FormLabel" style="padding-left: 15px;"> <label for="OrderTicketExamLocationState">Exam Location State:</label> </div> <div class="FormInput"> <select id="OrderTicketExamLocationState" name="OrderTicketExamLocationState"> <option value=""> ... </option> <? $StateResult = mysql_query("SELECT * FROM States"); while ($StateRow = mysql_fetch_assoc($StateResult)) { echo '<option value="'.$StateRow['StateAbbr'].'"'; if ($StateRow['StateAbbr'] == $OrderTicketExamLocationState){echo ' SELECTED';} elseif ($StateRow['StateAbbr'] == "MO"){echo ' SELECTED';} echo '>'.$StateRow['State'].'</option>'; } ?> </select> </div> </div> <br /> <div class="show_hide"> <div class="FormLabel" style="padding-left: 15px;"> <label for="OrderTicketExamLocationZipCode">Exam Location Zip Code:</label> </div> <div class="FormInput"> <input id="OrderTicketExamLocationZipCode" name="OrderTicketExamLocationZipCode" type="text" value="<? echo $OrderTicketExamLocationZipCode; ?>" pattern="[0-9]{5}" /> </div> </div> <br /> <div class="FormRow"> <div class="FormLabel"> <label for="OrderTicketHomePhone">* Home Phone:</label> </div> <div class="FormInput"> <input id="OrderTicketHomePhone" name="OrderTicketHomePhone" type="tel" value="<? echo formatPhone($OrderTicketHomePhone); ?>" required /> </div> </div> <br /> <div class="FormRow"> <div class="FormLabel"> <label for="OrderTicketWorkPhone"> Work Phone:</label> </div> <div class="FormInput"> <input id="OrderTicketWorkPhone" name="OrderTicketWorkPhone" type="tel" value="<? echo formatPhone($OrderTicketWorkPhone); ?>" /> </div> </div> <br /> <div class="FormRow"> <div class="FormLabel"> <label for="OrderTicketMobilePhone"> Mobile Phone:</label> </div> <div class="FormInput"> <input id="OrderTicketMobilePhone" name="OrderTicketMobilePhone" type="tel" value="<? echo formatPhone($OrderTicketMobilePhone); ?>" /> </div> </div> <br /> <div class="FormRow"> <div class="FormLabel"> <label for="OrderTicketEmailAddress"> Email Address:</label> </div> <div class="FormInput"> <input id="OrderTicketEmailAddress" name="OrderTicketEmailAddress" type="email" size="50" value="<? echo $OrderTicketEmailAddress; ?>" /> </div> </div> <br /> <div class="FormRow"> <div class="FormLabel"> <label for="OrderTicketDOBMonth">* Date of Birth:</label> </div> <div class="FormInput"> <select id="OrderTicketDOBMonth" name="OrderTicketDOBMonth"> <option value=""> ... </option> <? for ($i=1;$i<13;$i++) { $i = sprintf('%02d', $i); echo '<option value="'.$i.'"'; if ($i == $OrderTicketDOBMonth) {echo ' SELECTED';} echo '>'.$i.'</option>'; } ?> </select> <select id="OrderTicketDOBDay" name="OrderTicketDOBDay"> <option value=""> ... </option> <? for ($i=1;$i<32;$i++) { $i = sprintf('%02d', $i); echo '<option value="'.$i.'"'; if ($i == $OrderTicketDOBDay) {echo ' SELECTED';} echo '>'.$i.'</option>'; } ?> </select> <select id="OrderTicketDOBYear" name="OrderTicketDOBYear"> <option value=""> ... </option> <? $thisYear = date('Y'); for ($i=1900;$i<$thisYear;$i++) { echo '<option value="'.$i.'"'; if ($i == $OrderTicketDOBYear){echo ' SELECTED';} echo '>'.$i.'</option>'; } ?> </select> </div> </div> <br /> <div class="FormRow"> <div class="FormLabel"> <label for="OrderTicketGender">* Gender:</label> </div> <div class="FormInput"> <select id="OrderTicketGender" name="OrderTicketGender"> <option value=""> ... </option> <option value="Male" <? if ($OrderTicketGender == "Male"){echo ' SELECTED';} ?>>Male</option> <option value="Female" <? if ($OrderTicketGender == "Female"){echo ' SELECTED';} ?>>Female</option> </select> </div> </div> <br /> <div class="FormRow"> <div class="FormLabel"> <label for="OrderTicketSmoker">* Tobacco User:</label> </div> <div class="FormInput"> <select id="OrderTicketSmoker" name="OrderTicketSmoker"> <option value=""> ... </option> <option value="Yes" <? if ($OrderTicketSmoker == "Yes"){echo ' SELECTED';} ?>>Yes</option> <option value="No" <? if ($OrderTicketSmoker == "No"){echo ' SELECTED';} ?>>No</option> <option value="NA" <? if ($OrderTicketSmoker == "NA"){echo ' SELECTED';} ?>>Not Applicable</option> </select> </div> </div> <br /> <div class="FormRow"> <div class="FormLabel"> <label for="OrderTicketPolicyType">* Policy Type:</label> </div> <div class="FormInput"> <select id="OrderTicketPolicyType" name="OrderTicketPolicyType"> <option value=""> ... </option> <option value="LifeTerm" <? if ($OrderTicketPolicyType == "LifeTerm"){echo ' SELECTED';} ?>>Life (term)</option> <option value="LifeVariable" <? if ($OrderTicketPolicyType == "LifeVariable"){echo ' SELECTED';} ?>>Life (variable)</option> <option value="Disability" <? if ($OrderTicketPolicyType == "Disability"){echo ' SELECTED';} ?>>Disability</option> <option value="Health" <? if ($OrderTicketPolicyType == "Health"){echo ' SELECTED';} ?>>Health</option> <option value="LTC" <? if ($OrderTicketPolicyType == "LTC"){echo ' SELECTED';} ?>>LTC</option> </select> </div> </div> <br /> <div class="FormRow"> <div class="FormLabel"> <label for="OrderTicketPolicyAmount">* Policy Amount:</label> </div> <div class="FormInput"> <input id="OrderTicketPolicyAmount" name="OrderTicketPolicyAmount" type="text" value="<? if ($OrderTicketPolicyAmount != 0) echo number_format($OrderTicketPolicyAmount, 2); ?>" required /> </div> </div> <br /> <div class="FormRow"> <div class="FormLabel"> <label for="OrderTicketSpecialInstructions"> Special Instructions:</label> </div> <div class="FormInput"> <textarea id="OrderTicketSpecialInstructions" name="OrderTicketSpecialInstructions" cols="40" rows="7"><? echo $OrderTicketSpecialInstructions; ?></textarea> </div> </div> <br /> <div class="FormRow"> <div class="FormSubmit"> <input id="submit" type="submit" value="Submit" /> </div> </div> <br /> </fieldset> <div id="sitesealdiv"> <span id="siteseal"><script type="text/javascript" src="https://seal.godaddy.com/getSeal?sealID=nezI8DdJpwJdyKY47vVrSgFuL1UYVfwDggv4JN4ykS5AumDDidYzrl"></script></span> </div> </form> </div> </body> </html>
  15. Hi I have a registration page for a website, in that i want to generate random number to disable the person's profile. Here the random number should generate after he creates his profile and that should be sent to the person through mail. He should enter that number for disabling his profile. I want the sample code or script by which i can implement easily. Thanks in advance Revs
  16. Hey, I would like to import data from CSV files to my application, First i've upload csv on to server then get csv contents by fgetcsv(), after that i want to map uploaded data and validate then send to db otherwise show error. Please suggest me how to do. Thanks
  17. Hi, I have problem with this line var value = $("#opstina option:selected").val(); , but only in chrome i get that value is undefined. In FireFox, and IE, works fine, only in chrome i get this warning. Does someone know why? My whole jquery code is if ($("#drzava option:selected").length) { $("select#opstina").attr("disabled","disabled"); $("select#opstina").html("<option>wait...</option>"); var id = $("select#drzava option:selected").attr('value'); $.post("select_opstina.php", {id:id}, function(data){ $("select#opstina").removeAttr("disabled"); alert( "html koji bi trebao biti upisan u select:\n\n" + data ); $("select#opstina").html(data); }); if ($("#opstina option:selected").length) { alert('Došao sam pred petlju'); var value = $("#opstina option:selected").val();//this is line that is problem alert(value); var sel = $("#opstina").val(); // this do the same if (sel!=0) { alert('Ušao sam u petlju, i selektovano polje za opštinu je' + sel ); $("select#mesto").attr("disabled","disabled"); $("select#mesto").html("<option>wait...</option>"); var id= $("select#opstina option:selected").attr('value'); alert(id); $.post("select_mesto.php", {id:id}, function(data){ alert("html koji bi trebao biti upisan u select:\n\n" + data ); $("select#mesto").removeAttr("disabled"); $("select#mesto").html(data); }); } } } }
  18. Hi, I am not asking for code, If you provide it thank you but I am happy to do the work myself I am more after the concept and code snippets. My Goal, I have 2 domains for this I will use www.1.com and www.2.com to make it easy. 1.com has a couple lines of javascript and 2 variables 1 being a domain and the other being a unique ID 2.com has a php script which is called by 1.com when the page is loaded (somehow) it will check the Unique ID and the domain that they match in a mySQL database and if they do to run another javascript script. If it does not to just end itself. The problem I have is I know PHP to an average level but Javascript well below average. I need to know how to run the PHP script from an external site 1.com to run a generic PHP script from 2.com and use the variables from 1.com to check the database at 2.com for a match and to either say yes matching display: or not matching deny. If anyone has any ideas on how to do this or something they have done before that would be awesome. I am wanting to to put the javascript on 10 different websites with different variables and for 2.com to just do the checking. for security reasons I need the URL to be checked so if 1.com loads and says the URL is 1.com but infact the user loaded 55.com it needs to be denied so PHP on 2.com needs to know where the request came from which domain... PLEASE HELP
  19. Hello everybody, I've started using a new CMS called Expression Engine. I'm very new but I know my way around the CMS itself and I need some help implementing a feature for a blog page. Currently on the blog page I have: {embed="/embed/header"} {embed="/embed/footer"} ..to give me my blank template of the page. I'm also using an embed to bring in the articles and a load more button, currently loading a new page with 6 new articles. What I want to achieve is an ajax load which loads 6 more articles underneath the existing 6. If anyone could help me find a tutorial or give me some advice on how to amend the current code to not load but dynamically enter 6 articles underneath ? The code underneath is the code that enables a new load with the next 6 articles Any help would be much appreciated ? HELP! {exp:channel:entries channel="research-developments" limit="6" status="Featured|Open" entry_id="not {embed:exclude-entry}" paginate="bottom" disable="member_data|trackbacks"} {switch="<div class='row'>||"} <div class="span3"> {article-block} </div> {switch="||</div>"} {if {count}=={total_results}} {if {count}!='3' AND {count}!='6'} </div><!-- close row --> {/if} {/if} {paginate} <div class="row"> <div class="span9"> {if next_page} <a href="{auto_path}" class="btn btn-large btn-block next" data-loading-text="Loading...">More articles (Showing page {current_page} of {total_pages} pages )</a> {/if} </div> </div> {/paginate} {/exp:channel:entries}
  20. I have a navigation script and I want to load the contents using ajax. the navigation script calls the ajax function but I don't know how to pass the ajax function the a href="data to be loaded" part. to test the script I have 2.php in the ajax function so how can I make '2.php' a variable that will change with the click of the link ? thank you <ul id="navigation"> <li class="one"><a href="index.html">home</a></li> <li class="two"><a href="2.php">page 2</a></li> <li class="three"><a href="3.php">page 3</a></li> <li class="four"><a href="4.php">page 4</a></li> <li class="five"><a href="5.php">page 5</a></li> <li class="shadow"></li> </ul> <div id="content"> <h2>here comes the content from the requested page</h2> </div> </div> <script type="text/javascript"> $(document).ready(function(){ $("ul#navigation li a").click(function() { $("ul#navigation li").removeClass("selected"); $(this).parents().addClass("selected"); return false; }); }); $("ul#navigation li a").click(function(){ $("#content").load("2.php",function(responseTxt,statusTxt,xhr){ if(statusTxt=="success") alert("External content loaded successfully!"); if(statusTxt=="error") alert("Error: "+xhr.status+": "+xhr.statusText); }); }); </script>
  21. I am trying to fetch data with AJAX but it is not working and also it is not providing any error ......... -------------------------------------------------------------------------------------------------------------------------------------------- This is the function that I have implemented to access the information -------------------------------------------------------------------------------------------------------------------------------------------- function get_data() { str = document.getElementById("select_data").value; var xmlhttp; if (str=="") { document.getElementById("select_data_here").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("select_data_here").innerHTML=xmlhttp.responseText; } } xmlhttp.open("GET","page.php?_search="+str,true); xmlhttp.send(); } -------------------------------------------------------------------------------------------------------------------------------------------- The page 127.0.0.1/online/page.php?_search=product1 is showing data, but it is not displaying that output on index.php -------------------------------------------------------------------------------------------------------------------------------------------- index.php <div id='select_data'> product1 </div> <button onClick="get_data()">Click </button> <div id='select_data_here'> Output here </div> --------------------------------------------------------------------------------------------------------------------------------------------
  22. I am not a jquery guru in any sense, so I am seeking some help with the below code. What I am trying to do, is populate two input fields, based on what is selected from a dropdown field via a database call. When I select a term from the dropdown, I want the term start date and term end date to populate in the appropriate fields. First here is my form: <form class="form-horizontal margin-none" action="<?=BASE_URL;?>form/runSection/" id="validateSubmitForm" method="post" autocomplete="off"> <div class="control-group"> <label class="control-label"><font color="red">*</font> <?php _e( _t( 'Term' ) ); ?></label> <div class="controls"> <select style="width:100%;" name="termCode" id="select2_10" required> <option value=""> </option> <?php table_dropdown('term', 'termCode', 'termName'); ?> </select> </div> </div> <div class="control-group"> <label class="control-label"><?php _e( _t( 'Term Start/End' ) ); ?></label> <div class="controls"> <input type="text" name="termStartDate" id="termStartDate" disabled class="span6" required /> <input type="text" name="termEndDate" id="termEndDate" disabled class="span6" required /> </div> </div> Second here is the javascript section: <script type="text/javascript"> jQuery(document).ready(function(){ jQuery('#select2_10').live('change', function(event) { $.ajax({ type : 'POST', url : '<?=BASE_URL;?>section/runTermLookup/', dataType: 'json', data : $('#validateSubmitForm').serialize(), cache: false, success: function( data ) { for(var id in data) { $(id).val( data[id] ); } } }); }); }); </script> Third, here is the method from my controller which passes the $_POST['termCode'] to the method of the same name found in the model: public function runTermLookup() { if(!$this->_auth->isUserLoggedIn()) { redirect( BASE_URL ); } $data = array(); $data['termCode'] = isPostSet('termCode'); $this->model->runTermLookup($data); } Lastly, here is the method from my model: public function runTermLookup($data) { $bind = array(":term" => $data['termCode']); $q = DB::inst()->select( "term","termCode = :term","termID","termStartDate,termEndDate", $bind ); $r = $q->fetch(\PDO::FETCH_ASSOC); $json = array( 'input#termStartDate' => $r['termStartDate'], 'input#termEndDate' => $r['termEndDate'] ); echo json_encode($json); } I've been looking at this for hours, so a fresh pair of eyes is greatly appreciated. Thank you.
  23. Hi Guys, I have a simple mysql_num_rows() expects parameter 1 to be resource, boolean given error in my script, I have tried to debug it myself but I don't understand why the script doesn't think the variable "$query" isn't an integer. I am trying to create a login form for users who are already registered and I want them to be able to see instant feedback as to whether their info has been accepted or not. The users won't be redirected though. testlogin.php <?php $name = $_GET['name']; $password = $_GET['password']; if (!$name && $password) { echo "Error"; exit; } mysql_connect("localhost" , "root" , "") or die("Issue with connection!"); mysql_select_db("testlogin"); $query = mysql_query("SELECT * FROM users WHERE Name='".$name."'"); $name = $_GET['name']; $password = $_GET['password']; if(!$name && $password) { echo 'No name or password'; exit(); } mysql_connect("localhost","root", ""); mysql_select_db("testlogin"); $query = mysql_query("SELECT * FROM users WHERE Name ='".$name."'"); $numrows = mysql_num_rows($query); if($numrows !=0) { while($row = mysql_fetch_assoc($query)) { $dbname = $row['Username']; $dbpassword = $row['password']; } if($name == $dbname && $password == $dbpassword) { echo "you are in!"; }else { echo "Please enter a valid username and password"; } }else { echo "Your name is not registered!"; } ?>
  24. I am trying to update the second select box 'subcategory_id' but I don't know how to return the query values back to the control/twig template. All of the examples I have seen echo back html from a option while loop. Should I be echo back the html as per other common examples or is there a more twig compliant way to do this, maybe returning an array variable. Thanks in advance, James catalogues.php <script> $('#category_id').change( function() { checkCategory(); // checks value and enables/disables subcategory control var catid = $(this).val(); var dataString = 'catid='+catid; $.ajax ({ type: "POST", url: "catalogues.php", data: dataString, cache: false, success: function() { $("#subcategory_id")..........; // ????? } }) }); </script> <?php if(isset($_POST['catid'] )) { $catid=$_POST['catid']; $sql_subcategory = "SELECT catalogues_categories.id, catalogues_categories.category, catalogues_categories.parent_id, catalogues_categories.inuse FROM catalogues_categories WHERE catalogues_categories.parent_id = {$catid} AND catalogues_categories.inuse = 1 ORDER BY catalogues_categories.category ASC"; $query_subcategory = $conn->query($sql_subcategory); $results_subcategory = $query_subcategory->fetchAll(); } else { $results_subcategory = null; } ?>
  25. hello i'm creating an ajax chat system and everything is working fine but the problem, i'm facing is that i can't replace some part of the message with the emotion kept in the array... If i run only the emotion script then its working fine but i can't immplement with the chat system.. Any body plz help... <?php ob_start(); session_start(); ?> <style> body{ background-color: grey; } #box{ width: 326px; height: 432px; border: 1px solid activeborder; margin: 0px auto; } #box1{ width: 326px; height: 400px; background-color: #eee; margin-bottom: 10px; } </style> <form method="post" action=""> <div id="box"> <div id="box1"> <?php mysql_connect("localhost","root","") or die(mysql_error()); mysql_select_db(chat) or die(mysql_error()); $req = mysql_query("SELECT * FROM msg") or die(mysql_error()); while($row = mysql_fetch_array($req)){ $m = $row['message']; echo "<div id='message'> $m </div>"; } ?> </div> <input type="text" id="chat" size="50" /> <input type="button" name="submit" value=" Chat " onclick="sendmessage()" /> </div> </form> <script> function sendmessage() { var msg = document.getElementById("chat").value; var xmlhttp; 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("box1").innerHTML=xmlhttp.responseText; } } xmlhttp.open("GET","chat_msg.php?m="+msg,true); xmlhttp.send(); } </script> and the chat_msg.php code is <?php session_start(); mysql_connect("localhost","root","") or die(mysql_error()); mysql_select_db(chat) or die(mysql_error()); $sess = session_id(); $mg = $_REQUEST['m']; $sql = mysql_query("INSERT INTO msg VALUES('','$sess','$mg')") or die(mysql_error()); $req = mysql_query("SELECT * FROM msg") or die(mysql_error()); while($row = mysql_fetch_array($req)){ $m = $row['message']; echo "<div id='message'> $m </div>"; } ?> and the emotion code is $str = $_REQUEST['comment']; $emo = array("<3", "#12", "@153", "#45", "@352"); $img = array("<img src='emotions/1.png' height='113' width='120' alt='ugly' />", "<img src='emotions/2.png' height='113' width='120' alt='happy' />", "<img src='emotions/3.png' height='113' width='120' alt='love' />", "<img src='emotions/4.png' height='113' width='120' alt='sweet' />", "<img src='emotions/5.png' height='113' width='120' alt='smiley' />"); $new_str = str_replace($emo, $img, $str); echo "<hr />"; echo $new_str; } ?> i can;t figure where to put the emotion code so that it will work like facebook chat system. Any help will be greatly appreciated... Thank u.
×
×
  • 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.