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. I have a 'subscribe' form on a website that uses Ajax to validate the input fields, the form is then processed via php. The actual html code resides on a Wordpress page. I had actually just got the form to work again. The website was static, and I transferred everything over to Wordpress, and the form didnt work. I was able to get it working by specifying the url: in ajax, as an absolute path to my php form. Overnight, something, I'm not sure what, stopped the form from processing. No data is posted to myql, and no email is sent or received. The status message just hangs at "Please wait while we process your information..." This message is in part of my Ajax code, so I am thinking something is wrong with my php script. I have a 'contact' page that uses nearly identical code that the 'subscribe' pages uses to validate the input fields, and it works. I was able to recover both the ajax and php script from an earlier time when they did work, I uploaded back to my server and nothing, the form still does not process. I also made sure my database credentials were correct with my host, and even tested my connection to mysql which I was able to connect. Next, I made sure I was able to send mail with my host. I don't know what is causing the form to hang, and I would love to get this solved; any help would be appreciated! PHP code: <?php if ($_SERVER['REQUEST_METHOD'] == 'POST') { define('DB_NAME', '######'); define('DB_USER', '######'); define('DB_PASSWORD', '######'); define('DB_HOST', '######'); $first = Trim(stripslashes($_POST['First'])); $last = Trim(stripslashes($_POST['Last'])); $city = Trim(stripslashes($_POST['City'])); $state = Trim(stripslashes($_POST['State'])); $country = Trim(stripslashes($_POST['Country'])); $email = Trim(stripslashes($_POST['Email'])); $tempt = $_POST['tempt']; $tempt2 = $_POST['tempt2']; if ($tempt == 'http://' && empty($tempt2)) { $error_message = ''; $reg_exp = "/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9­-]+\.[a-zA-Z.]{2,5}$/"; if(!preg_match($reg_exp, $email)) { $error_message .= "<p>A valid email address is required.</p>"; } if (empty($first)) { $error_message .= "<p>Please provide your first name.</p>"; } if (empty($last)) { $error_message .= "<p>Please provide your last name.</p>"; } if (!empty($error_message)) { $return['error'] = true; $return['msg'] = "<p>The request was successful, but the form was not filled out correctly.</p>".$error_message; echo json_encode($return); exit(); $dbc = mysql_connect('######', '######', '######'); $check_email_for_duplicates = mysql_query($dbc, "select * from 'members' where 'Email' = '".mysql_real_escape_string($email)."'"); if(mysql_num_rows($check_email_for_duplicates) > 0) //Email address is unique within this system and must not be more than one { echo 'Sorry, <b>'.$email.'</b> has already subscribed.'; } } else { $return['error'] = false; $return['msg'] = "<p style='top:12px; color:#ff6000; left:15px; text-align:left; font-size:1.50em;'>".$first .", <p style='top:0px; width:100%; left:15px; text-align:left; line-height:1.1em;'>your subscription request has been processed.</p>"; echo json_encode($return); } } else { $return['error'] = true; $return['msg'] = "<p>There was a problem while sending this form. Try it again.</p>"; echo json_encode($return); } $to = "######, ######"; $subject = "New Email Address for Mailing List"; $headers = "From: $email\n"; $headers .= "Content-type: text/html\r\n"; $message = "<span style='color:#252525; font-size:1.2em;'>A visitor to 3Elements Review has entered the following information so they can be added to your mailing list.</span><br>\n <br> <span style='color:#252525; font-weight:bold; font-size:1.35em;'>$first $last</span><br> <span style='color:#252525; font-weight:bold; font-size:1.35em;'>$city, $state</span><br> <span style='color:#252525; font-weight:bold; font-size:1.35em;'>$country</span><br> <span style='color:#252525; font-weight:bold; font-size:1.35em;'>$email</span>"; mail($to,$subject,$message,$headers); $user = "$email"; $usersubject = "Thank you for subscribing to 3Elements Review"; $userheaders = "From: ######\n"; $userheaders .= "Content-type: text/html\r\n"; $usermessage = "<body style='background-color:#dbf7ff; width:100%; height:105%;'> <span style='color:#353535; font-size:2em; font-weight:bold; font-family:pt sans;'>Welcome</span> <span style='color:#ff6000; font-size:2em; font-weight:bold; font-family:pt sans;'>$first</span><span style='color:#353535; font-size:2em; font-weight:bold; font-family:pt sans;'>,</span><br> <br> <span style='color:#353535; font-size:1.30em; font-family:noto serif;'>We're glad that you've decided to subscribe to our email list. We adore the people of $city!</span><br> <br> <span style='color:#353535; font-size:1.30em; font-family:noto serif;'>We have a lot of great things in the works that we're excited about at <em>3Elements Review,</em> and we can't wait to show <em>you</em> and all of the other writers, artists, and photographers immersed in the $city literary scene, all that <strong><em>3Elements Review</em></strong> has in store!</span><br> <br> <span style='color:#353535; font-size:1.30em; font-family:noto serif;'>Stay tuned for information regarding our issue release dates, contests, and other news!<br> <br> If you find us interesting enough, like us on Facebook and follow us on Twitter!</span><br> <br> <br> <span style='color:#353535; font-size:1.30em; font-family:noto serif;'>Sincerely,</span><br> <br> <span style='color:#ff6000; font-size:1.50em; font-family:pt sans;'>The 3Elements Team</span><br> <br> <br> <p> <span style='color:#353535; font-size:1.25em; font-family:pt sans; font-weight:bold;'>######</span><br> <span style='color:#353535; font-size:1.25em; font-family:pt sans; font-weight:bold;'>######</span><br> <span style='color:#ff6000; font-size:1.25em; font-family:pt sans; font-weight:bold;'>######</span><br> <img src='http://www.3elementsreview.com/images/logo-2.svg' width='122px' height='95px'> <br> <p> <span style='color:#353535; font-size:.9em; font-family:noto serif;'>You're receiving this email because you or someone you know subscribed you to our email list.</p> <span style='color:#353535; font-size:.9em; font-family:noto serif;'>If you would rather not receive email from 3Elements Review, you can unsubscribe by clicking <a href='mailto:######?Subject=Unsubscribe%20Request'>here</a>.</p> <br> <p> </body>"; mail($user,$usersubject,$usermessage,$userheaders); $link = mysql_connect('######', '######', '######'); if (!$link) { die('Could not connect: ' . mysql_error()); } $db_selected = mysql_select_db('######', $link); if (!$db_selected) { die('Can\'t use ' . '######' . ': ' . mysql_error()); } $value = mysql_real_escape_string($_POST['First']); $value2 = mysql_real_escape_string($_POST['Last']); $value3 = mysql_real_escape_string($_POST['City']); $value4 = mysql_real_escape_string($_POST['State']); $value5 = mysql_real_escape_string($_POST['Country']); $value6 = mysql_real_escape_string($_POST['Email']); $sql = "INSERT INTO members (First, Last, City, State, Country, Email, Date) VALUES('$value','$value2','$value3','$value4','$value5','$value6',NOW() + interval 2 hour)"; if (!mysql_query($sql)){ die('Error: ' . mysql_error()); } mysql_close(); }else{} ?> Ajax code: //*************************************************************REQUIRED FIELD SCRIPT FOR SUBSCRIBE PAGE*************************************************// $(document).ready(function() { $('form #response2').hide(); $('.button2').click(function(e) { e.preventDefault(); var valid = ''; var required = ' is required'; var first = $('form #first').val(); var last = $('form #last').val(); var email = $('form #email').val(); var tempt = $('form #tempt').val(); var tempt2 = $('form #tempt2').val(); if (first = '' || first.length <= 1) { valid += '<p>Your first name' + required + '</p>'; } if (last = '' || last.length <= 1) { valid += '<p>Your last name' + required + '</p>'; } if (!email.match(/^([a-z0-9._-]+@[a-z0-9._-]+\.[a-z]{2,4}$)/i)) { valid += '<p>Your e-mail address' + required + '</p>'; } if (tempt != 'http://') { valid += '<p>We can\'t allow spam bots.</p>'; } if (tempt2 != '') { valid += '<p>A human user' + required + '</p>'; } if (valid != '') { $('form #response2').removeClass().addClass('error2') .html('' +valid).fadeIn('fast'); } else { $('form #response2').removeClass().addClass('processing2').html('<p style="top:0px; left:0px; text-align:center; line-height:1.5em;">Please wait while we process your information...</p>').fadeIn('fast'); var formData = $('form').serialize(); submitForm(formData); } }); }); function submitForm(formData) { $.ajax({ type: 'POST', url: 'http://3elementsreview.com/blog/wp-content/themes/3elements/php-signup/sign-up-complete.php', data: formData, dataType: 'json', cache: false, timeout: 4000, success: function(data) { $('form #response2').removeClass().addClass((data.error === true) ? 'error2' : 'success2') .html(data.msg).fadeIn('fast'); if ($('form #response2').hasClass('success2')) { setTimeout("$('form #response2').fadeOut('fast')", 6000); } }, error: function(XMLHttpRequest, textStatus, errorThrown) { $('form #response2').removeClass().addClass('error2') .html('<p>There was an <strong>' + errorThrown + '</strong> error due to an <strong>' + textStatus + '</strong> condition.</p>').fadeIn('fast'); }, complete: function(XMLHttpRequest, status) { $('form')[0].reset(); } }); };
  2. Help me... My objective is to reload the marker inside google map every 30s... But the scripts below seem not running properly... <?php define('INCLUDE_CHECK',1); include "dbconnect.php"; ?> <!DOCTYPE html> <html lang="en"> <head> <title></title> <meta charset="UTF-8" /> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name ="audience" CONTENT="all"> <meta name ="revisit-after" CONTENT="4 days"> <meta name ="content-Language" CONTENT="English"> <meta name ="distribution" CONTENT="global"> <link rel="shortcut icon" href="favicon.png"/> <link rel="stylesheet" type="text/css" href="host_entry/css/demo.css" /> <link href="host_entry/css/bootstrap.min.css" rel="stylesheet" media="screen"> <script type="text/javascript" src="host_entry/js/jquery-1.7.1.min.js"></script> <script src="host_entry/js/bootstrap.min.js"></script> <!-- Google Map JS --> <script src="http://maps.google.com/maps/api/js?key=AIzaSyDY0kkJiTPVd2U7aTOAwhc9ySH6oHxOIYM&sensor=false" type="text/javascript"></script> <script> //SCRIPTS TO RESFRESH THE MARKER...I THINK THIS IS INCORRECT...HELP!!! $(document).ready(function() { $.ajaxSetup({ cache: false }); // This part addresses an IE bug. without it, IE will only load the first number and will never refresh setInterval(function() { $('#result').load('index.php'); }, 10000); // the "3000" here refers to the time to refresh the div. it is in milliseconds. }); // ]]> </script> </head> //to dislay the map <div id="map_canvas" style="top:55px;left:13px;"> <!-- Map will display --> <div id="map"> <!-- Fullscreen Loading & Fullscreen Buttons area --> <span style="color:Gray;">Loading map...</span> </div> <!-- Fullscreen Loading & Fullscreen Buttons area Ends --> </div><!-- Map Ends display --> <script type="text/javascript"> var locations = [ <?php $query="SELECT * from host_entry"; $result=mysql_query($query)or die(mysql_error()); { if ($num=mysql_numrows($result)) { $i=0; while ($i < $num) { $id=mysql_result($result,$i,"id"); //$host_type=mysql_result($result,$i,"host_type"); $host_name=mysql_result($result,$i,"host_name"); $host_status=mysql_result($result,$i,"host_status"); $host_lapt=mysql_result($result,$i,"host_lapt"); $host_long=mysql_result($result,$i,"host_long"); if($host_status==0) echo "[ '<div id=result><div class=info style=text-align:center;><h4>$host_name</h4></div></div>', $host_lapt, $host_long],"; $i++; } }else { echo "<h3 align='center'><font color='#ff0000'>No Content Found</font></h3>"; } } ?> ]; //FROM HERE TO SET THE MARKER IMAGE // Setup the different icons and shadows var iconURLPrefix = 'host_entry/img/'; var icons = [ iconURLPrefix + 'p_red_alert.png' ] var icons_length = icons.length; var map = new google.maps.Map(document.getElementById('map'), { zoom: -5, center: new google.maps.LatLng(3.1215681, 101.71180140000001), mapTypeId: google.maps.MapTypeId.ROADMAP, mapTypeControl: false, streetViewControl: false, disableDefaultUI: true, panControl: false, zoomControlOptions: { position: google.maps.ControlPosition.LEFT_BOTTOM } }); var infowindow = new google.maps.InfoWindow({ maxWidth: 400, maxHeight: 350, }); var marker; var markers = new Array(); var iconCounter = 0; //I THINK THE PROBLEM START HERE... // Add the markers and infowindows to the map for (var i = 0; i < locations.length; i++) { marker = new google.maps.Marker({ position: new google.maps.LatLng(locations[i][1], locations[i][2], locations[i][3], locations[i][4], locations[i][5]), map: map, animation: google.maps.Animation.BOUNCE, icon : icons[iconCounter], }); markers.push(marker); google.maps.event.addListener(marker, 'click', (function(marker, i) { return function() { infowindow.setContent(locations[i][0]); infowindow.open(map, marker); } })(marker, i)); iconCounter++; // We only have a limited number of possible icon colors, so we may have to restart the counter if(iconCounter >= icons_length){ iconCounter = 0; } } function AutoCenter() { // Create a new viewpoint bound var bounds = new google.maps.LatLngBounds(); // Go through each... $.each(markers, function (index, marker) { bounds.extend(marker.position); }); // Fit these bounds to the map map.fitBounds(bounds); } AutoCenter(); google.maps.event.addDomListener(window, 'load', initialize); </script> <?php //include "includes/footer.php"; ?> </body> </html> Is there a way to reload the marker with the ability of ajax towards the markers Help me for the solution... Thanks....
  3. I want to know how to hit a webpage that is not on your domain. I am doing an AJAX request right now, but receiving the following error in my console: The site I'm trying to hit does this weird cookie thing. I already spoke with their web administrator and he said the first time they access that site, it sets the cookie so they have to refresh in order to see if they can bypass a webpage they are trying to access.. I'm not sure if there is anyway to go about doing this since I can't go the AJAX route. But I don't have the capability of refreshing the user once they go on that page since it's not under my server or whatever. The only thing I could think of was AJAX which is not an option now. <?php include('scripts/config.php'); //Declare Variables $filter = new Filter(); $byPasscode = $filter->getBypassCode(); $openDns = "https://bpb.opendns.com/a/" . $_GET['url']; echo 'Redirecting...'; ?> <html> <head></head> <body> <form method="post" name="bypassForm" id="bypassForm" action="<?php echo $openDns ?>" style="display:none"> <input type="text" size="15" name="textBypassCode" id="textBypassCode" autocomplete="off" value="<?php echo $byPasscode; ?>" /> <input type="password" size="15" name="passwordBypassCode" id="passwordBypassCode" style="display:none;" value="<?php echo $byPasscode; ?>" /> <input type="hidden" name="code" id="bypassCode" value="<?php echo $byPasscode; ?>" /> <input type="submit" value="Continue" /> </form> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <script type="text/javascript"> //setTimeout(function(){ var textBypassCode = $('#textBypassCode').val(); var passwordBypassCode = $('#passwordBypassCode').val(); var bypassCode = $('#bypassCode').val(); $.ajax({ type: 'POST', url: $('#bypassForm').attr('action'), data: { textBypassCode: textBypassCode, passwordBypassCode: passwordBypassCode, bypassCode: bypassCode } }) .done(function(data) { //$('#bypassForm').submit(); }); //}, 3000); </script> </body> </html> Up above you can see my code. Thanks for any other options that you may think of.
  4. Where is my "Progr" return value? This is not my first day using php but I don't code in the language that often. I don't understand why my dynamic variable is not returned in AJAX GET? Essentially, I need to give the client a simple UI so that they can copy files to a printer and I wanted to provide a little unfiltered feedback so they knew whether operation was a success. My feedback was just going to be output of exec() function though cleaned up slightly (perhaps replace line breaks with html break tags). PHP version is 5.2.17.17 and cannot be upgraded. Web Server Apache. PHP dumbed down code: exec("LoadZPL_PURL.bat", $output); $results = implode("|", $output); $results = 'BEFORE'.substr($results, 4, 5).'AFTER'; echo "$results"; Results when run from command prompt give expected results of "BEFOREProgrAFTER". I just grabbed the substring here for a simple test, so that carriage returns and escape characters don't come into play. Results viewed in fiddler2 only give the following. Where is my "Progr"? HTTP/1.1 200 OK Content-Type: text/html Server: Microsoft-IIS/7.5 X-Powered-By: PHP/5.2.17 X-Powered-By: ASP.NET Date: Sun, 19 Oct 2014 18:58:35 GMT Connection: close Content-Length: 11 BEFOREAFTER I can post the AJAX code if really needed, I don't think issue resides here per fiddler2 trace, but here is fiddler2 request though I removed ip and a few client specific directory names. I haven't had problems with http requests in the past though I have never used in this fashion as I usually return record(s) from a table. GET http://x.x.x.179/custom/abc/reupload/LoadPrinterGraphic.php?&param1=document.getElementById(uncShare').value&param2=0.31039151530034853 HTTP/1.1 Accept: */* Accept-Language: en-us Referer: http://x.x.x.179/custom/abc/reupload/abc_populate_printer_purolator.php Accept-Encoding: gzip, deflate User-Agent: Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0) Host: x.x.x.179 DNT: 1 Connection: Keep-Alive Cookie: PHPSESSID=0e4c2a01916297affd1df9e737283889 I dumbed down bat file for replication purposes. Bat file currently contains: copy plogo.grf plogo2.grf
  5. I am trying to build a website, where: 1) User logs in (UserA) 2) Inserting a name in the search box and pressing "Search", a list of all users matching that name is shown 3) The user selects a user (UserB) from that list (among several results) 4) By selecting the user (UserB) , a message box appears to insert text 5) The user(UserA) types the message 6) The user(UserA) presses the SUBMIT button and sends the message to the other user(UserB) The problem i face is how to pass the variables from my PHP script to the JavaScript script. Its easy for me to get the values of input fiedls, select fields or any other DOM element value. But if the value i need to pass to Javascript file to perform an AJAX call isnt inside a DOM element, how do i do it? For example, for me to determine the user that will send the message (userA), i will need several data. This data, i have them inside the PHP script as variables, but dont know how to pass them to Javascript file. Getting the data from the URL, or from a hidden input field or any other DOM element, is a solution, but i want to know the way that is safer and better. To summarize: -->[pass necessary data from PHP to JavaScript file]-->[perform an AJAX call] --> [return data to PHP Script] How do i do it? Thanks in advance.
  6. Hey guys, i'm new to this site and would need some help with coding. So i'm making a car part website which should has brand/model search. It's a dropdown search which will get the brand / model from database and should display all the parts for that exact model, from folder. Database structure which i have is id, master, name. ( Here's some pictures to clear out what i'm doing. http://imgur.com/a/7XwVd ) So the problem is that it does not get the images from folder named ex: *_audi_a3.jpg. And link to codes what have been written already. Parts.php: http://pastebin.com/q6vdypge Update.php: http://pastebin.com/DymhGQ17 Search_images.php: http://pastebin.com/LF5Q0i8f Core.js: http://pastebin.com/bgc0y4TS I don't know what's wrong with it sadly. One thing i noticed when i used firebug it gives error on category when searching error:true. Hope you guys understand what i mean here, and also all help is appreciated. And move this post if it's in wrong place. Thanks!
  7. Hello all, I feel pretty good that I got my AJAX filter working properly. But it still needs some help. Now I am returning the content with Ajax that I want from the search filter of dropdown option (keep in mind there are several options to filter by). But the content returned is often to much to fit on one page - so I need to paginate the successfully returned html from my AJAX call. Here is where I get stumped. Do I setup a normal page nav outside the AJAX area? </div><!-- AJAX return container--> <nav class="pagenav"> <ul id="pag-link"> <li class="old"><?php next_posts_link('« Older Sermons', $sermons_query->max_num_pages) ?></li> <li class="new"><?php previous_posts_link('Newer Sermons »', $sermons_query->max_num_pages) ?></li> </ul> </nav> IF so, how do I update the links info? or do I keep the page nav inside the AJAX area but use some custom code to retrieve the proper link? (I tried using the normal wordpress page nav functions in my php function but they provide the url of the page that the php function is on, not the actual page being viewed). Do I need to make a separate AJAX call to a function that just builds my links? or is there a way to do it with my main call? Here is my AJAX call: //Listen for the menu's to change except the main filter_by dropdown var ids = ['filter_preacher_dropdown', 'filter_sort_by_dropdown', 'filter_per_page_dropdown', 'filter_series_dropdown', 'filter_service_dropdown', 'filter_tag_dropdown', 'filter_book_dropdown', 'filter_year_dropdown']; $('#' + ids.join(',#')).change(function(e) { var pt = [ "preacher","series","service" ]; if($.inArray(this.name, pt)!==-1){ var mk = this.name; var mv = $(this).val(); var ppp = $("#filter_per_page_dropdown").val(); var ob = $("#filter_sort_by_dropdown").val(); var data = { action: 'filter_sermons', meta_key: mk, meta_value: mv, posts_per_page: ppp }; $.post(mbsb_ajaxurl, data, function(response) { $('#sermonlists').fadeOut('slow', function() { $(this).html(response) }).fadeIn('slow'); }); } and here is my php function (slightly paired down for viewing ease): //ajax for sermons filter add_action('wp_ajax_filter_sermons', 'check_ajax'); add_action('wp_ajax_nopriv_filter_sermons', 'check_ajax'); function check_ajax() { global $wpdb, $paged, $max_num_pages; //check if filter is on post_type if($_POST['meta_key']){ $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; $mk = '"'.$_POST['meta_key'].'"'; $mv = intval($_POST['meta_value']); $ppp = intval($_POST['posts_per_page']); $offset = ($paged - 1) * $ppp; $sermons = $wpdb->get_results("SELECT SQL_CALC_FOUND_ROWS sermons.* FROM {$wpdb->prefix}posts AS sermons, {$wpdb->prefix}postmeta WHERE meta_key = {$mk} AND meta_value = {$mv} AND sermons.ID = {$wpdb->prefix}postmeta.post_id LIMIT {$offset}, {$ppp}", OBJECT); $sql_posts_total = $wpdb->get_var( "SELECT FOUND_ROWS();" ); $max_num_pages = ceil($sql_posts_total / $ppp); }elseif($_POST['name']){ //another custom query }elseif ($_POST['book_number']){ //another custom query } $posts = get_posts(); // returns posts in an array if($sermons) { global $post; foreach ($sermons as $post){ setup_postdata($post); //custom query info returned here } //Would the Pagination for the AJAXED content go here? }else{ ?> <h2 class="center">Not Found</h2> <p class="center">Sorry, but you are looking for something that isn't here.</p> <?php } die(); }
  8. I'm trying to pass php select option value to another page through url.but it's not working.please help me. member.php <?php mysql_connect("localhost","root","") or die(mysql_error()); mysql_select_db("nordfxlk_member")or die(mysql_error()); $result = mysql_query("SELECT id,ugroup FROM ugroups"); ?> <select name='group' id='group' > <?php while ($line = mysql_fetch_array($result)) { echo '<option value=' . $line['ugroup'] . '>' . $line['ugroup'] . '</option>'; }?> </select> <a href="db_sql/add_group.php?ugroup=<?php echo $line['ugroup'] ;?>"> click</a> add_group.php include('../limoconfig.php'); if(!isset($_SESSION['adminuserid']) ) { header('Location:../index.php'); } else { $ugroup = $_GET['ugroup']; /*$id = $_GET['id'];*/ $acc_status = "update users set ugroup='".$ugroup."' where id=1931"; echo $acc_status; $rate = db::getInstance()->exec($acc_status); header('Location:../test.php'); } }
  9. When I click on the letter of the alphabet on my form page, it will bring up the results of my query. I got this part working. The next part is to be able to click on any of the populated results and have it autofill my form with organization, first name, last name, email address and phone number. I know that I need to use Ajax and jQuery to accomplish this. Here is my html <!-- Letter Search --> <div class="searchBox span12"> <h3>Choose the First Letter of the Person's Last Name</h3> <ul> <li class="alphabets" id="A"><a href="?by=A">A</a></li> <li class="alphabets" id="B"><a href="?by=B">B</a></li> <li class="alphabets" id="C"><a href="?by=C">C</a></li> <li class="alphabets" id="D"><a href="?by=D">D</a></li> <li class="alphabets" id="E"><a href="?by=E">E</a></li> <li class="alphabets" id="F"><a href="?by=F">F</a></li> <li class="alphabets" id="G"><a href="?by=G">G</a></li> <li class="alphabets" id="H"><a href="?by=H">H</a></li> <li class="alphabets" id="I"><a href="?by=I">I</a></li> <li class="alphabets" id="J"><a href="?by=J">J</a></li> <li class="alphabets" id="K"><a href="?by=K">K</a></li> <li class="alphabets" id="L"><a href="?by=L">L</a></li> <li class="alphabets" id="M"><a href="?by=M">M</a></li> <li class="alphabets" id="N"><a href="?by=N">N</a></li> <li class="alphabets" id="O"><a href="?by=O">O</a></li> <li class="alphabets" id="P"><a href="?by=P">P</a></li> <li class="alphabets" id="Q"><a href="?by=Q">Q</a></li> <li class="alphabets" id="R"><a href="?by=R">R</a></li> <li class="alphabets" id="S"><a href="?by=S">S</a></li> <li class="alphabets" id="T"><a href="?by=T">T</a></li> <li class="alphabets" id="U"><a href="?by=U">U</a></li> <li class="alphabets" id="V"><a href="?by=V">V</a></li> <li class="alphabets" id="W"><a href="?by=W">W</a></li> <li class="alphabets" id="X"><a href="?by=X">X</a></li> <li class="alphabets" id="Y"><a href="?by=Y">Y</a></li> <li class="alphabets" id="Z"><a href="?by=Z">Z</a></li> </ul> <? include('search.php'); ?> </div> <hr style="color:#ccc; margin-bottom:20px;" /> <!-- Main Form --> <div id="mainForm"> <form method="post" id="icsForm" class="searchBox span12"> <div id="col1" class"span6"> <h3>Contact Information</h3> <label>Church / Organization:</label><input type="text" name="organization" id="organization" class="span6 upright" /><br /> <label>First Name:</label><input type="text" name="firstName" id="firstName" class="span6 upright" /> <label>Last Name:</label><input type="text" name="lastName" id="lastName" class="span6 left upright" /> <label>Email Address:</label><input type="text" name="email" id="email" class="span6 left upright" /> <label>Phone Number:</label><input type="text" name="phone" id="phone" class="span6 left upright" /> </div> </div> Here is my php if(preg_match("/^[A-Z | a-z]+/", $_POST['name'])){ $name=$_POST['name']; } if(isset($_GET['by'])){ $letter=$_GET['by']; //query to sort by last name $sql="SELECT contact_id, first_name, last_name, church_org, email_address, phone_number FROM ics_data WHERE last_name LIKE '$letter%' ORDER BY last_name ASC"; //run the query against the mysql query function $result=mysql_query($sql); //count results $numrows=mysql_num_rows($result); echo "<p>" .$numrows . " results found for " . $letter . "</p>"; //Create while loop and loop through result set while($row=mysql_fetch_array($result)){ $first_name=$row['first_name']; $last_name=$row['last_name']; $church_org=$row['church_org']; $email_address=$row['email_address']; $phone_number=$row['phone_number']; $contact_id=$row['contact_id']; //display the result of the array echo "<div id=\"search-results\">"; echo "<ul class=\"letter-results\">\n"; echo "<li class=\"result-row\">" . "<a href=\"#\" class=\"testclass\">" .$first_name . " " .$last_name . "". ", " ."" .$church_org ."</a></li>\n"; echo "</ul>"; echo "</div>"; } } Here is my Javascript file (Ajax) $(document).ready( function() { function formfill() { var organization = $('#organization').val(); var firstname = $('#firstname').val(); var lastname = $('#lastname').val(); var email = $('#email').val(); var phone = $('#phone').val(); $.ajax ({ method: "GET", url: "search.php", dataType: 'json', data: { organization:organization, firstname:firstname, lastname:lastname, email:email, phone:phone }, type: "POST", success: function(data) { $organization $firstname $lastname $email $phone }, failure: function() { alert('fail!'); } }); } I know that I do not have a reference yet to JSON in my php file and that it is needed. I'm not solid on the Ajax part. That is the part that is tripping me up. I know that I need to make the form autofill when clicking on a specific result returned from my query... but i'm not sure how to do that. Thank you in advance for any help or advice you can give!! I am relatively new to programming. Hopefully I posted this in the right forum as a lot of these technologies overlap.
  10. hello all, I am trying to use ajax, to filter my custom post_type using a dropdown (several actually, but just working on one now). when I check the console.log for my two variables the log returns the values that I need to pass into my function check_ajax() I am using to do the filtering, but when I check the log for the data array it comes up with 0? Here is my Jquery code: //Listen for the menu's to change except the main filter_by dropdown var ids = ['filter_preacher_dropdown', 'filter_sort_by_dropdown', 'filter_per_page_dropdown', 'filter_series_dropdown', 'filter_tag_dropdown', 'filter_book_dropdown', 'filter_year_dropdown']; $('#' + ids.join(',#')).change(function() { var sermonForm = $("#sermon_filter_form"); var myForm = $(this).closest("form"); var meta_key = this.name; var meta_value = $(this).val(); var current_selection = $(this); var ajaxLoader = '<div class="loading_img"></div>'; $(this).after(ajaxLoader); $.ajax ( { type: "POST", url: ajax_object.ajax_url, data: { 'action': 'filter_sermons', 'meta_key': meta_key, 'meta_value': meta_value, }, dataType: 'JSON', success:function(data){ console.log(data); } } ); }); and here is my function.php code: //ajax for sermons filter add_action('wp_ajax_filter_sermons', 'check_ajax'); add_action('wp_ajax_nopriv_filter_sermons', 'check_ajax'); } /** * Sets up custom query for AJAX to filter * */ function my_sermon_query($meta_key, $meta_value) { return new WP_Query( array( 'meta_key' => $meta_key, 'meta_value' => $meta_value, 'post_type' => 'mbsb_sermon' ) ); } function check_ajax() { $mk = intval($_POST['meta_key']); $mv = intval($_POST['meta_value']); $query = my_sermon_query($mk, $mv); echo json_encode($query); die(); } Any ideas what I am missing/doing wrong? Thanks,
  11. So I have an AJAX call that I'm using to POST 1 variable to a PHP script I have on a separate server. The PHP takes this variable and returns data based off of what the variable is. This works on all browsers except IE9 and below. IE9 returns data but it's an error saying the variable is missing which to me shows that it isn't sending the data. Below I have the AJAX call I'm making: (function (jQ) { var inviteID = '00000000000'; jQ.ajax({ url: 'www.example.com/test.php', type: 'POST', dataType: 'json', cache: false, data: { classID: inviteID }, error: function (data, status, error) { jQ('.statusField').append('Failure: ' + data + status + error); }, success: function (data, status, error) { jQ('.statusField').append('Success: ' + data); } }); })(jQuery); And below I have the PHP script that's being used: <?php //first POST to grab token function runPost($classID) { $postdata = array( 'username' => 'username', 'password' => 'password' ); //open connection $ch = curl_init(); //set the url, POST data curl_setopt($ch, CURLOPT_URL, "https://www.example.com/login"); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($postdata)); curl_setopt($ch, CURLOPT_USERAGENT, 'example'); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json')); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //execute post $result = curl_exec($ch); //close connection curl_close($ch); list($message, $time, $token, $userID) = split(',', $result); list($one, $two, $three, $four, $five) = split('\"', $token); $four = json_encode($four); $four = str_replace('"','',$four); $secondaryPostData = array( 'token' => $four, 'data' => array( 'invitationID' => $classID )); //open connection $chu = curl_init(); //set the url, POST data curl_setopt($chu, CURLOPT_URL, "https://www.example.com/classID"); curl_setopt($chu, CURLOPT_POST, 1); curl_setopt($chu, CURLOPT_POSTFIELDS, json_encode($secondaryPostData)); curl_setopt($chu, CURLOPT_USERAGENT, 'example'); curl_setopt($chu, CURLOPT_HTTPHEADER, array('Content-Type: application/json')); curl_setopt($chu, CURLOPT_RETURNTRANSFER, 1); //execute post $secondResult = curl_exec($chu); //close connection curl_close($chu); return json_encode($secondResult); } //Grab classID from javascript echo runPost(trim($_POST['classID'])); ?> Again, this works fine in everything except IE. I've tried using just $.post and even XDomainRequest() and get the same result. The network console in IE shows that the Request body does have the classID in it, but I'm guessing it's just not sending the data to the PHP script. I don't know if I'm missing something that IE needs to send this to the PHP script but any help with this would be GREATLY appreciated.
  12. haw can I make a commit script , when I click on button the commit inserted in the table and browsed immediately without refresh the page , like Facebook commits ?
  13. I have this first example for ajax but it dosent work is there importance for import jquery librery? <!doctype html> <html> <head> <meta charset="utf-8"> <title>Untitled Document</title> </head> <body> <div id="commit"> </div> <script type="text/javascript"> function getinfo () { var xmlhttp; if(window.XMLHttpRequest) xmlhttp = new XMLHttpRequest(); else xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); xmlhttp.onreadystatechange = function () { if(xmlhttp.readyState ==4 & xmlhttp.status == 200) document.getElementById("commit").innerHTML =xmlhttp.responeText; } xmlhttp.open("GET","info.php",true); xmlhttp.send(); } </script> <button type="button" onClick="getinfo()">send</button> </body> </html>
  14. I found a tutorial on youtube that would allow me to create a calendar of events. We have the calendar html page: This includes the onload="initialCalendar();" function <script type="text/javascript"> /* <![CDATA[ */ function initialCalendar(){ var hr = new XMLHttpRequest(); var url = "calendar/calendar_start.php"; var currentTime = new Date (); var month = currentTime.getMonth() + 1; var year = currentTime.getFullYear(); showmonth = month; showyear = year; var vars= "showmonth="+showmonth+"&showyear="+showyear; hr.open("POST", url, true); hr.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); hr.onreadystatechange = function() { if (hr.readyState == 4 && hr.status == 200) { var return_data = hr.responseText; document.getElementById("showCalendar").innerHTML = return_data; } } hr.send(vars); document.getElementById("showCalendar"). innerHTML = "processing..."; } /* ]]> */ </script> <script type="text/javascript"> /* <![CDATA[ */ function next_month() { var nextmonth = showmonth + 1; if(nextmonth > 12) { nextmonth = 1; showyear = showyear+1; } showmonth = nextmonth; var hr = new XMLHttpRequest(); var url = "calendar/calendar_start.php"; var vars= "showmonth="+showmonth+"&showyear="+showyear; hr.open("POST", url, true); hr.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); hr.onreadystatechange = function() { if (hr.readyState == 4 && hr.status == 200) { var return_data = hr.responseText; document.getElementById("showCalendar").innerHTML = return_data; } } hr.send(vars); document.getElementById("showCalendar"). innerHTML = "processing..."; } /* ]]> */ </script> <script type="text/javascript"> /* <![CDATA[ */ function last_month() { var lastmonth = showmonth - 1; if(lastmonth < 1 ) { lastmonth = 12; showyear = showyear-1; } showmonth = lastmonth; var hr = new XMLHttpRequest(); var url = "calendar/calendar_start.php"; var vars= "showmonth="+showmonth+"&showyear="+showyear; hr.open("POST", url, true); hr.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); hr.onreadystatechange = function() { if (hr.readyState == 4 && hr.status == 200) { var return_data = hr.responseText; document.getElementById("showCalendar").innerHTML = return_data; } } hr.send(vars); document.getElementById("showCalendar"). innerHTML = "processing..."; } /* ]]> */ </script> <script type="text/javascript"> /* <![CDATA[ */ function overlay() { el = document.getElementById("overlay"); el.style.display = (el.style.display == "block") ? "none" : "block"; el = document.getElementById("events"); el.style.display = (el.style.display == "block") ? "none" : "block"; el = document.getElementById("eventsBody"); el.style.display = (el.style.display == "block") ? "none" : "block"; } /* ]]> */ </script> <script type="text/javascript"> /* <![CDATA[ */ function show_details(theId) { var deets = (theId.id); el = document.getElementById("overlay"); el.style.display = (el.style.display == "block") ? "none" : "block"; el = document.getElementById("events"); el.style.display = (el.style.display == "block") ? "none" : "block"; var hr = new XMLHttpRequest(); var url = "calendar/events_fns.php"; var vars = "deets="+deets; hr.open("POST", url, true); hr.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); hr.onreadystatechange= function() { if (hr.readyState == 4 && hr.status == 200) { var return_data = hr.responseText; document.getElementById("events").innerHTML = return_data; } } hr.send(vars); document.get ElementById("events").innerHTML = "processing..."; } /* ]]> */ </script> The script to show to actual calendar is called from here.... calendar_start.php <?php $showmonth = $_POST['showmonth']; $showyear = $_POST['showyear']; $showmonth= preg_replace('#[^0-9]#i', '', $showmonth); $showyear= preg_replace('#[^0-9]#i', '', $showyear); $day_count = cal_days_in_month(CAL_GREGORIAN, $showmonth, $showyear); $pre_days = date('w', mktime(0,0,0, $showmonth, 1, $showyear)); $post_days = (6-(date('w', mktime(0,0,0, $showmonth, $day_count, $showyear)))); echo '<div id="calendar-wrap">'; echo '<div class="title-bar">'; echo '<div class="previous-month"><input name="button" type="submit" value="Previous Month" onClick="javascript:last_month();"></div>'; echo '<div class="show-month">' . date('F', mktime(0, 0, 0, $showmonth)) . ' ' . $showyear . '</div>'; echo '<div class="next-month"><input name="button" type="submit" value="Next Month" onClick="javascript:next_month();"></div>'; echo '</div>'; echo '<div class="week_days">'; echo '<div class="days-of-week">Sun</div>'; echo '<div class="days-of-week">Mon</div>'; echo '<div class="days-of-week">Tues</div>'; echo '<div class="days-of-week">Wed</div>'; echo '<div class="days-of-week">Thur</div>'; echo '<div class="days-of-week">Fri</div>'; echo '<div class="days-of-week">Sat</div>'; echo '<div class="clear"></div>'; echo '</div>'; //Previous Month days if ($pre_days != 0) { for($i=1; $i<=$pre_days; $i++) { echo '<div class="non-cal-days"></div>'; } } //Current Month Days $conn = mysqli_connect('Databaseconnection Things') or die ("Could not connect to the Database"); for ($i=1; $i<= $day_count; $i++) { //get event logic $date = $i.'/'.$showmonth.'/'.$showyear; $query = mysqli_query('SELECT calid FROM calendar WHERE caldate = "'.$date.'"') or trigger_error("Query Failed! SQL: $sql - Error: ".mysqli_error($query), E_USER_ERROR); $num_rows = mysqli_num_rows($conn, $query); if($num_rows > 0) { $event = "<input name='$date' type='submit' value='Details' id='$date' onClick='javascript:show_details(this);'>"; } echo '<div class="cal-days">'; echo '<div class="day-heading">' . $i . '</div>'; if($num_rows != 0) { echo "<div class='opening'><br/>" . $event . "</div>";} echo '</div>'; } //Next Months Days if ($post_days !=0) { for($i=1; $i<=$post_days; $i++) { echo '<div class="non-cal-days"></div>'; } } echo '</div>'; ?> And events_fns. <?php $deets = $_POST['deets']; $deets = preg_replace('#[^0-9/]#i', '', $deets); $conn = mysqli_connect("Database Connection") or die ("Could not connect to the Database"); $events = ''; $query = mysqli_query('SELECT calid FROM calendar WHERE caldate = "'.$deets.'"') or die ("Error:".mysqli_errno()); //echo "$query"; $num_rows=0; if ($result = mysqli_query($query,$conn)) { $num_rows = mysqli_num_rows($result); } if ($num_rows > 0) { $events .= '<div id="eventsControl"><button onMouseDown="overlay()">Close</button><br /><br />'.$deets.'<br /><br /></div>'; while ($row = mysqli_fetch_array($query)) { $title = $row['eventtitle']; $desc = $row['description']; $loc = $row['eventlocation']; $events .='<div id="eventsBody">'.$title.'<br />'.$desc.'<br />'.$loc.'<hr /></div>'; } } echo $events; ?> I have posted all the code so you can see how it fits together ect ect however the issue I am having is an error message that repeats across the page. it reads: Warning: mysqli_error() expects parameter 1 to be mysqli, boolean given in /home/sites/agile-cms.co.uk/public_html/mfcf/calendar/calendar_start.php on line 49 Fatal error: Query Failed! SQL: - Error: in /home/sites/agile-cms.co.uk/public_html/mfcf/calendar/calendar_start.php on line 49 for ($i=1; $i<= $day_count; $i++) { //get event logic $date = $i.'/'.$showmonth.'/'.$showyear; $query = mysqli_query($conn, 'SELECT eventid FROM events WHERE eventdate = "'.$date.'"') or trigger_error("Query Failed! SQL: $sql - Error: ".mysqli_error($query), E_USER_ERROR); $num_rows = mysqli_num_rows($query); if($num_rows > 0) { $event = "<input name='$date' type='submit' value='Details' id='$date' onClick='javascript:show_details(this);'>"; } echo '<div class="cal-days">'; echo '<div class="day-heading">' . $i . '</div>'; if($num_rows != 0) { echo "<div class='opening'><br/>" . $event . "</div>";} echo '</div>'; } I think I have missed something being so close to it and I think I need an outside P.O.V to look at it and point me in the right direction.... Any help would be much appreciated....
  15. Hello, I want to grab some data from this site, using a script. But I am stuck right at the beginning. If you go to the site, you can make a selection with the drop-down-boxes and get some output. For example if you select (left side: text on page in dutch / right side: translation in english): Selecteer competitienaam: Najaarscompetitie 2014 Select league name: Autumn League 2014 Selecteer competitiegroep: Eredivisie dames Select league group: Eredivisie ladies Selecteer weergave: Programma (incl. uitslagen en stand) Select view: Program (including results and position) Optioneel poule filter: De Treffers R Optional group filter: De Treffers R Selecteer poule(s): Eredivisie - Poule A Select group(s): Premier League - Group A I want to grab the output you get after making all the selections. When I look at the webbrowser's page source the selections (drop-down-boxes) are inside an iframe from another domain: <iframe src="http://www.nttb-competitie.nl/" width="100%" height="1200" scrolling="yes" frameborder="0" name="NTTB_Competitie"></iframe> I figured out: First, the script gets url: http://www.nttb-competitie.nl/selectie.php?anr=0 And after last selection it gets url: http://www.nttb-competitie.nl/web_programma.php?reset=0&pidString=1009267&sc=0&vastgesteldeAfdelingsnr=0&cnid=10085&cid=10704&view=programma&pf=1269&pid=1009267 My problem is when I copy those URL's in a webbroser 's address bar, I get a page with only the words: Ongeldige aanroep! Which means "Invalid Call!" So my question is: How can I grab the data instead of this stupid message? Is it even possible or is it somehow protected? Please help!
  16. So currently I have 2 files that pretty much does the same thing but connects to 2 different tables. I sort of want to merge it together to save file space and make everything more efficient: caseprice.php <?php $q = intval($_GET['q']); $con = mysqli_connect('localhost','root','','test'); if (!$con) { die('Could not connect: ' . mysqli_error($con)); } mysqli_select_db($con,"compcase"); $sql="SELECT * FROM compcase WHERE id = '".$q."'"; $result = mysqli_query($con,$sql); while($row = mysqli_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['case_price'] . "</td>"; echo "</tr>"; } echo "</table>"; mysqli_close($con); ?> caselightprice.php <?php $q = intval($_GET['q']); $con = mysqli_connect('localhost','root','','test'); if (!$con) { die('Could not connect: ' . mysqli_error($con)); } mysqli_select_db($con,"complight"); $sql="SELECT * FROM complight WHERE id = '".$q."'"; $result = mysqli_query($con,$sql); while($row = mysqli_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['caselight_price'] . "</td>"; echo "</tr>"; } echo "</table>"; mysqli_close($con); ?> also how can I use all this to display a sub total on my page when the radio buttons are pressed? I have it so the price shows I just cant seem to add them both up: index.php <script> //CASE PRICE// function casePrice(str) { if (str=="") { document.getElementById("txtHint").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("txtHint").innerHTML=xmlhttp.responseText; } } xmlhttp.open("GET","caseprice.php?q="+str,true); xmlhttp.send(); } //CASE PRICE// //CASE LIGHT PRICE// function caselightPrice(str) { if (str=="") { document.getElementById("txtHint").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("txtHint").innerHTML=xmlhttp.responseText; } } xmlhttp.open("GET","caselightprice.php?q="+str,true); xmlhttp.send(); } //CASE LIGHT PRICE// </script> <Input type = 'Radio' Name ='compcase' onchange="casePrice(this.value)" value= '1' />NZXT Phantom Enthusiast USB3.0 Full Tower Case - White <br /> <Input type = 'Radio' Name ='compcase' onchange="casePrice(this.value)" value= '2' />Corsair Obsidian 750D Large Tower Case Black <br /> <Input type = 'Radio' Name ='compcase' onchange="casePrice(this.value)" value= '3' />Cooler Master CM Storm Trooper Black Full Tower Gaming Case <br /><br /> <Input type = 'Radio' Name ='caselight' onchange="caselightPrice(this.value)" value= '1' />Red<br /> <Input type = 'Radio' Name ='caselight' onchange="caselightPrice(this.value)" value= '2' />Green <br /><br /> <div id="txtHint"><b>Processor listed here</b></div> <div id="txtTest"><b>Processor listed here</b></div> as you can see, the price is displaying separately. Can I somehow calculate it as a subtotal instead of separate totals? Thanks for any help.
  17. my name is fairooj and ama new to php and jquery. i have a proplam. i want your help. <script type="text/javascript"> var count = 0; $(function(){ $('p#add_field').click(function(){ count += 1; $('#container').append( '<strong>Link #' + count + '</strong><br />' + '<input id="field_' + count + '" name="fields[]' + '" type="text" />' + '<input id="code_' + count + '" name="code[]' + '" type="text" /><br />' ); }); }); </script> this is my script to add more text boxes.. and this is ma code for insert it to database <?php //If form was submitted if (isset($_POST['btnSubmit'])) { //create instance of database class $db = new mysqldb(); $db->select_db(); //Insert static values into users table $sql_user = sprintf("INSERT INTO users (Username, Password) VALUES ('%s','%s')", mysql_real_escape_string($_POST['name']), mysql_real_escape_string($_POST['password']) ); $result_user = $db->query($sql_user); //Check if user has actually added additional fields to prevent a php error if ($_POST['fields']) { //get last inserted userid $inserted_user_id = $db->last_insert_id(); //Loop through added fields foreach ( $_POST['fields'] as $key=>$value ) { //Insert into websites table $sql_website = sprintf("INSERT INTO websites (Website_URL, web_Link) VALUES ('%s', '%s')", mysql_real_escape_string($value), mysql_real_escape_string($value) ); $result_website = $db->query($sql_website); $inserted_website_id = $db->last_insert_id(); //Insert into users_websites_link table $sql_users_website = sprintf("INSERT INTO users_websites_link (UserID, WebsiteID) VALUES ('%s','%s')", mysql_real_escape_string($inserted_user_id), mysql_real_escape_string($inserted_website_id) ); $result_users_website = $db->query($sql_users_website); } } else { ?> the problame web_Link sql table is repeating Website_URL table value.... plz how can i solve this am waiting for your reply..
  18. We are not getting the error message, that should match with the error_code We sending the code and the object contains the error/success message to show!!! This seems to almost works. It is part of Jquery Validations, once the field or submit button is clicked. It looks for error on field. then Enter the Ajax Funciton which is to parse the error code and the out put the error message which is coming from json object. The code is not returning the error message, on line (alert(data)) Produces [object,object] not actual data string. The error message does not return. Please help, is there something work with our ajax request //*new style for error Messages*/ //var jsonErrors = frontEndErrorCodes; //JC wrote. //MG added. To retrieve Front-end error codes as well as //Backend Error Codes function _getErrorMessage(errorCode, message){ var errorData = JSON.stringify({error_code: errorCode, message: message}); var dataString = $.parseJSON(errorData); $.ajax({ url: './retrieveErrorMessage.json', type: 'POST', data: dataString, dataType: "json", contentType: 'application/json', mimeType: 'application/json', success: function(data) { //data = $.parseJSON(data); alert(data); $('.error.message').contents().find('h4').text(data.message); // if(!vanillaeGift.notify.called) { // $('.error.message').contents().find('h4').text(error.text()); // vanillaeGift.notify.showNotification(".error"); // } //Bolt Notification Called and Enabled here if(BoltNotify == true){ var spanerrorgen = $('.error.message').contents().find('h4').html(data.message); VanillaReload.notify.showNotification(".error"); }else if(BoltNotify == true && multipleNotice ==true ){ var spanerrorgen = $('.error.message').contents().find('h4').html(data.message); VanillaReload.notify.showNotification(".error").append(spanerrorgen); }else{ var spanerrorgen = $("<span/>").css("color","#D00").hide().addClass("error").html(data.message); $fieldref.parent().append(spanerrorgen) spanerrorgen.show("fast"); } }, error: function(data) { //data = $.parseJSON(data); alert(data); $('.error.message').contents().find('h4').text(data.message); // if(!vanillaeGift.notify.called) { // $('.error.message').contents().find('h4').text(error.text()); // vanillaeGift.notify.showNotification(".error"); // } //Bolt Notification Called and Enabled here if(BoltNotify == true){ var spanerrorgen = $('.error.message').contents().find('h4').html(data.message); VanillaReload.notify.showNotification(".error"); }else if(BoltNotify == true && multipleNotice == true ){ var spanerrorgen = $('.error.message').contents().find('h4').html(data.message); VanillaReload.notify.showNotification(".error").append(spanerrorgen); }else{ var spanerrorgen = $("<span/>").css("color","#D00").hide().addClass("error").html(data.message); $fieldref.parent().append(spanerrorgen) spanerrorgen.show("fast"); } }, fail: function(jqXHR, textStatus) { alert(data); if(textStatus == "parsererror"){ return "We're Sorry a system error occured"; } } }); }
  19. Right now I redirect to index page after I delete a record. However I am looking to make it so that I can delete a record without redirecting the page. I know this can be accomplised using Ajax. I have spent countless hours before trying to make it work, but it did not work. So here is a basic setup I created. Can you please update it with ajax code so that I can see how it's done properly? <!DOCTYPE HTML> <html lang="en"> <head> <meta charset="UTF-8"> <title>Home Page</title> </head> <body> <div class="record" > <a href="record.php?id=<?php echo $record_id ?>"><?php echo $record_name; ?></a> <div class="delete-record"> <a href="delete.php">Delete Record</a> </div> </div> </body> </html>
  20. Hello, I am building an online game(users make a character and move on a map and so on...) All user data is stored in a mySQL database and I want the users to interact in real-time, but there can be a 1-3 second delay between the communication, but not exceed 3 seconds even if 500 players are playing at the same time. But for the purpose of the question let's say the users can only chat between one another, if I'll have a solution for that then I can use the same method for more parts of the game. I can't use websockets because my webhost doesn't support it( I don't want to use pusher.com). I know I can make real-time apps with ajax long polling, but I think that with 500 players playing at the same time it's not the best solution. So, finally: How can I make user interaction as close as possible to a real-time game? (Without too much load on the hosting server) (I am sorry if some of my terms are not correct - I am just getting back to coding after a long time...)
  21. Hello I am using JSONP as dataType on my AJAX, but there's an incident that a Transaction was successfully complete but a PHP error text occured while trying pass the data. E.g. SMTP Error: Data not accepted. Unable to send Mail: SMTP Error: Data not accepted.<p>SMTP server error: Requested action aborted: This mail account has sent too many messages in a short amount of time. Please try later. </p> jQuery111001592713373247534_1407318091484({"result":11308,"err":"no"}) There was an unexpected error happen, SMTP Error. So in my javascript jquery ajax the response will go to .error(function(xhr,status,error){ console.log(xhr); }); But the thing here is that the transaction was successfully complete. So how do I tell the to the client side about the transaction process and the error happen?
  22. The like/dislike button script found here: http://wcetdesigns.com/tutorials/demos/like-dislike-button.html works perfectly for what I am trying to do on my webpage. The issue I am having is I can connect to one table perfect but the script breaks if I try to add another set of like/dislike buttons that connects to another table. How can I add 2 additional like/dislike button sets that can connect to 2 addtional tables in my database. For example Topic name (like/dislike button set that connects to table 1) Messages (like/dislike button set that connect to table 2) Message Replies (like/dislike button set that connects to table 3) any help would be appreciated. Thanks
  23. Hi, I've seen this done, and I thought it would be simple now that I am starting to understand ajax but I can't figure it out. I am using jQuery ajax via wordpress. I can click a button, call a php function and use the value returned from php to populate the textbox. Ok, great! but I want to run a rather lengthy procedure, and while it's running I would like it to record it's status in a multi-line text box as sort of a debugger ( and to pass the time while waiting ) How can I accomplish this? I've googled but I must not be using the correct words to search.
  24. What I am trying to do is to submit as POST values to database_write.php, from within the while statement. What is happening is I am getting the second row of data every time I change the primary button. Currently database_write.php is just doing print_r($_POST), And my array is always the same, no matter which select box I choose from. How can I get the values to be associated with the row I am currently changing? Any help would be great, thanks. What I have so far: <table class="table table-bordered table-hover"> <thead> <th>Room Number</th> <th>Primary Caregiver</th> <th>Seconday Caregiver</th> </thead> <tbody class="list"> <?php $sql = 'SELECT alarm_device_id, alarm_description, alarm_device_type, notes FROM alarm_device where notes in (\'MSU\') ORDER BY alarm_description'; $retval = mysql_query( $sql, $con ); if(! $retval ) { die('Could not get data: ' . mysql_error()); } $x=0; while($row = mysql_fetch_array($retval, MYSQL_ASSOC)) { $id = $row['alarm_device_id']; $alarm_description = $row['alarm_description']; echo '<form id="msu_form">'; echo "<tr><td>{$row['alarm_description']}</td>"; echo "<td>"; $query2 = "SELECT alert_device_id,alert_description FROM alert_device WHERE notes = 'MSU'"; $result2 = mysql_query($query2) or die("Error in alarm_device select:" . mysql_error()); $count2 = mysql_num_rows($result2); if($count2 > 0) { //echo '<select name='.$x.'>'; echo '<select id="Primary" name="primary" onchange="doAjaxPost(this)">'; while($row2 = mysql_fetch_array($result2)) { echo "<option value=".$row2['alert_device_id'].">".$row2['alert_description']."</option>"; } echo "</select>"; }else { echo "Please update alert device to this area"; } echo "</td>"; echo "<td>"; $query3 = "SELECT alert_device_id,alert_description FROM alert_device WHERE notes = 'MSU2'"; $result3 = mysql_query($query3) or die("Error in alarm_device select:" . mysql_error()); $count3 = mysql_num_rows($result3); if($count3 > 0) { echo '<select id="Secondary" name="secondary">'; while($row3 = mysql_fetch_array($result3)) { echo "<option value=".$row3['alert_device_id'].">".$row3['alert_description']."</option>"; } echo "</select>"; }else { echo "Please update alert device to this area"; } echo "</td>"; $aid = $id + $x; //echo $aid; //$ad = $alarm_description + $x; echo '<input type="hidden" id="ID" name="ID" value="'.$id.'"/>'; //echo '<input type="hidden" id="desc" name="desc" value="'.$ad.'"/>'; //echo '<td>'."<input type='submit' name='btnupdate' value='UPDATE' /></td>"; //echo '<td><input type="button" value="Ajax Request" onClick="doAjaxPost()"></td>'; echo '</form>'; $x = $x+1; } ?> <script> function doAjaxPost() { // get the form values var primary = $('#Primary').val(); var secondary = $('#Secondary').val(); var hidden = $('#ID').val(); //var desc = $(sel).parent().nextAll('#desc').val(); $.ajax({ type: "POST", url: "functions/database_write.php", data: $('#msu_form').serialize(), //data: "Primary="+primary+"&Hidden="+hidden+"&Secondary="+secondary, success: function(resp){ //we have the response alert("'" + resp + "'"); }, error: function(e){ alert('Error: ' + e); } }); } </script> </tr> </tbody> </table>
  25. I have a working autocomplete which connects to my database using ajax. I am trying to include a function where the user can scroll through the results list using the up/down arrow keys. All of the suggestions I found in google basically broke my autocomplete and yes I've installed the latest Jquery. Also, for some reason the user has to click the upper half of the search result in order for the data to display otherwise it won't register for some reason any ideas about that? Any help would be greatly appreciated. Thanks <script type="text/javascript"> $(function(){ $(".search").keyup(function() { var searchid = $(this).val(); var dataString = 'search='+ searchid; if(searchid!='') { $.ajax({ type: "POST", url: "search.php", data: dataString, cache: false, success: function(html) { $("#result").html(html).show(); } }); }return false; }); jQuery("#result").live("click",function(e){ var $clicked = $(e.target); var $name = $clicked.find('.name').html(); var decoded = $("<div/>").html($name).text(); $('#searchid').val(decoded); var yourLinkHref= $(this).attr('href'); window.location = "mainpage.php?TopicName=" + $name; }); jQuery(document).live("click", function(e) { var $clicked = $(e.target); if (! $clicked.hasClass("search")){ jQuery("#result").fadeOut(); } }); $('#searchid').click(function(){ jQuery("#result").fadeIn(); }); }); </script>
×
×
  • 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.