PHP - Receiving Compressed Data And Uncompressing - Xml, Php, Gzip, Deflate
I am being sent an XML feed which needs to be downloaded in a 'compressed way'.
The example I have been given is this:
$url = 'http://myurl.com';
$headers[] = "Accept-Encoding: gzip,deflate"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_BINARYTRANSFER, true); $data = curl_exec($ch); but the output I am getting is jargon like this with loads of black diamond question marks:� +T��sƒ���-}#v���]K���������HB�$&G�����Y�����'߷s�,�.4֫'?'���9;*9^��>�j~�ǫ}z|hq�J��Գ".o2)~b���U~I| How to a convert it back into XML? Many thanks Edited by samjsharples, 30 September 2014 - 03:49 PM. Similar TutorialsIs there a way I can readily stream-process a compressed XML file in PHP? Something like this NON WORKING example: Code: [Select] $reader = new XMLReader(); $reader->open(bzopen($planet_file,"r")); while ($reader->read()) { ... See also http://php.net/manual/en/xmlreader.open.php Apologies, first off: I only venture into PHP occasionally and my problem is something very very obvious... The data I'm getting back from the script below differs radically from the data recovered by the same SQL applied directly in phpMyAdmin. $sql = mysql_query('SELECT `fid` , `title` , `extension` FROM files WHERE `mid_FK` = 2353 ORDER BY `title`') or die ("Sorry: cannot retrieve files."); $files_found = mysql_fetch_array($sql); $num_files_found = count($files_found); The native SQL returns three rows from the table, all with entries in each column. What my script produces as relevant variables is this. Code: [Select] [sql] => Resource id #6 [files_found] => Array ( [0] => 961 [fid] => 961 [1] => Abstract of Case [title] => Abstract of Case [2] => doc [extension] => doc ) [num_files_found] => 6 This is the first row of the SQL results, duplicated. Whereas what I need are the entries for all three rows. I'm baffled, not least because I copied it out of another script I wrote last time I was doing this sort of thing, which has been working fine ever since. Hi all, I should first mention I'm not much of a coder, I'm using PHP to create a custom weather solution for myself. Basically am pulling XML from weather.gov and working with the data. So far, so good. I'm getting the data I want displayed correctly, but noticed when I refresh the page I sometimes receive old data. (From the past hour, two hours, etc.) I figured this was cached info and I'm trying to figure out how to clear that out. This is how I'm accessing the XML: $url = 'http://forecast.weather.gov/MapClick.php?lat=40.65160&lon=-74.34420&FcstType=digitalDWML'; $xml = file_get_contents($url); I did some research and tried the following headers, but that doesnt seem to work: <?php header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); header("Cache-Control: no-cache"); header("Pragma: no-cache"); ?> Also tried appending a random number onto the $url, (as per a forum question/response somewhere) but that didn't work. Anyone suggestions would be great. Thanks I'm trying to set up paypal payment processing on my website. I have godaddy shared hosting (<--mistake) and I'm trying my hardest to not switch hosts. The payments process fine, it is the listener that I'm having problems with. Paypal POSTs data to a script for which you set the url to a "listener" script in your settings. When a payment is made.... they POST the data to the listener script... you encode the data...append it all together plus another variable and send it back to be verified that it matches... Well I'm not too worried about the script working and all that... the problem is I'm not even RECEIVING the post. I have a simple foreach loop gather and append the data into a string. I have it set up right now to insert into MYSQL just so I can SEE if it's working....You can check your IPN history and I can see that payments are made but paypal is sending it over and over it's in a "retrying" state with a 408 error. My server is not sending a 200ok response. After 4 days of bashing my head against the wall I figured out that there's a problem with godaddy shared hosting.. If I use a virtual private server with the SAME script from godaddy it works just fine. But on the shared hosting it blocks it for some reason...After calling paypal and godaddy countless times with them pointing their finger at each other... one godaddy support rep tells me that I should set my script up with a proxy and he gave me info which I will show you in the script... This is what I need help with right. How can I receive POST data through a proxy in my script.... I want to add that this doesn't make sense to me because in my script I also have the word "yes" insert into MYSQL even if the script is hit at all... All this time my script is NEVER even touched by paypal... So.. if I add this proxy stuff... how will let my script even be accessed? I'm not sure how servers work together too well to process things. It just didn't seem like the proxy thing would even help when my script can't even be accessed it seems. Any help is appreciated. Here's the simple code I'm working with: $con = mysql_connect("","","") or die(mysql_error()); $db = mysql_select_db("swellshirt",$con); $ip = "64.202.165.130"; // proxy IP <-- IP... $port = 3128; // proxy port $url_proxy = 'http://proxy.shr.secureserver.net'; // read the post from PayPal system and add 'cmd' $req = 'cmd=_notify-validate'; foreach ($_POST as $key => $value) { $value = urlencode(stripslashes($value)); $req .= "&$key=$value"; } mysql_query("INSERT INTO orders (description, street) VALUES ('$req', 'yes') ") or die(mysql_error()); This has probably been asked a bunch of times , but : I only recently started to self learn PHP , and this small project i am making is quite a challange for me. The scripts below are not realy writen by me , but i wished to tie them together to get a fully working code. What is suppose to happen is : In the form i wish to put a special button that puts extra input fields in the form. After the form is submited ,with whatever amount of feilds in it, the data goes to a processing.php file that sorts all the info gathered and finaly sends all this data formated in to the last file that will be inluded in the index.php. i already have the code for increcing the amount of inputs but the problem is , all inputs have the same names. Coz of that i get a mess. What i need is each input to have a unique name or id , that way the processing file would receive different names(id's) with different values(what ever is writen in the inputs by users). for example: I have 2 enitial fields displayed on form.html , i click the button "add new" 5 times and add 5 more input fields. All this data must be sent to a process.php and on the output write all of this information formated in the last file in a row that will be displayed in the index by useing <?include("blablabla.php");?> The input increment is done by a java script. the problem is sending data with unique id(name) and receiving it. The form file : <?include("header.php");?> <?$i = 1; ?> <script type="text/javascript"> function validate(frm) { var ele = frm.elements['feedurl[]']; if (! ele.length) { alert(ele.value); } for(var i=0; i<ele.length; i++) { alert(ele[i].value); } return true; } function add_feed() { var div1 = document.createElement('div'); // Get template data div1.innerHTML = document.getElementById('newlinktpl').innerHTML; // append to our form, so that template data //become part of form document.getElementById('newlink').appendChild(div1); } var ct = 1; function new_link() { ct++; var div1 = document.createElement('div'); div1.id = ct; // link to delete extended form elements var delLink = '<div style="text-align:right;margin-right:65px"><a href="javascript:delIt('+ ct +')">Del</a></div>'; div1.innerHTML = document.getElementById('newlinktpl').innerHTML + delLink; document.getElementById('newlink').appendChild(div1); } // function to delete the newly added set of elements function delIt(eleId) { d = document; var ele = d.getElementById(eleId); var parentEle = d.getElementById('newlink'); parentEle.removeChild(ele); } </script> <TABLE> <style> #newlink {width:600px} </style> <form action='sendorder.php' method='post'> <div id="newlink"> <div> <table align="center" border=0> <TR><TD><B>Product:</B> </TD><TD><input type=text name=prodname1 value="<?=$_GET['prodname1'];?>"> </TD> <TD><B>Price:</B> </TD><TD><input type=text name=price1 value="<?=$_GET['price1'].$curency;?>"><b>%</b></TD></TR> </table> </div> </div> <p> <br> <input type="submit" name="submit1"> <input type="reset" name="reset1"> </p> <p id="addnew"></p> <FORM> <INPUT type="button" value="Add New" name="button2" onClick="javascript:new_link()"> </FORM> </form> <!-- Template --> <div id="newlinktpl" style="display:none"> <div> <table border=0> <TR><TD><B>Product:</B> </TD><TD><input type=text name=<?$_POST[++$i];?> value="<?$_GET[$i];?>"> </TD> <TD><B>Price:</B> </TD><TD><input type=text name=<?$_POST [++$i];?> value="<?$_GET[$i].$curency;?>"> </TD></TR> </form> </TABLE> <?include("footer.php");?> in the code above i tryed to make the programm POST the numbers in the name increcing it by 1. But when i click submit i get offset error. The processing file : <? $timestamp = strftime("%d-%m-%Y %H:%M:%S %Y"); // for later use (ignore it) $i =1; #################################################################################### if(($_POST['prodname']!="")&&($_POST['price']!="")){ ############################################################ $writetocsv = $_POST['prodname1'] . "," . $_POST['price1']"%" <BR> . $_POST[$i] . $_POST[$i]; $fp = fopen("data/data.csv", "a"); fwrite ($fp,$writetocsv); fclose ($fp); echo "<script>alert('Data sent.')</script>"; } else{ echo "<script>alert('Error! Please fill the form!')</script>"; } echo "<script>location.replace('index.php')</script>"; ?> Perhaps someone knows a easyer way , since i am not sure how to make stuff due to the lack of knowlage in php. I also tryed arrays but , as said before , too tough when you are a noob Please help. Using PHP 5.4.17 on Windows XP, and MySQL 5.6.17 on Windows Server 2003.
In phpinfo(), I have: mysqlnd 5.0.10 - 20111026
I have a need to capture/analyze the MySQL TCP packets as they pass between client computer and database server. I'm using WireShark 1.12.1 to do it.
I understand that compression of the payload will happen if both client and server can do it.
(It seems that the MySQL dissector in WireShark does not yet automatically deflate the payload - according to a bugtracker entry.)
So, is there a config file statement I can use, either in php.ini's [mysqlnd] section, or the server's my.cnf file, that will force zero compression?
Ive gzipped some static html files and want to send it to the browser but not sure how to approach it So i have : http://site.com/cache/file.html (14gb) http://site.com/cache/file.html.gz (1kb) I did this but do i still need a header?? <?php if(file_exists('cache/file.html')){ @readfile("cache/file.html"); } ?> I have just googling in order to find out how to do GZIP so that user can load web page faster. n i found some article which stated that i have to put this script only. <?php ob_start( 'ob_gzhandler' ); ?> my question is...is it doing the zip? if it is correct where should i put that script, in every page which is needed to be compressed or inside index page only? thanks in advance Hi guys, I'll try to be concise. When I use this code (zlib): $xmlFile = 'test.xml'; $data = implode("", file($xmlFile)); $gzdata = gzencode($data, 9); $gzFile = "test.gz"; $fp = fopen($gzFile, "w"); fwrite($fp, $gzdata); fclose($fp); It produces test.gz but when I extract the .gz file I get "test" file (without extension) I need to gzip the xml file (keeping the extension) not only the data (when I extract the gz I should get test.xml back) Is there a way I can do this ? For security reasons I can't use exec() function. Please help! Thanks in advance, Alex hey all now im new to gzip got not much knowledge on it. i was testing my site in seositecheckup and according to the test im asked to compress my html, css and js files and i found this bit of coding on google <?php if(isset($_SERVER['HTTP_ACCEPT_ENCODING']) && substr_count($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')) ob_start('ob_gzhandler'); else ob_start(); ?> i included this file on top of my pages and then it seemed to compress my my file but it seem we need to set header expire on gzip so how could i set expire on it and could someone tell me what exactly is this coding above compressing i mean is it compressing image and all type of files? I have spent all day trying to get any of these functions to work... I have downloaded heaps of expample and NONE! work.. In the case of Zip Archive the CREATE function will not produce a zip file archive to strat with.. Error message says it's created ok... but a search finds no such file. GZip has the same problem. Bzip2 at least creates a blank zip file (17bytes) but I can't add any files to the Bzip2. I have tried on the localhost with dll's installed and on a comercial web server... Nothing gets created... I have read endless examples and documents on the web... None work.. Any help would be much apreciated. My specific situation is SEOMoz, but this is a general question. I have a pretty extensive series of tools that rely on the SEOMoz api. They recently implemented 1 request per 10 seconds throttle limit. Is there a way I can run one request, stop for 10 seconds, and run the next, and so on? Anyway to get around something like this, without breaking their TOS? i have a shopping cart set up with mysql with a $_COOKIE['cart_id'] used to call all rows with cart_id... i have a while loop print out all the items in the cart $sql2 = mysql_query("SELECT * FROM cart WHERE cart_id = '$cart_id'") or die(mysql_error()); while($row = mysql_fetch_array($sql2)){ then i have it echo out the name...desc... quantity of each item... but the quantity is set up to be able to change and i have a form set up and i'd like to have each item be able to be changed at once if they wanted....but being multiple rows... there could be multiple $_POST['quantity']... echo "<td><input type='text' name='quantity' value='".$quantity."'/></td>"; there is a unique id for each row in the table that i'd like to set up with an array to post... i'd like to set up an array $array[$uniq_id] => $quantity; and somehow POST this array name='$array[]' and then on the action end... be able to call it by having foreach($quantity as $uniq_id => $qty){ mysql_query("UPDATE cart SET quantity='$qty' WHERE id='$uniq_id' "); } i'm not sure if i'm approaching this the right way... the array part is leaving me stuck...any help is appreciated..thank you! Hi everyone, First off I have to mention I'm a newbie so my php knowledge is limited -sorry, but this is why I turn to you guys. I have a basic emailform.php= a field into which the user inputs his email address and I should be getting some sort of a message announcing me he signed up. But the last part isn't happening - I've tried emails from yahoo, gmail and from the sitedomain itself. Also I've tried these emails in the php form itself (email to section). I also gotta mention I may have deleted a php.ini file from the root server (I don't really remember exactly). Hosting is with godaddy (I know it sux but please bear with me.) Also my website is not in English so I need special characters (so it's UTF8). I'd be so grateful if you could help me out here - in return I'm offering a drink if you're ever in the vicinity of Milan (Italy) and my permanent respect to the world of programmers EMAILFORM.PHP Code: [Select] <?php if(isset($_POST['email'])) { // EDIT THE 2 LINES BELOW AS REQUIRED $email_to = "ajutor@t-ajutam.net"; $email_subject = "New e-mail subscriber"; function died($error) { // your error code can go here echo "We are very sorry, but there were error(s) found with the form your submitted. "; echo "These errors appear below.<br /><br />"; echo $error."<br /><br />"; echo "Please go back and fix these errors.<br /><br />"; die(); } // validation expected data exists if (!isset($_POST['email'])) { died('We are sorry, but there appears to be a problem with the email your submitted.'); } $email_from = $_POST['email']; // required $error_message = ""; $email_exp = "^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$"; if(!eregi($email_exp,$email_from)) { $error_message .= 'The Email Address you entered does not appear to be valid.<br />'; } if(strlen($error_message) > 0) { died($error_message); } $email_message = "Form details below.\n\n"; function clean_string($string) { $bad = array("content-type","bcc:","to:","cc:","href"); return str_replace($bad,"",$string); } $email_message .= "Email: ".clean_string($email_from)."\n"; // create email headers $headers = 'From: ajutor@t-ajutam.net'; 'Reply-To: '.$email_from."\r\n" . 'X-Mailer: PHP/' . phpversion(); @mail($email_to, $email_subject, $email_message, $headers); ?> <!-- include your own success html here --> Thank you for contacting us. We will be in touch with you very soon. <? } ?> and HTML index Code: [Select] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>T-ajutăm nu este încă gata. </title> <link rel="stylesheet" type="text/css" href="style.css" /> <script type="text/javascript" src="http://code.jquery.com/jquery-latest.pack.js"></script> <script type="text/javascript" src="js/jquery.countdown.js"></script> <script type="text/javascript" src="js/jcarousellite1.0.1_min.js"></script> <script type="text/javascript" src="http://w.sharethis.com/button/buttons.js"></script><script type="text/javascript">stLight.options({publisher:'83f9b168-ba78-4f14-af11-992f92dcf19b'});</script> <!-- jquery countdown--> <script type="text/javascript"> $(function () { var austDay = new Date(); austDay = new Date(austDay.getFullYear() + 2, 0, 0); $('#defaultCountdown').countdown({until: austDay, layout: '{dn} {dl}, {hn} {hl}, {mn} {ml}, and {sn} {sl}'}); $('#year').text(austDay.getFullYear()); }); </script> <!-- jquery slider --> <script type="text/javascript"> $(function() { $("#slidertext").jCarouselLite({ btnNext: ".next", btnPrev: ".prev" }); }); </script> <!--script for IE6-image transparency recover--> <!--[if IE 6]> <script type="text/javascript" src="js/DD_belatedPNG_0.0.7a-min.js"></script> <script> /* EXAMPLE */ DD_belatedPNG.fix('#logo img,#main,.counter,.twitter,.facebook,#submit_button,.prev img,.next img,#email_input'); </script> <![endif]--> <script type="text/javascript"> var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-21856062-1']); _gaq.push(['_trackPageview']); (function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })(); </script> </head> <body> <div class="container"> <div id="header"> <div id="logo"> <a href="index.html"><img src="images/logo.png" alt="logo"/></a> </div><!--end logo--> <div id="contact_details"> <p><a href="mailto:ajutor@t-ajutam.net">Contact</a></p> </div><!--end contact details--> </div><!--end header--> <div style="clear:both"></div> <div id="main"> <div id="content"> <div class="text"> <h2>T-ajutăm nu este încă gata</h2> <br> <p><font color=#e5e5e5>Dacă ne laşi adresa ta de email mai jos te anunţăm când suntem gata.</font></p><br> </div><!--end text--> <div class="details"> <!--slider prev button--> <a class="prev" href="#"><img src="images/prev.png" alt="" /> </a> <div id="sliderwrap"> <div id="slidertext"><!-- The slider --> <ul style="margin: 0pt; padding: 0pt; position: relative; list-style-type: none; z-index: 1; width: 6600px; left: -3000px;"> <li> <h3>Introdu adresa ta de email</h3> <!-- <form action="emailhandler.php" method="post" id="email"> <div id="submitwrapper"> <div ><input type="text" name="email" size="30" value="Enter Your E-mail" onfocus="if(this.value=='Enter Your E-mail'){this.value=''};" onblur="if(this.value==''){this.value='Enter Your E-mail'};" id="email_input" /> </div> <div ><input type="submit" name="Submit" value="Submit" border="none" id="submit_button"/> </div> </div> </form> --> <form method="post" id="subscribeform" action="emailform.php"> <p> <div id="email_input"><input name="email" type="text" size="30" value="Enter Your E-mail" onfocus="if(this.value=='Enter Your E-mail'){this.value=''};" onblur="if(this.value==''){this.value='Enter Your E-mail'};" id="email" /> <input type="submit" id="submit_button" value="Submit" size="80" /> </div> <br /> </p> </form> </li><!-- Slider item --> <li> <h3>T-ajutăm este un nou concept de donaţii online</h3> <p>Ai nevoie de ajutor? Vrei să ajuţi dar nu ştii cum ?<p> <br> <p>Ai ajuns la locul potrivit.</p> </li><!-- Slider item --> <li> <h3>Fii la curent: urmăreşte-ne pe facebook sau twitter</h3> <div class="social"> <a class="twitter" href="http://twitter.com/t_ajutam"></a> <a class="facebook" href="http://www.facebook.com/pages/T-ajutam/178280318883554"></a> </div> </li><!-- Slider item --> <li> <h3>Ţi se pare interesant? Trimite linkul şi prietenilor tăi </h3> <span class="st_twitter_vcount" displayText="Tweet"></span><span class="st_facebook_vcount" displayText="Share"></span><span class="st_email_vcount" displayText="Email"></span><span class="st_sharethis_vcount" displayText="Share"></span> </li><!-- Slider item --> </ul> </div><!-- End of slidertext --> </div><!-- End of sliderwrap --> <!--slider next button--> <a class="next" href="#"><img src="images/next.png" alt=""/></a> </div><!--end details--> </div><!--end content--> </div><!--end main--> <div id="footer"></div> <!-- Footer start --> <p>Powered by <a href="http://ourtuts.com">ourtuts.com</a></p> <!-- Footer end --> </div><!--end class container--> </div> </body> </html> I want some code to receive email, reformat and then forward to another email address
I'm not sure where to start with this
Does the application need to be constantly running - monitoring incoming emails?
What is involved?
I did a search and saw many discussions saying that Google App Engine was available for usage
I've no experience of this
Just looking for suggestions
Thanks
OM
Hi, I have products page which products page and I am echoing the ID of each product into a link with the description of the product as the anchor text. Code: [Select] <a href="product.php?ID=<?php echo $row['ID']; ?>" class='productlink' ><?php echo $row['description']; ?></a> However I am struggling to Get the information from the receiving 'product.php' page. The code I have on the product.php page is as follows: Code: [Select] <?php $ID = 0; if (isset($_GET['ID'])) { $ID = $_GET['ID']; } ?> <?php echo $_GET['price']; // outputs: 1 ?> However nothing is being echoed out. I just a blank screen. Am I missing like capital letters. My column is title 'ID'. Do I need to query the database in someway on the receiving page or do I just use a different GET code? Good day i am not receiving emails when hitting submit; not sure if my code is correct. jtconfirmation.co.za <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Names Confirmation RSVP</title> <link rel="stylesheet" href="church.css"> </head> <body> <form action="/mail_form.php" method="POST" id="church-form"> <div class="top"> <nav> <a href="index.html" class="mybutton">Home</a> </nav> </div> <div class="form"> <div class="info"> <h1>RSVP</h1> <h2>for the Confirmation Service of</h2> <h1>Name</h1> <p class="line">________________________________________</p> <h2>The Details</h2> <p>Sunday, 28 February 2021</p> <p>10:00 AM</p> <p>Please RSVP by 15 February 2021</p> <h2>Confirmation Service</h2> <p><a href="#" target="_blank"> Calvyn Protestant Church Diep River</a></p> <p>10 Keswick St, Elfindale</p> <p class="line">________________________________________</p> <input type="text" value="name" placeholder="Name"> <input type="email" value="email" placeholder="Email"> </div> <?php echo((!empty($errorMessage)) ? $errorMessage : '') ?> <button type="submit" class="accept" value="Send">Accept</button> <button type="submit" class="regret" value="Send">Regret</button> </div> </form> <script src="//cdnjs.cloudflare.com/ajax/libs/validate.js/0.13.1/validate.min.js"></script> <script> const constraints = { name: { presence: {allowEmpty: false} }, email: { presence: {allowEmpty: false}, email: true } }; const form = document.getElementById('church-form'); form.addEventListener('submit', function (event) { const formValues = { name: form.elements.name.value, email: form.elements.email.value }; const errors = validate(formValues, constraints); if (errors) { event.preventDefault(); const errorMessage = Object .values(errors) .map(function (fieldValues) { return fieldValues.join(', ') }) .join("\n"); alert(errorMessage); } }, false); </script> </body> </html> s <?php use PHPMailer\PHPMailer\PHPMailer; require __DIR__ . '/vendor/autoload.php'; $errors = []; $errorMessage = ''; if (!empty($_POST)) { $name = $_POST['name']; $email = $_POST['email']; if (empty($name)) { $errors[] = 'Name is empty'; } if (empty($email)) { $errors[] = 'Email is empty'; } else if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { $errors[] = 'Email is invalid'; } if (!empty($errors)) { $allErrors = join('<br/>', $errors); $errorMessage = "<p style='color: red;'>{$allErrors}</p>"; } else { $mail = new PHPMailer(); // specify SMTP credentials $mail->isSMTP(); $mail->Host = 'smtp.gmail.com'; $mail->SMTPAuth = true; $mail->Username = 'name@example.com'; $mail->Password = 'P@ssword123'; $mail->SMTPSecure = 'tls'; $mail->Port = 587; $mail->setFrom($email, 'Mailtrap Website'); $mail->addAddress('piotr@mailtrap.io ', 'Me'); $mail->Subject = 'RSVP Church'; // Enable HTML if needed $mail->isHTML(true); $bodyParagraphs = ["Name: {$name}", "Email: {$email}", "Message:", nl2br($message)]; $body = join('<br />', $bodyParagraphs); $mail->Body = $body; echo $body; if($mail->send()){ header('Location: thank-you.html'); // redirect to 'thank you' page } else { $errorMessage = 'Oops, something went wrong. Mailer Error: ' . $mail->ErrorInfo; } } } ?>
I have some data I'm posting from Swift to my php file via x-www-form-urlencoded. How can I decode this POST data? I am trying to retrieve certain keys of a post array. I am sending a payment form with a dynamic number of product id's. I will never know how many product id's will be sent for each order. When the post array returns the values to my script it returns them as: Code: [Select] $_POST['product_id_1'], $_POST['product_id_2'], etc. How would I be able to extract all post array keys that start with "product_id_? Here is what I was thinking earlier, but it doesn't work. Code: [Select] $i = 1; foreach ($_POST['product_id_' . $i] as $product) { $productId = $product['product_id_' . $i]; $queryInsert = mysql_query("INSERT INTO video_purchase (video_purchase_purchase_id, video_purchase_video_id) VALUES ($purchaseId, $productId)", $connect) or die(mysql_error()); $i++; } I'm using the example_form from securimage. I have modified the email address in the php script to my email address and uploaded everything to my hosting company's FTP server. I then fill out the form and click the submit message button and the form says "The captcha was correct and the message has been sent!" but I never receive the email. I have other basic php forms that work just fine just for some reason I can't get this one working. Could someone please let me know if I'm missing something here? Thanks |