PHP - Send Div Results Via Ajax
I am creating a library app (personal dev) and have ran into some trouble. I'm very new to Ajax and Php
I have a page named addEntryISBN which shows the results of a user search in a div named #results. I want to post the contents of #results to my database. The contents of #results comes from a page named searchISBN.
What is the most effective way of doing this? My code so far is aas follows;
addEntryISBN.php
$(document).ready(function() { $('form').on('submit', function (e) { e.preventDefault(); $.ajax({ type: 'post', url: 'searchIsbn.php', data: $('form').serialize(), success: function (result) { $('.result').html(result); } }); return true; }); }); <div class="result"</div> Similar TutorialsI am retrieving Google Books info in JSON format and displaying it inside a div. I would like to send the contents of this div (name, title, description) to my database using Ajax.
Currently only the ISBN field sends because I have it declared as a variable. However my question is, how do I send the other fields (name, title, author). How do I declare these also, I'm not sure what format they need to be in etc.
My JS
$(document).ready(function() { $('#submit').click(function(ev) { ev.preventDefault(); var isbn = $('#isbn_search').val(); //get isbn direct from input var url='https://www.googleapis.com/books/v1/volumes?q='+isbn; $.getJSON(url,function(data){ $.each(data.items, function(entryIndex, entry){ var html = '<div class="results well">'; html += '<h3>' + entry.volumeInfo.title + '</h3>'; html += '<div class="author">' + entry.volumeInfo.authors + '</div>'; html += '<div class="description">' + entry.volumeInfo.description + '</div>'; }); }); }); });My Ajax; $.ajax({ type: 'POST', url: 'addIsbnScript.php', data: { 'isbn' : isbn, 'title' : title 'subtitle' : subtitle, 'authors' : authors, 'description' : description }, success: function () { $.growl({ message: " Record added" }); } });Note, if i manually set the vars like below they all do successfully send to my database, so I know my query is working ok var title = "some text", var author = "some text", Var description = "some text"Thanks in advance for any help, newbie here (incase it wasn't obvious!). J Hi, I would like to send a value in a link and request it back in ajax and set it as a variable in php in the same page, can anyone help me here? thanks Hey guys I am having a bit of a hard time understanding how I can fetch data from my SQL table using AJAX and jQuery, I am sorry if this isn't the right place to post this however I usually get great support here.
I am trying to recreate this filter on the right of the page: http://www.autotrade...arch/used/cars/
So basically I have this code to display the whole MySQL table into a list:
<?php while($row = $results->fetch(PDO::FETCH_ASSOC)) { echo ' <div class="listing-container"> <h3 class="model-listing-title clearfix">'.$row["Make"].' '.$row["Model"].' '.$row["Variant"].'</h3> <h3 class="price-listing">£'.number_format($row['Price']).'</h3> </div> <div class="listing-container-spec"> <img src="'.(explode(',', $row["PictureRefs"])[0]).'" class="stock-img-finder"/> <div class="ul-listing-container"> <ul class="overwrite-btstrp-ul"> <li class="diesel-svg list-svg">'.$row["FuelType"].'</li> <li class="saloon-svg list-svg">'.$row["Bodytype"].'</li> <li class="gear-svg list-svg">'.$row["Transmission"].'</li> <li class="color-svg list-svg">'.$row["Colour"].'</li> </ul> </div> <ul class="overwrite-btstrp-ul other-specs-ul h4-style"> <li>Mileage: '.number_format($row["Mileage"]).'</li> <li>Engine size: '.$row["EngineSize"].'cc</li> </ul> <button href="#" class="btn h4-style checked-btn hover-listing-btn"><span class="glyphicon glyphicon-ok"></span> History checked </button> <button href="#" class="btn h4-style more-details-btn hover-listing-btn tst-mre-btn"><span class="glyphicon glyphicon-list"></span> More details </button> <button href="#" class="btn h4-style test-drive-btn hover-listing-btn tst-mre-btn"><span class="test-drive-glyph"></span> Test drive </button> <h4 class="h4-style listing-photos-count"><span class="glyphicon glyphicon-camera"></span> 5 More photos</h4> </div> '; } ?>As you can see I am using a while loop to display the whole contents of the table into lists, this includes vehicle data. I also have this bit of HTML that I will be using as a form to filter the results: <form class="car-finder-container dflt-container"> <h2 class="h2-finder">Car finder</h2> <ul class="toggle-view"> <li class="li-toggle"> <h4 class="h4-finder-toggle">Make<span class="glyphicon glyphicon-plus glyph-plus-toggle"></span></h4> <div class="panel"> <select class="form-control select-box"> <option value="make-any">Make (Any)</option> <option value="two">Two</option> <option value="three">Three</option> <option value="four">Four</option> <option value="five">Five</option> </select> <select class="form-control last-select select-box"> <option value="model-any">Model (Any)</option> <option value="two">Two</option> <option value="three">Three</option> <option value="four">Four</option> <option value="five">Five</option> </select> </div> </li> <li class="li-toggle"> <h4 class="h4-finder-toggle">Body type<span class="glyphicon glyphicon-plus glyph-plus-toggle"></span></h4> <div class="panel"> <input id="four-by-four-checkbox" class="float-checkbox" type="checkbox"/> <label for="four-by-four-checkbox" class="label-checkbox">4x4</label> <input id="convertible-checkbox" class="float-checkbox" type="checkbox"/> <label for="convertible-checkbox" class="label-checkbox">Convertible</label> <input id="coupe-checkbox" class="float-checkbox" type="checkbox"/> <label for="coupe-checkbox" class="label-checkbox">Coupe</label> </div> </li> <li class="li-toggle"> <h4 class="h4-finder-toggle">Transmission<span class="glyphicon glyphicon-plus glyph-plus-toggle"></span></h4> <div class="panel"> <input id="automatic-checkbox" class="float-checkbox" type="checkbox"/> <label for="automatic-checkbox" class="label-checkbox">Automatic</label> <input id="manual-checkbox" class="float-checkbox" type="checkbox"/> <label for="manual-checkbox" class="label-checkbox">Manual</label> <input id="semi-auto-checkbox" class="float-checkbox" type="checkbox"/> <label for="semi-auto-checkbox" class="label-checkbox">Semi automatic</label> </div> </li> </ul> <button href="#" class="btn btn-block car-search-button btn-lg btn-success"><span class="glyphicon car-search-g glyphicon-search"></span> Search cars </button> <h4 class="h4-finder"><a href="#">Try our Smart Search </a><span class="glyphicon info-car-search-g glyphicon-info-sign"></span></h4> </form>I have noticed that JS and Ajax give a great user experience when it comes to filtering search results, in this HTML template I have added some select elements and check boxes and I am now really stuck. Does anybody know how I can make exceptions to what SQL results are returned to the front end or know of any tutorials? Thanks I have been given a task, and I gotta say it is kicking my butt.
Here is what I have to do.
1. Have user fill out and submit a form.
2. Data gets sent to: http://www.ffiec.gov...de/Default.aspx
3. Data is set as values for input fields in the sites form.
4. Form executes.
5. Retrieve result data.
6. Display data back to my site.
I have no idea how to do this.
Usually when I have done something like this I use an API.
Hope my question is clear.
Thanks for the help.
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 }, failu 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. Edited by kjetterman, 26 September 2014 - 10:23 AM. I am trying to implement lazy loading into a project with pagination already set up.
If I was to go to my website and after the .com, type in "api_courselist.php?page=1" I would receive the first 20 results of my query. If I was to change that to page=2, it would retrieve the next 20 and so on.
My issue is I have no idea how to implement that into my java script/ajax file. I have it set up so that when the user scrolls to the bottom of the page, a div will make its self visible with the new page populated inside of it and IT will keep on pulling pages in till There is no more content.
jQuery(function ($) { jQuery(document).ready(function() { var is_loaded = true; jQuery(window).scroll(function() { if(jQuery(window).scrollTop() == jQuery(document).height() - jQuery(window).height()) { jQuery('div#loadMore').show(); if(is_loaded){ is_loaded = false; jQuery.ajax({ url: "api_courselist.php?page=1", success: function(html) { is_loaded = true; if(html){ jQuery("#infiscroll").append(html); jQuery('div#loadMore').hide(); }else{ jQuery('div#loadMore').replaceWith("<center><h1 style='color:red'>End of Content !!!!!!!</h1></center>"); } } }); } } }); }); }); I am working on a phpmailer script that sends an order confirmation email to the customer AND the client at the same time. If I have the customer email and client email set both to the originating domain's email addresses (myname@myserver.com), then it sends fine. However, if I try to send to an outside mail server (eg. someone@gmail.com), I get the following errors: Code: [Select] SMTP -> FROM SERVER:220 myserver.com ESMTP Exim 4.63 Sat, 18 Sep 2010 15:08:21 -0700 SMTP -> FROM SERVER: 250 myserver.com Hello localhost [127.0.0.1] 250-SIZE 52428800 250-PIPELINING 250-AUTH LOGIN PLAIN 250-STARTTLS 250 HELP SMTP -> FROM SERVER:250 OK SMTP -> FROM SERVER:250 Accepted SMTP -> FROM SERVER: SMTP -> ERROR: RCPT not accepted from server: SMTP Error: The following recipients failed: someone@gmail.com Message could not be sent. Mailer Error: SMTP Error: The following recipients failed: someone@gmail.com SMTP server error: I'm not sure what's going on here. Any SMTP or phpmailer geniuses here that can shed some light on what needs to happen here for this to send to any address? Hi, I'm trying to setup a quick PHP script that will grab the email from the url (see below) and after inserting into MySQL db - which is working fine - the script will complete two additional tasks: 1. send that same captured email out to a external db as in shown via http://domain1.com/insert.php?email=$lead (example), but then send to a DIFFERENT source - the originator of the lead - a portback acknowledgement using Header (sending the status and email to http://domain2.com/check.php?e=$lead&s=$status for their records). See the code below: ------------------------- Code: [Select] $lead = $_REQUEST['e_mail']; // will grab email from posted url string and assign to local variable $result = mysql_query($command); // this is just to execute the MySQL insert which works just fine but included here to explain validation below // Create API Call string to insert lead into iContact folder $requestURL = "http://domain1.com/insert.php?email=$lead"; // Execute API Call to CAKE $xml = simplexml_load_file($requestURL) or die("feed not loading"); if ($result) { $status = 1; // mark lead as sucess // send postback on lead status header("Location: http://domain2.com/check.php?e=$lead&s=$status"); } -------- Problem: I'm getting all sorts of errors with the simplexml_load_file() function and can't figure out why it won't work. Any input appreciated as this the only way I know how to pass the lead onward and then inform/update the other party of receipt of information. thanks! 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> Edited by man5, 18 August 2014 - 08:55 PM. Now I'm having this strange issue with my website I'm currently working on a tester system and I've encountered a problem that I'm unable to find the issue, tho I'm thinking my ajax php part of the script to be the thing causing it even tho it seems strange that it would cause it. The first part which is connected to where the problem occurs is the echo"<form>"; and from there, It should take you to index.php?page=tester&select=answer, now that is where it in the browser goes there tho it still shows the page stuff from the last page which is index.php?page=tester&select=applications, so it's like showing both &select=answer and &select=applications on the same page. <?php $q=$_GET["q"]; include'../config/connection.php'; $result = mysql_query("SELECT * FROM applications WHERE id = '$q'"); echo "<center><table border='1'> <tr> <th>Account Name</th> <th>Character Name</th> <th>Gender</th> <th>Skin Color</th> </tr>"; $row = mysql_fetch_array($result); echo "<tr>"; echo "<td>" . $row['name'] . "</td>"; echo "<td>" . $row['charactername'] . "</td>"; echo "<td>" . $row['gender'] . "</td>"; echo "<td>" . $row['race'] . "</td>"; echo "</tr></table></center>"; echo"<br/>"; echo"<table><tr> <th>Description</th> <th>Metagaming</th> <th>Powergaming</th></tr>"; echo"<tr>"; echo "<td><textarea readonly='readonly' style='width:22em; height:20em;'>".$row['description']."</textarea></td>"; echo "<td><textarea readonly='readonly' style='width:22em; height:20em;'>".$row['mg']."</textarea></td>"; echo "<td><textarea readonly='readonly' style='width:22em; height:20em;'>".$row['pg']."</textarea></td>"; echo"</tr></table><table><br/><center><h1>Answer</h1><br/><form action='index.php?page=tester&select=answer' method='post'>"; echo"<textarea name='why' style='height:10em; width:60em;'></textarea><br/>"; echo"<input type='submit' name='answer' value='Accept' /><a/>"; echo"<input type='submit' name='answer' value='Decline' /></center>"; echo"<input type='hidden' name='id' value='$q'/>"; echo"</form></table>"; ?> Now on &select=answer it included a page which the script of that include consist of the stuff below, it outputs that the query was successfully, and all that. <? if(!empty($_POST['why'])) { $why = mysql_real_escape_string($_POST['why']); $answer = trim($_POST['answer']); $id = $_POST['id']; if($answer == "Accept") { $query1 = mysql_query("UPDATE characters SET accepted = '1' WHERE id = '".$id."'"); echo"Successfully accepted"; $answer = 1; } elseif($answer == "Decline") { echo"Successfully declined"; $answer = 0; } $query = mysql_query("UPDATE applications SET answer = '$why' AND tester = '".$_COOKIE['Username']."' AND accepted = '$answer' AND answered = '1' WHERE cid = '".$id."'") or die('Could not connect: ' . mysql_error()); if($query) { echo"<br/>Query went through without problems"; header("Refresh: 5;url=index.php?page=tester"); } } ?> This is the ajax part javascript of it which gets the information for index.php?page=tester&select=applications Code: [Select] <script type="text/javascript"> function showApplication(str) { if (str==""||str==0) { document.getElementById("txtHint").innerHTML=""; return; } if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("txtHint").innerHTML=xmlhttp.responseText; } } xmlhttp.open("GET","tester/applications.php?q="+str,true); xmlhttp.send(); } </script>If you need any more information feel free to ask for it. Thanks in advance. Hello, I've been trying this for hours now, looking at different examples and trying to change them to work for me, but with no luck... This is what I am trying to do: I have a simple form with: - 1 input field, where I can enter a number - 1 Submit Button When I enter a number into the field and click submit, I want that number to be send to the php file that is in the ajax call, then the script will take that number and run a bunch of queries and then return a new number. I want that new number to be used to call the php script via ajax again, until no number is returned, or something else is returned like the word "done" or something like that, at which point is simply makes an alert or populated a div with a message... The point is, that depending on the number entered it could take up to an hour to complete ALL the queries, so I want the script that is called to only run a fixed amount of queries at a time and then return the number it is currently at (+1), so that it can continue with the next number when it is called again. I would like to use jquery, but could also be any other way, as long as I get this to work. I already have the php script completed that needs to be called by the ajax, it returns a single number when being called. Thank you, vb As the title say, I can not for the life of me get the "$bank" content to display, no matter HOW much I try... Does anyone see any errors. I am sooooooo wiped out at this! main page <? $body = ' <script type="text/javascript" src="change-content.js"></script> <div id="addSold"> <form action="'.$_SERVER['REQUEST_URI'].'" method="post" name="form" autocomplete="off"> <fieldset id="Vehicle"> <legend>Vehicle</legend> <ul> <li><label for="Year">Year</label>'.$Year.'</li> <li><label for="Make">Make</label>'.$Make.'</li> <li><label for="Model">Model</label>'.$Model.'</li> <li><label for="Trim">Trim</label><input type="text" name="Trim" id="Trim" size="10" value="'.$trim.'" disabled="disabled"></li> </ul> <ul> <li><label for="Mileage">Mileage</label><input type="text" name="Mileage" id="Mileage" size="5" maxlength="6" value="'.$row['mileage'].'"></li> <li><label for="VIN">VIN</label><input type="text" name="VIN" id="VIN" size="23" maxlength="17" value="'.$row['vin'].'" disabled="disabled"></li> <li><label for="Color">Color</label>'.$Exterior.'</li> </ul> </fieldset> <fieldset id="Deal"> <legend>Deal</legend> <ul> <li> <label for="soldDte1">Date</label> <input type="text" name="soldDte1" id="soldDte1" size="1" maxlength="2" onkeyup="return autoTab(this, 2, event)" value="08"> / <input type="text" name="soldDte2" id="soldDte2" size="1" maxlength="2" onkeyup="return autoTab(this, 2, event)" value="30"> / <input type="text" name="soldDte3" id="soldDte3" size="1" maxlength="2" value="'.$year.'"> <a href="#"><img id="date_'.$row[stock].'" src="images/Icons/dateOff.png" onfocus="this.select();lcs(this)" onmouseover="MM_swapImage(\'date_'.$row[stock].'\',\'\',\'images/Icons/dateOn.png\',1)" onmouseout="MM_swapImgRestore()" alt="Choose Date"></a> </li> <li> <label for="salesman">Salesman</label> <select name="salesman" id="salesman"> <option></option> '.$salesmen.' </select> </li> </ul> <ul> <li> <label for="dealType">Deal Type</label> <select name="dealType" class="select-content" onchange="getFile(this.value)"> <option></option> <option value="AL">Auto Loan</option> <option value="Cash">Cash</option> <option value="CAC">Credit Acceptance</option> <option value="IH">In House</option> <option value="SAL">Sensible Auto</option> </select> </li> <li> <label for="tradeDrop">Trade</label> <select name="tradein" id="tradeDrop" onchange="show_hide_trade(this.value);"> <option value="No">No</option> <option value="Yes">Yes</option> </select> </li> </ul> </fieldset> <div id="Bank" class="view">'.$bank.'</div> </form> </div> '; ?> get_Bank.php <? if ($_GET['dealType'] == "AL") { $bank = ' <fieldset id="AL"> <legend>Auto Loan Figures</legend> <ul> <li><label for="price">Price</label><input type="text" name="price" id="price" class="price" size="7" onchange="currency(this)"></li> <li><label for="down">Down</label><input type="text" name="down" id="down" class="price" size="6" onchange="currency(this)"></li> <li><label for="tax">Tax</label><input type="text" name="tax" id="tax" class="price" size="6" onchange="currency(this)"></li> <li><label for="reg">Plates</label><input type="text" name="reg" id="reg" class="price" size="4" onchange="currency(this)"></li> <li><label for="gap">Gap</label><input type="text" name="gap" id="gap" class="price" size="4" onchange="currency(this)"></li> </ul> <ul> <li> <label for="pymtNum">--------------- Payment ---------------</label> <input type="text" name="pymtNum" id="pymtNum" size="3" maxlength="3" onkeyup="return autoTab(this, 3, event)"> @ <input type="text" name="pymtAmnt" id="pymtAmnt" class="price" size="5" onchange="currency(this)"> per <select name="pymtType"> <option value="Weekly" selected="selected">Week</option> <option value="Monthly">Month</option> </select> </li> <li><label for="APR">APR</label><input type="text" name="APR" id="APR" class="rate" size="6" value="19.00"></li> </ul> </fieldset> '; } elseif ($_GET['dealType'] == "CAC") { $bank = ' Credit Acceptance stuff goes here '; } else { $bank = 'You must choose a bank before continuing'; } ?> change-content.js Code: [Select] window.onload = init; // finds all <select> tags will class="select-content" and activates function function init() { var sel = document.getElementsByTagName("select"); for (var i=0; i<sel.length; i++){ if (sel[i].className == "select-content") { sel[i].onchange = getFile; } sel[i].selectedIndex = 0; } } function getFile (url) { var url = "AJAX/get_Bank.php?dealType="+ this.value; if (window.XMLHttpRequest) {xmlhttp=new XMLHttpRequest();} else {xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");} xmlhttp.open("GET",url,false); xmlhttp.send(); // a loop that looks through all <div>s on the page // and then replaces the id with the value and gets that file var divs = document.getElementsByTagName("div"); for (var i=0; i<divs.length; i++) { if(divs[i].id == "bank") { divs[i].id = this.value; divs[i].innerHTML=xmlhttp.responseText; } } } i would like to send sms using AT Hayes command in php... is it possible? Hello i need the php send code for this html code if anyone can help me? website url: http://dclxvi.co.uk/htmlform.htm <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html lang="en-GB" xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <meta name="description" content="A site for contacting a dj to play at an event"/> <meta name="keywords" content="DJ, Decks, AI-disco, AI Disco, Disco"/> <meta name="author" content="Ashley Sargent"/> <link rel="stylesheet" href="stylee.css" type="text/css" /> <title>DCLXVI: Booking</title> </head> <body> <div id="container"> <div id="header"> </div> <div id="navigation"> <div id="navigation"> <ul class="menu"> <div class="left"> <a href="index.html"><img src="imagess/homet.gif" onmouseover="this.src='imagess/homet1.gif'" onmouseout="this.src='imagess/homet.gif'"> <a href="services.html"><img src="imagess/services.jpg" onmouseover="this.src='imagess/services1.jpg'" onmouseout="this.src='imagess/services.jpg'"> <a href="about.html"><img src="imagess/about.jpg" onmouseover="this.src='imagess/about1.jpg'" onmouseout="this.src='imagess/about.jpg'"> <a href="contact.html"><img src="imagess/contact.jpg" onmouseover="this.src='imagess/contact1.jpg'" onmouseout="this.src='imagess/contact.jpg'"> <a href="faq.html"><img src="imagess/faq.jpg" onmouseover="this.src='imagess/faq1.jpg'" onmouseout="this.src='imagess/faq.jpg'"> <a href="gallery.html"><img src="imagess/gallery1.jpg" onmouseover="this.src='imagess/gallery2.jpg'" onmouseout="this.src='imagess/gallery1.jpg'"> <a href="login.php"><img src="imagess/login.jpg" onmouseover="this.src='imagess/login1.jpg'" onmouseout="this.src='imagess/login.jpg'"> <a href=""></a> </div> </div> <br><br><br> <form name="htmlform" method="post" action="html_form_send.php"> <table border="1" bordercolor="0000FF" cellspacing="2" cellpadding="5"> </tr> <U><b>Personal Information:</b></U><BR><BR> <tr> <td valign="top"> <label for="Title">Title *</label> </td> <td valign="top"> <select> <option><selected>--Please Select--</option> <option>Mr</option> <option>Mrs</option> <option>Miss</option> <option>Dr</option> <option>Other</option></select>Other:<INPUT type="text" SIZE="20"> <tr> <td valign="top"> <label for="first_name">First Name *</label> </td> <td valign="top"> <input type="text" name="first_name" maxlength="50" size="30"> </td> </tr> </select> <tr> <td valign="top""> <label for="last_name">Last Name *</label> </td> <td valign="top"> <input type="text" name="last_name" maxlength="50" size="30"> </td> </tr> <tr> <td valign="top"> <label for="email">Email Address *</label> </td> <td valign="top"> <input type="text" name="email" maxlength="80" size="30"> </td> </tr> <tr> <td valign="top"> <label for="telephone">Telephone Number *</label> </td> <td valign="top"> <input type="text" name="telephone" maxlength="30" size="30"> </td> </tr> </tr> </table> <br><br> <table border="1" bordercolor="0000FF" cellspacing="2" cellpadding="5" width="460"> <u><b>Event Information:</b></u><br><br> <tr> <td valign="top"> <label for="occasion">Occasion</label> </td> <td valign="top"> <select> <option><selected>--Please Select--</option> <option>Birthday</option> <option>Wedding</option> <option>Anniversary</option> <option>Party</option> <option>Engagement</option> <option>Valentines</option> </select> <tr> <td valign="top"> <td valign="top"> <input type="checkbox" value="70's">70's<br> <input type="checkbox" value="80's">80's <input type="checkbox" value="90's">90's<br> <input type="checkbox" value="Cheese">Cheese <input type="checkbox" value="Mainstreem">Mainstreem R n B<br> <input type="checkbox" value="House">House <input type="checkbox" value="Dance">Dance<br> <input type="checkbox" value="Garage">Garage <input type="checkbox" value="hiphop">Hip-Hop<br> <input type="checkbox" value="Karaoke">Karaoke <input type="checkbox" value="Other">Other <INPUT type="text" SIZE="6"> </div> </td> </tr> </select> <tr> <td valign="top"> <label for="event_date">Event Date</label> </td> <td valign="top"> <input type="text" name="event_date" maxlength="50" size="30"> </td> </tr> <td valign="top"> <label for="length_of_party">Length of Party</label> </td> <td valign="top"> <select> <option><selected>--Please Select--</option> <option>1 Hour</option> <option>2 Hours</option> <option>3 Hours</option> <option>4 Hours</option> <option>5 Hours</option> <option>Other</option></select>Other:<INPUT type="text" SIZE="10"> </td> </tr> <tr> <td valign="top"> <label for="location">Location</label> </td> <td valign="top"> <input type="text" name="location" maxlength="30" size="30"> </td> </tr> <tr> <td valign="top"> <label for="comments">Comments</label> </td> <td valign="top"> <textarea name="comments" cols="29" rows="5"> Enter your comments here... </textarea> <center><input type="submit" value="Submit" /></center> </td> </tr> </table> I am trying the following code to send SMS. <?php $gatewayURL = 'http://localhost:9333/ozeki?'; $request = 'login=admin'; $request .= '&password=abc123'; $request .= '&action=sendMessage'; $request .= '&messageType=SMS:TEXT'; $request .= '&recepient='.urlencode('+9898989898'); $request .= '&messageData='.urlencode("Hello World"); $url = $gatewayURL . $request; //Open the URL to send the message file($url); ?> But I am getting the following error message. Warning: file(http://localhost:9333/ozeki?login=ad...ta=Hello+World) [function.file]: failed to open stream: Connection refused in /home/vpe/public_html/_demo2/sms/sms2.php on line 13 Please help to rectify my code. Thanks a lot in advance. Hi guys, i have a custom made php that collect all the info in admin page (long story short), there's a button called "Approve" I would like to send back an email to user who applied with picture, once Approved button is pressed, so here's the script: <?php session_start(); $user = '123'; $pass = '123'; $to = $data['email']; $subject = 'blablabla'; $message = 'test123'; if (!isset($_SERVER['PHP_AUTH_USER']) || !isset($_SERVER['PHP_AUTH_PW']) || $_SERVER['PHP_AUTH_USER'] != $user || $_SERVER['PHP_AUTH_PW'] != $pass) { header('WWW-Authenticate: Basic realm="Enter password to access this page."'); header('HTTP/1.0 401 Unauthorized'); echo"You must be logged in to see this page."; exit; } ################## PROTECTED CONTENT ######################## require('./config.php'); ?> <!DOCTYPE HTML> <html> <head> <title>ADMIN PANEL</title> <style type="text/css"> body{width: 960px; margin: auto; margin-top: 20px; padding: 5px 20px; box-shadow: 0px 0px 2px #000000; border-radius: 5px;background:transparent url(images/bg_header.gif) top left repeat-x;} a:link,a:active,a:visited{color: inherit; text-decoration: none;} a:hover{text-decoration: underline;} .button{background:transparent url(images/grad.PNG) bottom left repeat-x; padding: 3px 5px; border-radius: 4px; border: 1px solid #cccccc;} .button:hover{border-color:orangered;text-decoration:none;} .approve .img{max-height: 200px; max-width: 200px; position: absolute; right: 5px; top: 5px;} .approve{display: block; height: 200px; overflow: hidden; box-shadow: 0px 0px 2px #000000; margin-top: 20px; padding: 20px; position: relative; font:13px verdana;} textarea,input{padding: 3px;font: 13px helvetica,verdana;border:1px solid rgb(51,151,251);border-radius: 4px;width: 300px; display: block; margin: 5px 0px;} input:hover,textarea:hover{border-color:orangered;cursor:pointer;} form{font:bold 13px verdana;} input[type='submit'],input[type='button']{width: auto;} </style> </head> <body> <?php echo" <div id='head'> <h1 align='center'>ADMIN PANEL</h1> <h4 align='center'><a href='index.php' class='button'>Homepage</a> <a class='button' href='admin.php'>Approval Queue</a> <a class='button' href='admin.php?edit'>Edit Image info.</a> <a class='button' href='?edit&view'>View Image Info.</a></h4> </div>"; if (isset($_GET['edit'])) { if (isset($_GET['pid'])) { $pic = mysql_query('SELECT * from `' . $table_name . '` WHERE pid = ' . intval($_GET['pid'])); if (mysql_num_rows($pic) == 1) { if (isset($_POST['submit'])) { $approved = isset($_POST['approved']) && $_POST['approved'] == '1' ? 1 : 0; mysql_query('UPDATE `' . $table_name . '` SET ' . 'first_name = "' . $_POST['first'] . '",' . 'last_name="' . $_POST['last'] . '",' . 'phone="' . $_POST['phone'] . '",' . 'email="' . $_POST['email'] . '",' . 'first_name="' . $_POST['first'] . '",' . 'approved=' . $approved . ',' . 'address="' . $_POST['addr'] . '",' . 'admin_desc="' . $_POST['admin_desc'] . '"' . ' WHERE pid = ' . intval($_GET['pid'])) or exit("Unable to edit" . mysql_error()); echo'<h3>EDITED</h3>'; $pic = mysql_query('SELECT * from `' . $table_name . '` WHERE pid = ' . intval($_GET['pid'])); } $data = mysql_fetch_array($pic); if (isset($_GET['view'])) { echo' <strong>Uploaded by </strong>' . $data['first_name'] . ' ' . $data['last_name'] . ' <br /> <img src="' . $default_dir . $data['image_name'] . '" style="max-width: 200px; max-height:200px; float: right;" /> <br /> <br /> <b>First_name :</b> ' . $data['first_name'] . ' <br /> <br /> <b>Last_name :</b> ' . $data['last_name'] . ' <br /> <br /> <b>Phone :</b> ' . $data['phone'] . ' <br /> <br /> <b>Email :</b> ' . $data['email'] . ' <br /> <br /> <b>Approved :</b> ' . ($data['approved'] == 1 ? 'Yes' : 'No') . ' <br /> <br /> <b>Address :</b> ' . $data['address'] . ' <br /> <br /> <b>Admin_description :</b> <br /> <br />' . $data['admin_desc'] . ' <br /> <br /> <a href="?edit&pid=' . $data['pid'] . '" class="button">Edit</a> <br /> <br /> '; } else { echo'<form method="POST" action="?edit&pid=' . intval($_GET['pid']) . '"> Editting photo: <a style="color:rgb(51,151,251);" href="' . $default_dir . $data['image_name'] . '">' . $data['image_name'] . '</a> uploaded by ' . $data['first_name'] . ' ' . $data['last_name'] . ' <br /> <img src="' . $default_dir . $data['image_name'] . '" style="max-width: 200px; max-height:200px; float: right;" /> <br /> First_name : <input type="text" name="first" value="' . $data['first_name'] . '" /> Last_name : <input type="text" name="last" value="' . $data['last_name'] . '" /> Phone : <input type="text" name="phone" value="' . $data['phone'] . '" /> Email : <input type="text" name="email" value="' . $data['email'] . '" /> Approved : <input type="text" name="approved" value="' . $data['approved'] . '" /> 0 or 1 Address : <textarea name="addr">' . $data['address'] . '</textarea> Admin_description : <textarea name="admin_desc">' . $data['admin_desc'] . '</textarea> <input type="submit" name="submit" value="Edit" /> </form>'; } } else { echo"NO SUCH PICTURE EXISTS"; } } else { echo" <h3>Search for image to " . (isset($_GET['view']) ? 'view' : 'edit') . " it: </h3> <form id='form' method='POST' action='admin.php?edit" . (isset($_GET['view']) ? '&view' : '') . "'> Uploader's first name: <input type='text' name='name' value='' /> OR Image name: <input type='text' name='img' value='' /> OR Email: <input type='text' name='email' value='' /> <input type='submit' name='submit' value='Search' /> </form>"; if (isset($_POST['submit'])) { $name = empty($_POST['name']) ? '%' : '%' . $_POST['name'] . '%'; $email = empty($_POST['email']) ? '%' : '%' . $_POST['email'] . '%'; $img = empty($_POST['img']) ? '%' : '%' . $_POST['img'] . '%'; $query = mysql_query( 'SELECT * from `' . $table_name . '` where ' . 'first_name like "' . $name . '" and ' . 'email like "' . $email . '" and ' . 'image_name like "' . $img . '"'); if (mysql_num_rows($query) > 0) { while ($pic = mysql_fetch_array($query)) { echo"<hr/><strong>Uploaded by $pic[first_name] $pic[last_name] " . date(' \a\t H:i \o\n d/m/Y', intval($pic['image_name'])) . "</strong> - <a href='$default_dir$pic[image_name]' target='_blank'>$pic[image_name]</a> <a href='?edit" . (isset($_GET['view']) ? '&view' : '') . "&pid=$pic[pid]' class='button'>" . (isset($_GET['view']) ? 'View' : 'Edit') . "</a>"; } } else { echo "NO IMAGE MATCHES THAT DESCRIPTION"; } } } exit; } if (isset($_GET['approve'])) { if (mysql_query('UPDATE `' . $table_name . '` SET approved = 1 WHERE pid = ' . intval($_GET['approve']))) { if (@mail($to, $subject, $message)) { echo('<p>Mail sent successfully.</p>'); } else { echo('<p>Mail could not be sent.</p>'); } echo"<h2>APPROVEDs</h2>"; } } It's not whole script though. Hello, I have a registration page and when a user registers I want to send their email an activation code. To test I have the following code. <?php //Send activation Email $to = $Email_address; $subject = "www.WEBSITE.com/"; $message = "Welcome to my website!\r\rYou, or someone using your email address, has completed registration at WEBSITE. You can complete registration by clicking the following link:\rhttp://www.WEBSITE.com/register.php?action=verify&$activationKey\r\r If this is an error, ignore this email and you will be removed from our mailing list.\r\rRegards,\ "; $headers = 'From: noreply@abc.com' . "\r\n" . 'Reply-To: noreply@abc.com' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); mail($to, $subject, $message, $headers); if (mail($to, $subject, $message, $headers)) { echo 'Success'; } else { echo 'Error'; } ?> I have the last if else to see if it is sent to not. I do get a Success message, but I don't get an email at the address (I have checked the spam folder). I have checked the email address and it is correct. I have even waited a few hours and nothing. Why is the email not getting to my account? Hi every one I've downloaded some classes but they weren't work . How do I send a private message? thanks # 1 Create an account with one of the SMS gateway providers, such as Clickatell, Ozeki NG and TM4B SMS Gateway (see Resources). The gateway provider will be in charge of sending your requests for SMS messages. As with sending text messages from cell phones, you will need a service provider in order to send SMS messages from your website. The gateway provider will provide you with a paid solution for sending SMS messages from your website. # 2 Start a new blank file in a web-authoring application, such as Dreamweaver, or a plain text-editing application like Notepad. Most web-authoring application uses a WSIWYG (What You See is What You Get) environment, in which you just add the visual elements to the document and the program will automatically generate the code. You want to type in your own code in this project, so switch to "Code" or "HTML" view of the program. Also, don't use a word processor as a text-editing program. Word processors, like Microsoft Word, add extra formatting code that will interfere with the PHP code. # 3 Create the web form that will work as the user interface for entering in the information for sending the text message. Visitors to your website will type in the information for the text message. You will then collect this information and send it in the request to the SMS gateway. "<html> <head> <body> <form action="<?php print $PHP_SELF?>" enctype="multipart/form-data" method="post"> Sender:<br /> <input type="text" name="sender" value="" /><br /> Receiver:<br /> <input type="text" name="receiver" value="" /><br /> Message: <p><textarea name="message" rows="20 cols="80"> Click in this box and type in your text message. # 4 Type in the PHP code to prepare the request to the messaging service's gateway. You have to send the gateway an HTTP request that passes along the details of the SMS message. The request should look like this: "<?php \\Takes the information from the form and save it to variables $sender = $_POST['sender']; $receiver = $_POST['receiver']; $message = $_POST['message']; \\Prepare the request $request = ""; $param["username"] = "username"; //the account username provided by gateway provider $param["password"] = "password"; //the account password provided by gateway provider $param["msg"] = $message; //the text message that will be sent $param["to"] = $receiver; //the recipient of the text message $param["from"] = $receiver; //the message sender $param["route"] = "frst"; //this means we are sending the message first class $param["sim"] = "yes"; foreach($param as $key=>$val){ $request.= $key."=".urlencode($val); $request.= "&"; } $request = substr($request, 0, strlen($request)-1); ?>" Change the param values above to meet your specific details. # 5 Type in the code to actually send the SMS message. PHP has a CURL library included that handles these types of things. "<?php $url = "{add the url to the gateway API}"; //the gateway's interface provided by the gateway provider $ch = curl_init; curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $request); $response = curl_exec($ch); curl_close($ch); ?> </body> </head> </html>" Do not change any of the code above other than removing the quotation marks from the first and last line in the code and adding the URL to the SMS gateway provider's API interface. Check with the provider for this information. Save the document with the PHP file extension and upload it to your web server. |